Fixed issue #2059: "Go to line" CLI argument support for diff command
[TortoiseGit.git] / ext / scintilla / src / Style.cxx
blobe12bdd1b08ed05f1c1a31a969d8442f64789380e
1 // Scintilla source code edit control
2 /** @file Style.cxx
3 ** Defines the font and colour style for a class of text.
4 **/
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #include <string.h>
10 #include "Platform.h"
12 #include "Scintilla.h"
13 #include "Style.h"
15 #ifdef SCI_NAMESPACE
16 using namespace Scintilla;
17 #endif
19 FontAlias::FontAlias() {
22 FontAlias::~FontAlias() {
23 SetID(0);
24 // ~Font will not release the actual font resource since it is now 0
27 void FontAlias::MakeAlias(Font &fontOrigin) {
28 SetID(fontOrigin.GetID());
31 void FontAlias::ClearFont() {
32 SetID(0);
35 bool FontSpecification::operator==(const FontSpecification &other) const {
36 return fontName == other.fontName &&
37 weight == other.weight &&
38 italic == other.italic &&
39 size == other.size &&
40 characterSet == other.characterSet &&
41 extraFontFlag == other.extraFontFlag;
44 bool FontSpecification::operator<(const FontSpecification &other) const {
45 if (fontName != other.fontName)
46 return fontName < other.fontName;
47 if (weight != other.weight)
48 return weight < other.weight;
49 if (italic != other.italic)
50 return italic == false;
51 if (size != other.size)
52 return size < other.size;
53 if (characterSet != other.characterSet)
54 return characterSet < other.characterSet;
55 if (extraFontFlag != other.extraFontFlag)
56 return extraFontFlag < other.extraFontFlag;
57 return false;
60 FontMeasurements::FontMeasurements() {
61 Clear();
64 void FontMeasurements::Clear() {
65 ascent = 1;
66 descent = 1;
67 aveCharWidth = 1;
68 spaceWidth = 1;
69 sizeZoomed = 2;
72 Style::Style() : FontSpecification() {
73 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
74 Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
75 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
78 Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
79 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
80 0, 0, 0,
81 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
82 fore = source.fore;
83 back = source.back;
84 characterSet = source.characterSet;
85 weight = source.weight;
86 italic = source.italic;
87 size = source.size;
88 fontName = source.fontName;
89 eolFilled = source.eolFilled;
90 underline = source.underline;
91 caseForce = source.caseForce;
92 visible = source.visible;
93 changeable = source.changeable;
94 hotspot = source.hotspot;
97 Style::~Style() {
100 Style &Style::operator=(const Style &source) {
101 if (this == &source)
102 return * this;
103 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
104 0, 0, SC_CHARSET_DEFAULT,
105 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
106 fore = source.fore;
107 back = source.back;
108 characterSet = source.characterSet;
109 weight = source.weight;
110 italic = source.italic;
111 size = source.size;
112 fontName = source.fontName;
113 eolFilled = source.eolFilled;
114 underline = source.underline;
115 caseForce = source.caseForce;
116 visible = source.visible;
117 changeable = source.changeable;
118 return *this;
121 void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
122 const char *fontName_, int characterSet_,
123 int weight_, bool italic_, bool eolFilled_,
124 bool underline_, ecaseForced caseForce_,
125 bool visible_, bool changeable_, bool hotspot_) {
126 fore = fore_;
127 back = back_;
128 characterSet = characterSet_;
129 weight = weight_;
130 italic = italic_;
131 size = size_;
132 fontName = fontName_;
133 eolFilled = eolFilled_;
134 underline = underline_;
135 caseForce = caseForce_;
136 visible = visible_;
137 changeable = changeable_;
138 hotspot = hotspot_;
139 font.ClearFont();
140 FontMeasurements::Clear();
143 void Style::ClearTo(const Style &source) {
144 Clear(
145 source.fore,
146 source.back,
147 source.size,
148 source.fontName,
149 source.characterSet,
150 source.weight,
151 source.italic,
152 source.eolFilled,
153 source.underline,
154 source.caseForce,
155 source.visible,
156 source.changeable,
157 source.hotspot);
160 void Style::Copy(Font &font_, const FontMeasurements &fm_) {
161 font.MakeAlias(font_);
162 #if PLAT_WX
163 font.SetAscent(fm_.ascent);
164 #endif
165 (FontMeasurements &)(*this) = fm_;