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 NumberFromHandle(int handle) const;
36 	int MarkValue() const;	///< Bit set of marker numbers.
37 	bool Contains(int handle) const;
38 	bool InsertHandle(int handle, int markerNum);
39 	void RemoveHandle(int handle);
40 	bool RemoveNumber(int markerNum, bool all);
41 	void CombineWith(MarkerHandleSet *other);
42 };
43 
44 class LineMarkers : public PerLine {
45 	SplitVector<MarkerHandleSet *> markers;
46 	/// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
47 	int handleCurrent;
48 public:
LineMarkers()49 	LineMarkers() : handleCurrent(0) {
50 	}
51 	virtual ~LineMarkers();
52 	virtual void Init();
53 	virtual void InsertLine(int line);
54 	virtual void RemoveLine(int line);
55 
56 	int MarkValue(int line);
57 	int MarkerNext(int lineStart, int mask) const;
58 	int AddMark(int line, int marker, int lines);
59 	void MergeMarkers(int pos);
60 	bool DeleteMark(int line, int markerNum, bool all);
61 	void DeleteMarkFromHandle(int markerHandle);
62 	int LineFromHandle(int markerHandle);
63 };
64 
65 class LineLevels : public PerLine {
66 	SplitVector<int> levels;
67 public:
68 	virtual ~LineLevels();
69 	virtual void Init();
70 	virtual void InsertLine(int line);
71 	virtual void RemoveLine(int line);
72 
73 	void ExpandLevels(int sizeNew=-1);
74 	void ClearLevels();
75 	int SetLevel(int line, int level, int lines);
76 	int GetLevel(int line);
77 };
78 
79 class LineState : public PerLine {
80 	SplitVector<int> lineStates;
81 public:
LineState()82 	LineState() {
83 	}
84 	virtual ~LineState();
85 	virtual void Init();
86 	virtual void InsertLine(int line);
87 	virtual void RemoveLine(int line);
88 
89 	int SetLineState(int line, int state);
90 	int GetLineState(int line);
91 	int GetMaxLineState();
92 };
93 
94 class LineAnnotation : public PerLine {
95 	SplitVector<char *> annotations;
96 public:
LineAnnotation()97 	LineAnnotation() {
98 	}
99 	virtual ~LineAnnotation();
100 	virtual void Init();
101 	virtual void InsertLine(int line);
102 	virtual void RemoveLine(int line);
103 
104 	bool AnySet() const;
105 	bool MultipleStyles(int line) const;
106 	int Style(int line);
107 	const char *Text(int line) const;
108 	const unsigned char *Styles(int line) const;
109 	void SetText(int line, const char *text);
110 	void ClearAll();
111 	void SetStyle(int line, int style);
112 	void SetStyles(int line, const unsigned char *styles);
113 	int Length(int line) const;
114 	int Lines(int line) const;
115 };
116 
117 #ifdef SCI_NAMESPACE
118 }
119 #endif
120 
121 #endif
122