Use italic for note labels in the Build Commands dialog.
[geany-mirror.git] / scintilla / PositionCache.h
blob754545877c2f72caf62ecf86599dcaa0a0aa7812
1 // Scintilla source code edit control
2 /** @file PositionCache.h
3 ** Classes for caching layout information.
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.
8 #ifndef POSITIONCACHE_H
9 #define POSITIONCACHE_H
11 #ifdef SCI_NAMESPACE
12 namespace Scintilla {
13 #endif
15 static inline bool IsEOLChar(char ch) {
16 return (ch == '\r') || (ch == '\n');
19 /**
21 class LineLayout {
22 private:
23 friend class LineLayoutCache;
24 int *lineStarts;
25 int lenLineStarts;
26 /// Drawing is only performed for @a maxLineLength characters on each line.
27 int lineNumber;
28 bool inCache;
29 public:
30 enum { wrapWidthInfinite = 0x7ffffff };
31 int maxLineLength;
32 int numCharsInLine;
33 int numCharsBeforeEOL;
34 enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity;
35 int xHighlightGuide;
36 bool highlightColumn;
37 Selection *psel;
38 bool containsCaret;
39 int edgeColumn;
40 char *chars;
41 unsigned char *styles;
42 int styleBitsSet;
43 char *indicators;
44 int *positions;
45 char bracePreviousStyles[2];
47 // Hotspot support
48 int hsStart;
49 int hsEnd;
51 // Wrapped line support
52 int widthLine;
53 int lines;
54 int wrapIndent; // In pixels
56 LineLayout(int maxLineLength_);
57 virtual ~LineLayout();
58 void Resize(int maxLineLength_);
59 void Free();
60 void Invalidate(validLevel validity_);
61 int LineStart(int line) const;
62 int LineLastVisible(int line) const;
63 bool InLine(int offset, int line) const;
64 void SetLineStart(int line, int start);
65 void SetBracesHighlight(Range rangeLine, Position braces[],
66 char bracesMatchStyle, int xHighlight);
67 void RestoreBracesHighlight(Range rangeLine, Position braces[]);
68 int FindBefore(int x, int lower, int upper) const;
69 int EndLineStyle() const;
72 /**
74 class LineLayoutCache {
75 int level;
76 int length;
77 int size;
78 LineLayout **cache;
79 bool allInvalidated;
80 int styleClock;
81 int useCount;
82 void Allocate(int length_);
83 void AllocateForLevel(int linesOnScreen, int linesInDoc);
84 public:
85 LineLayoutCache();
86 virtual ~LineLayoutCache();
87 void Deallocate();
88 enum {
89 llcNone=SC_CACHE_NONE,
90 llcCaret=SC_CACHE_CARET,
91 llcPage=SC_CACHE_PAGE,
92 llcDocument=SC_CACHE_DOCUMENT
94 void Invalidate(LineLayout::validLevel validity_);
95 void SetLevel(int level_);
96 int GetLevel() const { return level; }
97 LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
98 int linesOnScreen, int linesInDoc);
99 void Dispose(LineLayout *ll);
102 class PositionCacheEntry {
103 unsigned int styleNumber:8;
104 unsigned int len:8;
105 unsigned int clock:16;
106 short *positions;
107 public:
108 PositionCacheEntry();
109 ~PositionCacheEntry();
110 void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_, unsigned int clock);
111 void Clear();
112 bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_) const;
113 static int Hash(unsigned int styleNumber, const char *s, unsigned int len);
114 bool NewerThan(const PositionCacheEntry &other) const;
115 void ResetClock();
118 // Class to break a line of text into shorter runs at sensible places.
119 class BreakFinder {
120 // If a whole run is longer than lengthStartSubdivision then subdivide
121 // into smaller runs at spaces or punctuation.
122 enum { lengthStartSubdivision = 300 };
123 // Try to make each subdivided run lengthEachSubdivision or shorter.
124 enum { lengthEachSubdivision = 100 };
125 LineLayout *ll;
126 int lineStart;
127 int lineEnd;
128 int posLineStart;
129 bool utf8;
130 int nextBreak;
131 int *selAndEdge;
132 unsigned int saeSize;
133 unsigned int saeLen;
134 unsigned int saeCurrentPos;
135 int saeNext;
136 int subBreak;
137 void Insert(int val);
138 public:
139 BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart, bool breakForSelection);
140 ~BreakFinder();
141 int First() const;
142 int Next();
145 class PositionCache {
146 PositionCacheEntry *pces;
147 size_t size;
148 unsigned int clock;
149 bool allClear;
150 public:
151 PositionCache();
152 ~PositionCache();
153 void Clear();
154 void SetSize(size_t size_);
155 int GetSize() const { return size; }
156 void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
157 const char *s, unsigned int len, int *positions);
160 inline bool IsSpaceOrTab(int ch) {
161 return ch == ' ' || ch == '\t';
164 #ifdef SCI_NAMESPACE
166 #endif
168 #endif