1 // Scintilla source code edit control
3 ** Defines the appearance of the main text area of the editor window.
5 // Copyright 1998-2014 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
13 struct PrintParameters
{
17 PrintParameters() noexcept
;
21 * The view may be drawn in separate phases.
25 drawIndicatorsBack
= 0x2,
27 drawIndentationGuides
= 0x8,
28 drawIndicatorsFore
= 0x10,
29 drawSelectionTranslucent
= 0x20,
30 drawLineTranslucent
= 0x40,
36 bool ValidStyledText(const ViewStyle
&vs
, size_t styleOffset
, const StyledText
&st
) noexcept
;
37 int WidestLineWidth(Surface
*surface
, const ViewStyle
&vs
, int styleOffset
, const StyledText
&st
);
38 void DrawTextNoClipPhase(Surface
*surface
, PRectangle rc
, const Style
&style
, XYPOSITION ybase
,
39 std::string_view text
, DrawPhase phase
);
40 void DrawStyledText(Surface
*surface
, const ViewStyle
&vs
, int styleOffset
, PRectangle rcText
,
41 const StyledText
&st
, size_t start
, size_t length
, DrawPhase phase
);
43 typedef void (*DrawTabArrowFn
)(Surface
*surface
, PRectangle rcTab
, int ymid
);
48 * EditView draws the main text area.
52 PrintParameters printParameters
;
53 std::unique_ptr
<LineTabstops
> ldTabstops
;
54 int tabWidthMinimumPixels
;
57 bool drawOverstrikeCaret
; // used by the curses platform
59 /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
60 * the screen. This avoids flashing but is about 30% slower. */
62 /** In phasesTwo mode, drawing is performed in two phases, first the background
63 * and then the foreground. This avoids chopping off characters that overlap the next run.
64 * In multiPhaseDraw mode, drawing is performed in multiple phases with each phase drawing
65 * one feature over the whole drawing area, instead of within one line. This allows text to
66 * overlap from one line to the next. */
67 enum PhasesDraw
{ phasesOne
, phasesTwo
, phasesMultiple
};
68 PhasesDraw phasesDraw
;
72 bool additionalCaretsBlink
;
73 bool additionalCaretsVisible
;
75 bool imeCaretBlockOverride
;
77 std::unique_ptr
<Surface
> pixmapLine
;
78 std::unique_ptr
<Surface
> pixmapIndentGuide
;
79 std::unique_ptr
<Surface
> pixmapIndentGuideHighlight
;
83 PositionCache posCache
;
85 int tabArrowHeight
; // draw arrow heads this many pixels above/below line midpoint
86 /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native
87 * DrawTabArrow function for drawing tab characters. Allow those platforms to
88 * override it instead of creating a new method in the Surface class that
89 * existing platforms must implement as empty. */
90 DrawTabArrowFn customDrawTabArrow
;
91 DrawWrapMarkerFn customDrawWrapMarker
;
94 // Deleted so EditView objects can not be copied.
95 EditView(const EditView
&) = delete;
96 EditView(EditView
&&) = delete;
97 void operator=(const EditView
&) = delete;
98 void operator=(EditView
&&) = delete;
101 bool SetTwoPhaseDraw(bool twoPhaseDraw
) noexcept
;
102 bool SetPhasesDraw(int phases
) noexcept
;
103 bool LinesOverlap() const noexcept
;
105 void ClearAllTabstops() noexcept
;
106 XYPOSITION
NextTabstopPos(Sci::Line line
, XYPOSITION x
, XYPOSITION tabWidth
) const noexcept
;
107 bool ClearTabstops(Sci::Line line
) noexcept
;
108 bool AddTabstop(Sci::Line line
, int x
);
109 int GetNextTabstop(Sci::Line line
, int x
) const noexcept
;
110 void LinesAddedOrRemoved(Sci::Line lineOfPos
, Sci::Line linesAdded
);
112 void DropGraphics(bool freeObjects
);
113 void AllocateGraphics(const ViewStyle
&vsDraw
);
114 void RefreshPixMaps(Surface
*surfaceWindow
, WindowID wid
, const ViewStyle
&vsDraw
);
116 LineLayout
*RetrieveLineLayout(Sci::Line lineNumber
, const EditModel
&model
);
117 void LayoutLine(const EditModel
&model
, Sci::Line line
, Surface
*surface
, const ViewStyle
&vstyle
,
118 LineLayout
*ll
, int width
= LineLayout::wrapWidthInfinite
);
120 static void UpdateBidiData(const EditModel
&model
, const ViewStyle
&vstyle
, LineLayout
*ll
);
122 Point
LocationFromPosition(Surface
*surface
, const EditModel
&model
, SelectionPosition pos
, Sci::Line topLine
,
123 const ViewStyle
&vs
, PointEnd pe
, const PRectangle rcClient
);
124 Range
RangeDisplayLine(Surface
*surface
, const EditModel
&model
, Sci::Line lineVisible
, const ViewStyle
&vs
);
125 SelectionPosition
SPositionFromLocation(Surface
*surface
, const EditModel
&model
, PointDocument pt
, bool canReturnInvalid
,
126 bool charPosition
, bool virtualSpace
, const ViewStyle
&vs
, const PRectangle rcClient
);
127 SelectionPosition
SPositionFromLineX(Surface
*surface
, const EditModel
&model
, Sci::Line lineDoc
, int x
, const ViewStyle
&vs
);
128 Sci::Line
DisplayFromPosition(Surface
*surface
, const EditModel
&model
, Sci::Position pos
, const ViewStyle
&vs
);
129 Sci::Position
StartEndDisplayLine(Surface
*surface
, const EditModel
&model
, Sci::Position pos
, bool start
, const ViewStyle
&vs
);
131 void DrawIndentGuide(Surface
*surface
, Sci::Line lineVisible
, int lineHeight
, XYPOSITION start
, PRectangle rcSegment
, bool highlight
);
132 void DrawEOL(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, PRectangle rcLine
,
133 Sci::Line line
, Sci::Position lineEnd
, int xStart
, int subLine
, XYACCUMULATOR subLineStart
,
134 ColourOptional background
);
135 void DrawFoldDisplayText(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
136 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, XYACCUMULATOR subLineStart
, DrawPhase phase
);
137 void DrawEOLAnnotationText(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
138 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, XYACCUMULATOR subLineStart
, DrawPhase phase
);
139 void DrawAnnotation(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
140 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, DrawPhase phase
);
141 void DrawCarets(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, Sci::Line lineDoc
,
142 int xStart
, PRectangle rcLine
, int subLine
) const;
143 void DrawBackground(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, PRectangle rcLine
,
144 Range lineRange
, Sci::Position posLineStart
, int xStart
,
145 int subLine
, ColourOptional background
) const;
146 void DrawForeground(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, Sci::Line lineVisible
,
147 PRectangle rcLine
, Range lineRange
, Sci::Position posLineStart
, int xStart
,
148 int subLine
, ColourOptional background
);
149 void DrawIndentGuidesOverEmpty(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
150 Sci::Line line
, Sci::Line lineVisible
, PRectangle rcLine
, int xStart
, int subLine
);
151 void DrawLine(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, Sci::Line line
,
152 Sci::Line lineVisible
, int xStart
, PRectangle rcLine
, int subLine
, DrawPhase phase
);
153 void PaintText(Surface
*surfaceWindow
, const EditModel
&model
, PRectangle rcArea
, PRectangle rcClient
,
154 const ViewStyle
&vsDraw
);
155 void FillLineRemainder(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
156 Sci::Line line
, PRectangle rcArea
, int subLine
) const;
157 Sci::Position
FormatRange(bool draw
, const Sci_RangeToFormat
*pfr
, Surface
*surface
, Surface
*surfaceMeasure
,
158 const EditModel
&model
, const ViewStyle
&vs
);
162 * Convenience class to ensure LineLayout objects are always disposed.
164 class AutoLineLayout
{
165 LineLayoutCache
&llc
;
168 AutoLineLayout(LineLayoutCache
&llc_
, LineLayout
*ll_
) noexcept
: llc(llc_
), ll(ll_
) {}
169 AutoLineLayout(const AutoLineLayout
&) = delete;
170 AutoLineLayout(AutoLineLayout
&&) = delete;
171 AutoLineLayout
&operator=(const AutoLineLayout
&) = delete;
172 AutoLineLayout
&operator=(AutoLineLayout
&&) = delete;
173 ~AutoLineLayout() noexcept
{
177 LineLayout
*operator->() const noexcept
{
180 operator LineLayout
*() const noexcept
{
183 void Set(LineLayout
*ll_
) noexcept
{