Merge pull request #2212 from TwlyY29/bibtex-parser
[geany-mirror.git] / scintilla / src / ViewStyle.h
blob587eb976a89ab7f4d9ca19bc1ca29abbd0c3cc6b
1 // Scintilla source code edit control
2 /** @file ViewStyle.h
3 ** Store information on how the document is to be viewed.
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 #ifndef VIEWSTYLE_H
9 #define VIEWSTYLE_H
11 namespace Scintilla {
13 /**
15 class MarginStyle {
16 public:
17 int style;
18 ColourDesired back;
19 int width;
20 int mask;
21 bool sensitive;
22 int cursor;
23 MarginStyle(int style_= SC_MARGIN_SYMBOL, int width_=0, int mask_=0) noexcept;
26 /**
30 class FontRealised : public FontMeasurements {
31 public:
32 Font font;
33 FontRealised() noexcept;
34 // FontRealised objects can not be copied.
35 FontRealised(const FontRealised &) = delete;
36 FontRealised(FontRealised &&) = delete;
37 FontRealised &operator=(const FontRealised &) = delete;
38 FontRealised &operator=(FontRealised &&) = delete;
39 virtual ~FontRealised();
40 void Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs);
43 enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
45 enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2, wsVisibleOnlyInIndent=3};
47 enum TabDrawMode {tdLongArrow=0, tdStrikeOut=1};
49 typedef std::map<FontSpecification, std::unique_ptr<FontRealised>> FontMap;
51 enum WrapMode { eWrapNone, eWrapWord, eWrapChar, eWrapWhitespace };
53 class ColourOptional : public ColourDesired {
54 public:
55 bool isSet;
56 ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) noexcept : ColourDesired(colour_), isSet(isSet_) {
58 ColourOptional(uptr_t wParam, sptr_t lParam) noexcept : ColourDesired(static_cast<int>(lParam)), isSet(wParam != 0) {
62 struct ForeBackColours {
63 ColourOptional fore;
64 ColourOptional back;
67 struct EdgeProperties {
68 int column;
69 ColourDesired colour;
70 EdgeProperties(int column_ = 0, ColourDesired colour_ = ColourDesired(0)) noexcept :
71 column(column_), colour(colour_) {
73 EdgeProperties(uptr_t wParam, sptr_t lParam) noexcept :
74 column(static_cast<int>(wParam)), colour(static_cast<int>(lParam)) {
78 /**
80 class ViewStyle {
81 UniqueStringSet fontNames;
82 FontMap fonts;
83 public:
84 std::vector<Style> styles;
85 int nextExtendedStyle;
86 std::vector<LineMarker> markers;
87 int largestMarkerHeight;
88 std::vector<Indicator> indicators;
89 bool indicatorsDynamic;
90 bool indicatorsSetFore;
91 int technology;
92 int lineHeight;
93 int lineOverlap;
94 unsigned int maxAscent;
95 unsigned int maxDescent;
96 XYPOSITION aveCharWidth;
97 XYPOSITION spaceWidth;
98 XYPOSITION tabWidth;
99 ForeBackColours selColours;
100 ColourDesired selAdditionalForeground;
101 ColourDesired selAdditionalBackground;
102 ColourDesired selBackground2;
103 int selAlpha;
104 int selAdditionalAlpha;
105 bool selEOLFilled;
106 ForeBackColours whitespaceColours;
107 int controlCharSymbol;
108 XYPOSITION controlCharWidth;
109 ColourDesired selbar;
110 ColourDesired selbarlight;
111 ColourOptional foldmarginColour;
112 ColourOptional foldmarginHighlightColour;
113 ForeBackColours hotspotColours;
114 bool hotspotUnderline;
115 bool hotspotSingleLine;
116 /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
117 int leftMarginWidth; ///< Spacing margin on left of text
118 int rightMarginWidth; ///< Spacing margin on right of text
119 int maskInLine; ///< Mask for markers to be put into text because there is nowhere for them to go in margin
120 int maskDrawInText; ///< Mask for markers that always draw in text
121 std::vector<MarginStyle> ms;
122 int fixedColumnWidth; ///< Total width of margins
123 bool marginInside; ///< true: margin included in text view, false: separate views
124 int textStart; ///< Starting x position of text within the view
125 int zoomLevel;
126 WhiteSpaceVisibility viewWhitespace;
127 TabDrawMode tabDrawMode;
128 int whitespaceSize;
129 IndentView viewIndentationGuides;
130 bool viewEOL;
131 ColourDesired caretcolour;
132 ColourDesired additionalCaretColour;
133 int caretLineFrame;
134 bool showCaretLineBackground;
135 bool alwaysShowCaretLineBackground;
136 ColourDesired caretLineBackground;
137 int caretLineAlpha;
138 int caretStyle;
139 int caretWidth;
140 bool someStylesProtected;
141 bool someStylesForceCase;
142 int extraFontFlag;
143 int extraAscent;
144 int extraDescent;
145 int marginStyleOffset;
146 int annotationVisible;
147 int annotationStyleOffset;
148 bool braceHighlightIndicatorSet;
149 int braceHighlightIndicator;
150 bool braceBadLightIndicatorSet;
151 int braceBadLightIndicator;
152 int edgeState;
153 EdgeProperties theEdge;
154 std::vector<EdgeProperties> theMultiEdge;
155 int marginNumberPadding; // the right-side padding of the number margin
156 int ctrlCharPadding; // the padding around control character text blobs
157 int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs
159 // Wrapping support
160 WrapMode wrapState;
161 int wrapVisualFlags;
162 int wrapVisualFlagsLocation;
163 int wrapVisualStartIndent;
164 int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
166 ViewStyle();
167 ViewStyle(const ViewStyle &source);
168 ViewStyle(ViewStyle &&) = delete;
169 // Can only be copied through copy constructor which ensures font names initialised correctly
170 ViewStyle &operator=(const ViewStyle &) = delete;
171 ViewStyle &operator=(ViewStyle &&) = delete;
172 ~ViewStyle();
173 void CalculateMarginWidthAndMask();
174 void Init(size_t stylesSize_=256);
175 void Refresh(Surface &surface, int tabInChars);
176 void ReleaseAllExtendedStyles() noexcept;
177 int AllocateExtendedStyles(int numberStyles);
178 void EnsureStyle(size_t index);
179 void ResetDefaultStyle();
180 void ClearStyles();
181 void SetStyleFontName(int styleIndex, const char *name);
182 bool ProtectionActive() const noexcept;
183 int ExternalMarginWidth() const noexcept;
184 int MarginFromLocation(Point pt) const;
185 bool ValidStyle(size_t styleIndex) const noexcept;
186 void CalcLargestMarkerHeight();
187 int GetFrameWidth() const noexcept;
188 bool IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const noexcept;
189 ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const;
190 bool SelectionBackgroundDrawn() const noexcept;
191 bool WhitespaceBackgroundDrawn() const noexcept;
192 ColourDesired WrapColour() const;
194 bool SetWrapState(int wrapState_) noexcept;
195 bool SetWrapVisualFlags(int wrapVisualFlags_) noexcept;
196 bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) noexcept;
197 bool SetWrapVisualStartIndent(int wrapVisualStartIndent_) noexcept;
198 bool SetWrapIndentMode(int wrapIndentMode_) noexcept;
200 bool WhiteSpaceVisible(bool inIndent) const noexcept;
202 enum class CaretShape { invisible, line, block, bar };
203 bool IsBlockCaretStyle() const noexcept;
204 CaretShape CaretShapeForMode(bool inOverstrike) const noexcept;
206 private:
207 void AllocStyles(size_t sizeNew);
208 void CreateAndAddFont(const FontSpecification &fs);
209 FontRealised *Find(const FontSpecification &fs);
210 void FindMaxAscentDescent();
215 #endif