10
10
#include "Platform.h"
12
12
#include "Scintilla.h"
13
#include "SplitVector.h"
14
#include "Partitioning.h"
15
#include "RunStyles.h"
13
16
#include "Indicator.h"
15
18
#include "LineMarker.h"
17
20
#include "ViewStyle.h"
23
using namespace Scintilla;
19
26
MarginStyle::MarginStyle() :
20
27
style(SC_MARGIN_SYMBOL), width(0), mask(0), sensitive(false) {
23
30
// A list of the fontnames - avoids wasting space in each style
24
31
FontNames::FontNames() {
33
names = new char *[size];
28
37
FontNames::~FontNames() {
32
43
void FontNames::Clear() {
60
int sizeNew = size * 2;
61
char **namesNew = new char *[sizeNew];
62
for (int j=0;j<max;j++) {
63
namesNew[j] = names[j];
47
69
names[max] = new char[strlen(name) + 1];
48
70
strcpy(names[max], name);
57
79
ViewStyle::ViewStyle(const ViewStyle &source) {
59
for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
80
Init(source.stylesSize);
81
for (unsigned int sty=0;sty<source.stylesSize;sty++) {
60
82
styles[sty] = source.styles[sty];
61
83
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
62
84
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
74
96
selbackground.desired = source.selbackground.desired;
75
97
selbackground2.desired = source.selbackground2.desired;
76
98
selAlpha = source.selAlpha;
99
selEOLFilled = source.selEOLFilled;
78
101
foldmarginColourSet = source.foldmarginColourSet;
79
102
foldmarginColour.desired = source.foldmarginColour.desired;
99
122
caretLineAlpha = source.caretLineAlpha;
100
123
edgecolour.desired = source.edgecolour.desired;
101
124
edgeState = source.edgeState;
125
caretStyle = source.caretStyle;
102
126
caretWidth = source.caretWidth;
103
127
someStylesProtected = false;
104
128
leftMarginWidth = source.leftMarginWidth;
120
144
ViewStyle::~ViewStyle() {
123
void ViewStyle::Init() {
149
void ViewStyle::Init(size_t stylesSize_) {
152
AllocStyles(stylesSize_);
124
153
fontNames.Clear();
125
154
ResetDefaultStyle();
127
156
indicators[0].style = INDIC_SQUIGGLE;
157
indicators[0].under = false;
128
158
indicators[0].fore = ColourDesired(0, 0x7f, 0);
129
159
indicators[1].style = INDIC_TT;
160
indicators[1].under = false;
130
161
indicators[1].fore = ColourDesired(0, 0, 0xff);
131
162
indicators[2].style = INDIC_PLAIN;
163
indicators[2].under = false;
132
164
indicators[2].fore = ColourDesired(0xff, 0, 0);
143
175
selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
144
176
selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
145
177
selAlpha = SC_ALPHA_NOALPHA;
178
selEOLFilled = false;
147
180
foldmarginColourSet = false;
148
181
foldmarginColour.desired = ColourDesired(0xff, 0, 0);
163
196
caretLineAlpha = SC_ALPHA_NOALPHA;
164
197
edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
165
198
edgeState = EDGE_NONE;
199
caretStyle = CARETSTYLE_LINE;
167
201
someStylesProtected = false;
204
238
void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
206
for (i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
240
for (i=0;i<stylesSize;i++) {
207
241
pal.WantFind(styles[i].fore, want);
208
242
pal.WantFind(styles[i].back, want);
238
272
maxAscent = styles[STYLE_DEFAULT].ascent;
239
273
maxDescent = styles[STYLE_DEFAULT].descent;
240
274
someStylesProtected = false;
241
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
275
for (unsigned int i=0; i<stylesSize; i++) {
242
276
if (i != STYLE_DEFAULT) {
243
277
styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT], extraFontFlag);
244
278
if (maxAscent < styles[i].ascent)
303
void ViewStyle::AllocStyles(size_t sizeNew) {
304
Style *stylesNew = new Style[sizeNew];
306
for (; i<stylesSize; i++) {
307
stylesNew[i] = styles[i];
308
stylesNew[i].fontName = styles[i].fontName;
310
if (stylesSize > STYLE_DEFAULT) {
311
for (; i<sizeNew; i++) {
312
if (i != STYLE_DEFAULT) {
313
stylesNew[i].ClearTo(styles[STYLE_DEFAULT]);
319
stylesSize = sizeNew;
322
void ViewStyle::EnsureStyle(size_t index) {
323
if (index >= stylesSize) {
324
size_t sizeNew = stylesSize * 2;
325
while (sizeNew < index)
327
AllocStyles(sizeNew);
269
331
void ViewStyle::ResetDefaultStyle() {
270
332
styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
271
333
ColourDesired(0xff,0xff,0xff),
272
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
334
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
273
335
SC_CHARSET_DEFAULT,
274
336
false, false, false, false, Style::caseMixed, true, true, false);
277
339
void ViewStyle::ClearStyles() {
278
340
// Reset all styles to be like the default style
279
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
341
for (unsigned int i=0; i<stylesSize; i++) {
280
342
if (i != STYLE_DEFAULT) {
281
343
styles[i].ClearTo(styles[STYLE_DEFAULT]);