1 // Scintilla source code edit control 2 /** @file PerLine.h 3 ** Manages data associated with each line of the document 4 **/ 5 // Copyright 1998-2009 by Neil Hodgson <neilh@scintilla.org> 6 // The License.txt file describes the conditions under which this software may be distributed. 7 8 #ifndef PERLINE_H 9 #define PERLINE_H 10 11 #ifdef SCI_NAMESPACE 12 namespace Scintilla { 13 #endif 14 15 /** 16 * This holds the marker identifier and the marker type to display. 17 * MarkerHandleNumbers are members of lists. 18 */ 19 struct MarkerHandleNumber { 20 int handle; 21 int number; 22 MarkerHandleNumber *next; 23 }; 24 25 /** 26 * A marker handle set contains any number of MarkerHandleNumbers. 27 */ 28 class MarkerHandleSet { 29 MarkerHandleNumber *root; 30 31 public: 32 MarkerHandleSet(); 33 ~MarkerHandleSet(); 34 int Length() const; 35 int MarkValue() const; ///< Bit set of marker numbers. 36 bool Contains(int handle) const; 37 bool InsertHandle(int handle, int markerNum); 38 void RemoveHandle(int handle); 39 bool RemoveNumber(int markerNum, bool all); 40 void CombineWith(MarkerHandleSet *other); 41 }; 42 43 class LineMarkers : public PerLine { 44 SplitVector<MarkerHandleSet *> markers; 45 /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. 46 int handleCurrent; 47 public: LineMarkers()48 LineMarkers() : handleCurrent(0) { 49 } 50 virtual ~LineMarkers(); 51 virtual void Init(); 52 virtual void InsertLine(int line); 53 virtual void RemoveLine(int line); 54 55 int MarkValue(int line); 56 int MarkerNext(int lineStart, int mask) const; 57 int AddMark(int line, int marker, int lines); 58 void MergeMarkers(int pos); 59 bool DeleteMark(int line, int markerNum, bool all); 60 void DeleteMarkFromHandle(int markerHandle); 61 int LineFromHandle(int markerHandle); 62 }; 63 64 class LineLevels : public PerLine { 65 SplitVector<int> levels; 66 public: 67 virtual ~LineLevels(); 68 virtual void Init(); 69 virtual void InsertLine(int line); 70 virtual void RemoveLine(int line); 71 72 void ExpandLevels(int sizeNew=-1); 73 void ClearLevels(); 74 int SetLevel(int line, int level, int lines); 75 int GetLevel(int line) const; 76 }; 77 78 class LineState : public PerLine { 79 SplitVector<int> lineStates; 80 public: LineState()81 LineState() { 82 } 83 virtual ~LineState(); 84 virtual void Init(); 85 virtual void InsertLine(int line); 86 virtual void RemoveLine(int line); 87 88 int SetLineState(int line, int state); 89 int GetLineState(int line); 90 int GetMaxLineState() const; 91 }; 92 93 class LineAnnotation : public PerLine { 94 SplitVector<char *> annotations; 95 public: LineAnnotation()96 LineAnnotation() { 97 } 98 virtual ~LineAnnotation(); 99 virtual void Init(); 100 virtual void InsertLine(int line); 101 virtual void RemoveLine(int line); 102 103 bool MultipleStyles(int line) const; 104 int Style(int line) const; 105 const char *Text(int line) const; 106 const unsigned char *Styles(int line) const; 107 void SetText(int line, const char *text); 108 void ClearAll(); 109 void SetStyle(int line, int style); 110 void SetStyles(int line, const unsigned char *styles); 111 int Length(int line) const; 112 int Lines(int line) const; 113 }; 114 115 typedef std::vector<int> TabstopList; 116 117 class LineTabstops : public PerLine { 118 SplitVector<TabstopList *> tabstops; 119 public: LineTabstops()120 LineTabstops() { 121 } 122 virtual ~LineTabstops(); 123 virtual void Init(); 124 virtual void InsertLine(int line); 125 virtual void RemoveLine(int line); 126 127 bool ClearTabstops(int line); 128 bool AddTabstop(int line, int x); 129 int GetNextTabstop(int line, int x) const; 130 }; 131 132 #ifdef SCI_NAMESPACE 133 } 134 #endif 135 136 #endif 137