1 // Scintilla source code edit control
3 ** Manages data associated with each line of the document
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.
11 namespace Scintilla::Internal
{
14 * This holds the marker identifier and the marker type to display.
15 * MarkerHandleNumbers are members of lists.
17 struct MarkerHandleNumber
{
20 MarkerHandleNumber(int handle_
, int number_
) noexcept
: handle(handle_
), number(number_
) {}
24 * A marker handle set contains any number of MarkerHandleNumbers.
26 class MarkerHandleSet
{
27 std::forward_list
<MarkerHandleNumber
> mhList
;
31 bool Empty() const noexcept
;
32 int MarkValue() const noexcept
; ///< Bit set of marker numbers.
33 bool Contains(int handle
) const noexcept
;
34 bool InsertHandle(int handle
, int markerNum
);
35 void RemoveHandle(int handle
);
36 bool RemoveNumber(int markerNum
, bool all
);
37 void CombineWith(MarkerHandleSet
*other
) noexcept
;
38 MarkerHandleNumber
const *GetMarkerHandleNumber(int which
) const noexcept
;
41 class LineMarkers
: public PerLine
{
42 SplitVector
<std::unique_ptr
<MarkerHandleSet
>> markers
;
43 /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
46 LineMarkers() : handleCurrent(0) {
49 void InsertLine(Sci::Line line
) override
;
50 void InsertLines(Sci::Line line
, Sci::Line lines
) override
;
51 void RemoveLine(Sci::Line line
) override
;
53 int MarkValue(Sci::Line line
) const noexcept
;
54 Sci::Line
MarkerNext(Sci::Line lineStart
, int mask
) const noexcept
;
55 int AddMark(Sci::Line line
, int markerNum
, Sci::Line lines
);
56 void MergeMarkers(Sci::Line line
);
57 bool DeleteMark(Sci::Line line
, int markerNum
, bool all
);
58 void DeleteMarkFromHandle(int markerHandle
);
59 Sci::Line
LineFromHandle(int markerHandle
) const noexcept
;
60 int HandleFromLine(Sci::Line line
, int which
) const noexcept
;
61 int NumberFromLine(Sci::Line line
, int which
) const noexcept
;
64 class LineLevels
: public PerLine
{
65 SplitVector
<int> levels
;
70 void InsertLine(Sci::Line line
) override
;
71 void InsertLines(Sci::Line line
, Sci::Line lines
) override
;
72 void RemoveLine(Sci::Line line
) override
;
74 void ExpandLevels(Sci::Line sizeNew
=-1);
76 int SetLevel(Sci::Line line
, int level
, Sci::Line lines
);
77 int GetLevel(Sci::Line line
) const noexcept
;
78 FoldLevel
GetFoldLevel(Sci::Line line
) const noexcept
;
79 Sci::Line
GetFoldParent(Sci::Line line
) const noexcept
;
82 class LineState
: public PerLine
{
83 SplitVector
<int> lineStates
;
88 void InsertLine(Sci::Line line
) override
;
89 void InsertLines(Sci::Line line
, Sci::Line lines
) override
;
90 void RemoveLine(Sci::Line line
) override
;
92 int SetLineState(Sci::Line line
, int state
, Sci::Line lines
);
93 int GetLineState(Sci::Line line
);
94 Sci::Line
GetMaxLineState() const noexcept
;
97 class LineAnnotation
: public PerLine
{
98 SplitVector
<std::unique_ptr
<char []>> annotations
;
103 [[nodiscard
]] bool Empty() const noexcept
;
104 void Init() override
;
105 void InsertLine(Sci::Line line
) override
;
106 void InsertLines(Sci::Line line
, Sci::Line lines
) override
;
107 void RemoveLine(Sci::Line line
) override
;
109 bool MultipleStyles(Sci::Line line
) const noexcept
;
110 int Style(Sci::Line line
) const noexcept
;
111 const char *Text(Sci::Line line
) const noexcept
;
112 const unsigned char *Styles(Sci::Line line
) const noexcept
;
113 void SetText(Sci::Line line
, const char *text
);
115 void SetStyle(Sci::Line line
, int style
);
116 void SetStyles(Sci::Line line
, const unsigned char *styles
);
117 int Length(Sci::Line line
) const noexcept
;
118 int Lines(Sci::Line line
) const noexcept
;
121 typedef std::vector
<int> TabstopList
;
123 class LineTabstops
: public PerLine
{
124 SplitVector
<std::unique_ptr
<TabstopList
>> tabstops
;
128 void Init() override
;
129 void InsertLine(Sci::Line line
) override
;
130 void InsertLines(Sci::Line line
, Sci::Line lines
) override
;
131 void RemoveLine(Sci::Line line
) override
;
133 bool ClearTabstops(Sci::Line line
) noexcept
;
134 bool AddTabstop(Sci::Line line
, int x
);
135 int GetNextTabstop(Sci::Line line
, int x
) const noexcept
;