aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Decoration.h
blob: 0d799920e3ba2d76f16126ae6d80e64d5e4e19f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/** @file Decoration.h
 ** Visual elements added over text.
 **/
// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.

#ifndef DECORATION_H
#define DECORATION_H

namespace Scintilla {

class Decoration {
	int indicator;
public:
	RunStyles<Sci::Position, int> rs;

	explicit Decoration(int indicator_);
	~Decoration();

	bool Empty() const;
	int Indicator() const {
		return indicator;
	}
};

class DecorationList {
	int currentIndicator;
	int currentValue;
	Decoration *current;	// Cached so FillRange doesn't have to search for each call.
	Sci::Position lengthDocument;
	// Ordered by indicator
	std::vector<std::unique_ptr<Decoration>> decorationList;
	std::vector<const Decoration*> decorationView;	// Read-only view of decorationList
	bool clickNotified;

	Decoration *DecorationFromIndicator(int indicator);
	Decoration *Create(int indicator, Sci::Position length);
	void Delete(int indicator);
	void DeleteAnyEmpty();
	void SetView();
public:

	DecorationList();
	~DecorationList();

	const std::vector<const Decoration*> &View() const { return decorationView; }

	void SetCurrentIndicator(int indicator);
	int GetCurrentIndicator() const { return currentIndicator; }

	void SetCurrentValue(int value);
	int GetCurrentValue() const { return currentValue; }

	// Returns true if some values may have changed
	bool FillRange(Sci::Position &position, int value, Sci::Position &fillLength);

	void InsertSpace(Sci::Position position, Sci::Position insertLength);
	void DeleteRange(Sci::Position position, Sci::Position deleteLength);

	void DeleteLexerDecorations();

	int AllOnFor(Sci::Position position) const;
	int ValueAt(int indicator, Sci::Position position);
	Sci::Position Start(int indicator, Sci::Position position);
	Sci::Position End(int indicator, Sci::Position position);

	bool ClickNotified() const {
		return clickNotified;
	}
	void SetClickNotified(bool notified) {
		clickNotified = notified;
	}
};

}

#endif