]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/Decoration.cxx
e4ac0e07c613e93ed3d1e6c471a291ffbbca01c7
1 /** @file Decoration.cxx
2 ** Visual elements added over text.
4 // Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
5 // The License.txt file describes the conditions under which this software may be distributed.
14 #include "Scintilla.h"
15 #include "SplitVector.h"
16 #include "Partitioning.h"
17 #include "RunStyles.h"
18 #include "Decoration.h"
21 using namespace Scintilla
;
24 Decoration::Decoration(int indicator_
) : next(0), indicator(indicator_
) {
27 Decoration::~Decoration() {
30 bool Decoration::Empty() {
31 return rs
.starts
->Partitions() == 1;
34 DecorationList::DecorationList() : currentIndicator(0), currentValue(1), current(0),
35 lengthDocument(0), root(0), clickNotified(false) {
38 DecorationList::~DecorationList() {
39 Decoration
*deco
= root
;
41 Decoration
*decoNext
= deco
->next
;
49 Decoration
*DecorationList::DecorationFromIndicator(int indicator
) {
50 for (Decoration
*deco
=root
; deco
; deco
= deco
->next
) {
51 if (deco
->indicator
== indicator
) {
58 Decoration
*DecorationList::Create(int indicator
, int length
) {
59 currentIndicator
= indicator
;
60 Decoration
*decoNew
= new Decoration(indicator
);
61 decoNew
->rs
.InsertSpace(0, length
);
63 Decoration
*decoPrev
= 0;
64 Decoration
*deco
= root
;
66 while (deco
&& (deco
->indicator
< indicator
)) {
75 decoPrev
->next
= decoNew
;
80 void DecorationList::Delete(int indicator
) {
81 Decoration
*decoToDelete
= 0;
83 if (root
->indicator
== indicator
) {
87 Decoration
*deco
=root
;
88 while (deco
->next
&& !decoToDelete
) {
89 if (deco
->next
&& deco
->next
->indicator
== indicator
) {
90 decoToDelete
= deco
->next
;
91 deco
->next
= decoToDelete
->next
;
104 void DecorationList::SetCurrentIndicator(int indicator
) {
105 currentIndicator
= indicator
;
106 current
= DecorationFromIndicator(indicator
);
110 void DecorationList::SetCurrentValue(int value
) {
111 currentValue
= value
? value
: 1;
114 bool DecorationList::FillRange(int &position
, int value
, int &fillLength
) {
116 current
= DecorationFromIndicator(currentIndicator
);
118 current
= Create(currentIndicator
, lengthDocument
);
121 bool changed
= current
->rs
.FillRange(position
, value
, fillLength
);
122 if (current
->Empty()) {
123 Delete(currentIndicator
);
128 void DecorationList::InsertSpace(int position
, int insertLength
) {
129 lengthDocument
+= insertLength
;
130 for (Decoration
*deco
=root
; deco
; deco
= deco
->next
) {
131 deco
->rs
.InsertSpace(position
, insertLength
);
135 void DecorationList::DeleteRange(int position
, int deleteLength
) {
136 lengthDocument
-= deleteLength
;
138 for (deco
=root
; deco
; deco
= deco
->next
) {
139 deco
->rs
.DeleteRange(position
, deleteLength
);
144 void DecorationList::DeleteAnyEmpty() {
145 Decoration
*deco
= root
;
148 Delete(deco
->indicator
);
156 int DecorationList::AllOnFor(int position
) {
158 for (Decoration
*deco
=root
; deco
; deco
= deco
->next
) {
159 if (deco
->rs
.ValueAt(position
)) {
160 mask
|= 1 << deco
->indicator
;
166 int DecorationList::ValueAt(int indicator
, int position
) {
167 Decoration
*deco
= DecorationFromIndicator(indicator
);
169 return deco
->rs
.ValueAt(position
);
174 int DecorationList::Start(int indicator
, int position
) {
175 Decoration
*deco
= DecorationFromIndicator(indicator
);
177 return deco
->rs
.StartRun(position
);
182 int DecorationList::End(int indicator
, int position
) {
183 Decoration
*deco
= DecorationFromIndicator(indicator
);
185 return deco
->rs
.EndRun(position
);