~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/sdk/wxscintilla/src/scintilla/src/PositionCache.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

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