1*8af74909SZhong Yang // Scintilla source code edit control 2*8af74909SZhong Yang /** @file PerLine.h 3*8af74909SZhong Yang ** Manages data associated with each line of the document 4*8af74909SZhong Yang **/ 5*8af74909SZhong Yang // Copyright 1998-2009 by Neil Hodgson <[email protected]> 6*8af74909SZhong Yang // The License.txt file describes the conditions under which this software may be distributed. 7*8af74909SZhong Yang 8*8af74909SZhong Yang #ifndef PERLINE_H 9*8af74909SZhong Yang #define PERLINE_H 10*8af74909SZhong Yang 11*8af74909SZhong Yang namespace Scintilla { 12*8af74909SZhong Yang 13*8af74909SZhong Yang /** 14*8af74909SZhong Yang * This holds the marker identifier and the marker type to display. 15*8af74909SZhong Yang * MarkerHandleNumbers are members of lists. 16*8af74909SZhong Yang */ 17*8af74909SZhong Yang struct MarkerHandleNumber { 18*8af74909SZhong Yang int handle; 19*8af74909SZhong Yang int number; MarkerHandleNumberMarkerHandleNumber20*8af74909SZhong Yang MarkerHandleNumber(int handle_, int number_) noexcept : handle(handle_), number(number_) {} 21*8af74909SZhong Yang }; 22*8af74909SZhong Yang 23*8af74909SZhong Yang /** 24*8af74909SZhong Yang * A marker handle set contains any number of MarkerHandleNumbers. 25*8af74909SZhong Yang */ 26*8af74909SZhong Yang class MarkerHandleSet { 27*8af74909SZhong Yang std::forward_list<MarkerHandleNumber> mhList; 28*8af74909SZhong Yang 29*8af74909SZhong Yang public: 30*8af74909SZhong Yang MarkerHandleSet(); 31*8af74909SZhong Yang // Deleted so MarkerHandleSet objects can not be copied. 32*8af74909SZhong Yang MarkerHandleSet(const MarkerHandleSet &) = delete; 33*8af74909SZhong Yang MarkerHandleSet(MarkerHandleSet &&) = delete; 34*8af74909SZhong Yang void operator=(const MarkerHandleSet &) = delete; 35*8af74909SZhong Yang void operator=(MarkerHandleSet &&) = delete; 36*8af74909SZhong Yang ~MarkerHandleSet(); 37*8af74909SZhong Yang bool Empty() const noexcept; 38*8af74909SZhong Yang int MarkValue() const noexcept; ///< Bit set of marker numbers. 39*8af74909SZhong Yang bool Contains(int handle) const noexcept; 40*8af74909SZhong Yang bool InsertHandle(int handle, int markerNum); 41*8af74909SZhong Yang void RemoveHandle(int handle); 42*8af74909SZhong Yang bool RemoveNumber(int markerNum, bool all); 43*8af74909SZhong Yang void CombineWith(MarkerHandleSet *other) noexcept; 44*8af74909SZhong Yang MarkerHandleNumber const *GetMarkerHandleNumber(int which) const noexcept; 45*8af74909SZhong Yang }; 46*8af74909SZhong Yang 47*8af74909SZhong Yang class LineMarkers : public PerLine { 48*8af74909SZhong Yang SplitVector<std::unique_ptr<MarkerHandleSet>> markers; 49*8af74909SZhong Yang /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. 50*8af74909SZhong Yang int handleCurrent; 51*8af74909SZhong Yang public: LineMarkers()52*8af74909SZhong Yang LineMarkers() : handleCurrent(0) { 53*8af74909SZhong Yang } 54*8af74909SZhong Yang // Deleted so LineMarkers objects can not be copied. 55*8af74909SZhong Yang LineMarkers(const LineMarkers &) = delete; 56*8af74909SZhong Yang LineMarkers(LineMarkers &&) = delete; 57*8af74909SZhong Yang void operator=(const LineMarkers &) = delete; 58*8af74909SZhong Yang void operator=(LineMarkers &&) = delete; 59*8af74909SZhong Yang ~LineMarkers() override; 60*8af74909SZhong Yang void Init() override; 61*8af74909SZhong Yang void InsertLine(Sci::Line line) override; 62*8af74909SZhong Yang void InsertLines(Sci::Line line, Sci::Line lines) override; 63*8af74909SZhong Yang void RemoveLine(Sci::Line line) override; 64*8af74909SZhong Yang 65*8af74909SZhong Yang int MarkValue(Sci::Line line) const noexcept; 66*8af74909SZhong Yang Sci::Line MarkerNext(Sci::Line lineStart, int mask) const noexcept; 67*8af74909SZhong Yang int AddMark(Sci::Line line, int markerNum, Sci::Line lines); 68*8af74909SZhong Yang void MergeMarkers(Sci::Line line); 69*8af74909SZhong Yang bool DeleteMark(Sci::Line line, int markerNum, bool all); 70*8af74909SZhong Yang void DeleteMarkFromHandle(int markerHandle); 71*8af74909SZhong Yang Sci::Line LineFromHandle(int markerHandle) const noexcept; 72*8af74909SZhong Yang int HandleFromLine(Sci::Line line, int which) const noexcept; 73*8af74909SZhong Yang int NumberFromLine(Sci::Line line, int which) const noexcept; 74*8af74909SZhong Yang }; 75*8af74909SZhong Yang 76*8af74909SZhong Yang class LineLevels : public PerLine { 77*8af74909SZhong Yang SplitVector<int> levels; 78*8af74909SZhong Yang public: LineLevels()79*8af74909SZhong Yang LineLevels() { 80*8af74909SZhong Yang } 81*8af74909SZhong Yang // Deleted so LineLevels objects can not be copied. 82*8af74909SZhong Yang LineLevels(const LineLevels &) = delete; 83*8af74909SZhong Yang LineLevels(LineLevels &&) = delete; 84*8af74909SZhong Yang void operator=(const LineLevels &) = delete; 85*8af74909SZhong Yang void operator=(LineLevels &&) = delete; 86*8af74909SZhong Yang ~LineLevels() override; 87*8af74909SZhong Yang void Init() override; 88*8af74909SZhong Yang void InsertLine(Sci::Line line) override; 89*8af74909SZhong Yang void InsertLines(Sci::Line line, Sci::Line lines) override; 90*8af74909SZhong Yang void RemoveLine(Sci::Line line) override; 91*8af74909SZhong Yang 92*8af74909SZhong Yang void ExpandLevels(Sci::Line sizeNew=-1); 93*8af74909SZhong Yang void ClearLevels(); 94*8af74909SZhong Yang int SetLevel(Sci::Line line, int level, Sci::Line lines); 95*8af74909SZhong Yang int GetLevel(Sci::Line line) const noexcept; 96*8af74909SZhong Yang }; 97*8af74909SZhong Yang 98*8af74909SZhong Yang class LineState : public PerLine { 99*8af74909SZhong Yang SplitVector<int> lineStates; 100*8af74909SZhong Yang public: LineState()101*8af74909SZhong Yang LineState() { 102*8af74909SZhong Yang } 103*8af74909SZhong Yang // Deleted so LineState objects can not be copied. 104*8af74909SZhong Yang LineState(const LineState &) = delete; 105*8af74909SZhong Yang LineState(LineState &&) = delete; 106*8af74909SZhong Yang void operator=(const LineState &) = delete; 107*8af74909SZhong Yang void operator=(LineState &&) = delete; 108*8af74909SZhong Yang ~LineState() override; 109*8af74909SZhong Yang void Init() override; 110*8af74909SZhong Yang void InsertLine(Sci::Line line) override; 111*8af74909SZhong Yang void InsertLines(Sci::Line line, Sci::Line lines) override; 112*8af74909SZhong Yang void RemoveLine(Sci::Line line) override; 113*8af74909SZhong Yang 114*8af74909SZhong Yang int SetLineState(Sci::Line line, int state); 115*8af74909SZhong Yang int GetLineState(Sci::Line line); 116*8af74909SZhong Yang Sci::Line GetMaxLineState() const noexcept; 117*8af74909SZhong Yang }; 118*8af74909SZhong Yang 119*8af74909SZhong Yang class LineAnnotation : public PerLine { 120*8af74909SZhong Yang SplitVector<std::unique_ptr<char []>> annotations; 121*8af74909SZhong Yang public: LineAnnotation()122*8af74909SZhong Yang LineAnnotation() { 123*8af74909SZhong Yang } 124*8af74909SZhong Yang // Deleted so LineAnnotation objects can not be copied. 125*8af74909SZhong Yang LineAnnotation(const LineAnnotation &) = delete; 126*8af74909SZhong Yang LineAnnotation(LineAnnotation &&) = delete; 127*8af74909SZhong Yang void operator=(const LineAnnotation &) = delete; 128*8af74909SZhong Yang void operator=(LineAnnotation &&) = delete; 129*8af74909SZhong Yang ~LineAnnotation() override; 130*8af74909SZhong Yang void Init() override; 131*8af74909SZhong Yang void InsertLine(Sci::Line line) override; 132*8af74909SZhong Yang void InsertLines(Sci::Line line, Sci::Line lines) override; 133*8af74909SZhong Yang void RemoveLine(Sci::Line line) override; 134*8af74909SZhong Yang 135*8af74909SZhong Yang bool MultipleStyles(Sci::Line line) const noexcept; 136*8af74909SZhong Yang int Style(Sci::Line line) const noexcept; 137*8af74909SZhong Yang const char *Text(Sci::Line line) const noexcept; 138*8af74909SZhong Yang const unsigned char *Styles(Sci::Line line) const noexcept; 139*8af74909SZhong Yang void SetText(Sci::Line line, const char *text); 140*8af74909SZhong Yang void ClearAll(); 141*8af74909SZhong Yang void SetStyle(Sci::Line line, int style); 142*8af74909SZhong Yang void SetStyles(Sci::Line line, const unsigned char *styles); 143*8af74909SZhong Yang int Length(Sci::Line line) const noexcept; 144*8af74909SZhong Yang int Lines(Sci::Line line) const noexcept; 145*8af74909SZhong Yang }; 146*8af74909SZhong Yang 147*8af74909SZhong Yang typedef std::vector<int> TabstopList; 148*8af74909SZhong Yang 149*8af74909SZhong Yang class LineTabstops : public PerLine { 150*8af74909SZhong Yang SplitVector<std::unique_ptr<TabstopList>> tabstops; 151*8af74909SZhong Yang public: LineTabstops()152*8af74909SZhong Yang LineTabstops() { 153*8af74909SZhong Yang } 154*8af74909SZhong Yang // Deleted so LineTabstops objects can not be copied. 155*8af74909SZhong Yang LineTabstops(const LineTabstops &) = delete; 156*8af74909SZhong Yang LineTabstops(LineTabstops &&) = delete; 157*8af74909SZhong Yang void operator=(const LineTabstops &) = delete; 158*8af74909SZhong Yang void operator=(LineTabstops &&) = delete; 159*8af74909SZhong Yang ~LineTabstops() override; 160*8af74909SZhong Yang void Init() override; 161*8af74909SZhong Yang void InsertLine(Sci::Line line) override; 162*8af74909SZhong Yang void InsertLines(Sci::Line line, Sci::Line lines) override; 163*8af74909SZhong Yang void RemoveLine(Sci::Line line) override; 164*8af74909SZhong Yang 165*8af74909SZhong Yang bool ClearTabstops(Sci::Line line) noexcept; 166*8af74909SZhong Yang bool AddTabstop(Sci::Line line, int x); 167*8af74909SZhong Yang int GetNextTabstop(Sci::Line line, int x) const noexcept; 168*8af74909SZhong Yang }; 169*8af74909SZhong Yang 170*8af74909SZhong Yang } 171*8af74909SZhong Yang 172*8af74909SZhong Yang #endif 173