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.
11 namespace Scintilla::Internal
{
13 struct PrintParameters
{
15 Scintilla::PrintOption colourMode
;
16 Scintilla::Wrap wrapState
;
17 PrintParameters() noexcept
;
21 * The view may be drawn in separate phases.
23 enum class DrawPhase
{
28 indentationGuides
= 0x8,
29 indicatorsFore
= 0x10,
30 selectionTranslucent
= 0x20,
31 lineTranslucent
= 0x40,
37 bool ValidStyledText(const ViewStyle
&vs
, size_t styleOffset
, const StyledText
&st
) noexcept
;
38 int WidestLineWidth(Surface
*surface
, const ViewStyle
&vs
, int styleOffset
, const StyledText
&st
);
39 void DrawTextNoClipPhase(Surface
*surface
, PRectangle rc
, const Style
&style
, XYPOSITION ybase
,
40 std::string_view text
, DrawPhase phase
);
41 void DrawStyledText(Surface
*surface
, const ViewStyle
&vs
, int styleOffset
, PRectangle rcText
,
42 const StyledText
&st
, size_t start
, size_t length
, DrawPhase phase
);
44 typedef void (*DrawTabArrowFn
)(Surface
*surface
, PRectangle rcTab
, int ymid
,
45 const ViewStyle
&vsDraw
, Stroke stroke
);
50 * EditView draws the main text area.
54 PrintParameters printParameters
;
55 std::unique_ptr
<LineTabstops
> ldTabstops
;
56 int tabWidthMinimumPixels
;
58 bool drawOverstrikeCaret
; // used by the curses platform
60 /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
61 * the screen. This avoids flashing but is about 30% slower. */
63 /** In phasesTwo mode, drawing is performed in two phases, first the background
64 * and then the foreground. This avoids chopping off characters that overlap the next run.
65 * In multiPhaseDraw mode, drawing is performed in multiple phases with each phase drawing
66 * one feature over the whole drawing area, instead of within one line. This allows text to
67 * overlap from one line to the next. */
68 Scintilla::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 std::unique_ptr
<IPositionCache
> posCache
;
85 unsigned int maxLayoutThreads
;
86 static constexpr int bytesPerLayoutThread
= 1000;
88 int tabArrowHeight
; // draw arrow heads this many pixels above/below line midpoint
89 /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native
90 * DrawTabArrow function for drawing tab characters. Allow those platforms to
91 * override it instead of creating a new method in the Surface class that
92 * existing platforms must implement as empty. */
93 DrawTabArrowFn customDrawTabArrow
;
94 DrawWrapMarkerFn customDrawWrapMarker
;
97 // Deleted so EditView objects can not be copied.
98 EditView(const EditView
&) = delete;
99 EditView(EditView
&&) = delete;
100 void operator=(const EditView
&) = delete;
101 void operator=(EditView
&&) = delete;
104 bool SetTwoPhaseDraw(bool twoPhaseDraw
) noexcept
;
105 bool SetPhasesDraw(int phases
) noexcept
;
106 bool LinesOverlap() const noexcept
;
108 void SetLayoutThreads(unsigned int threads
) noexcept
;
109 unsigned int GetLayoutThreads() const noexcept
;
111 void ClearAllTabstops() noexcept
;
112 XYPOSITION
NextTabstopPos(Sci::Line line
, XYPOSITION x
, XYPOSITION tabWidth
) const noexcept
;
113 bool ClearTabstops(Sci::Line line
) noexcept
;
114 bool AddTabstop(Sci::Line line
, int x
);
115 int GetNextTabstop(Sci::Line line
, int x
) const noexcept
;
116 void LinesAddedOrRemoved(Sci::Line lineOfPos
, Sci::Line linesAdded
);
118 void DropGraphics() noexcept
;
119 void RefreshPixMaps(Surface
*surfaceWindow
, const ViewStyle
&vsDraw
);
121 std::shared_ptr
<LineLayout
> RetrieveLineLayout(Sci::Line lineNumber
, const EditModel
&model
);
122 void LayoutLine(const EditModel
&model
, Surface
*surface
, const ViewStyle
&vstyle
,
123 LineLayout
*ll
, int width
, bool callerMultiThreaded
=false);
125 static void UpdateBidiData(const EditModel
&model
, const ViewStyle
&vstyle
, LineLayout
*ll
);
127 Point
LocationFromPosition(Surface
*surface
, const EditModel
&model
, SelectionPosition pos
, Sci::Line topLine
,
128 const ViewStyle
&vs
, PointEnd pe
, const PRectangle rcClient
);
129 Range
RangeDisplayLine(Surface
*surface
, const EditModel
&model
, Sci::Line lineVisible
, const ViewStyle
&vs
);
130 SelectionPosition
SPositionFromLocation(Surface
*surface
, const EditModel
&model
, PointDocument pt
, bool canReturnInvalid
,
131 bool charPosition
, bool virtualSpace
, const ViewStyle
&vs
, const PRectangle rcClient
);
132 SelectionPosition
SPositionFromLineX(Surface
*surface
, const EditModel
&model
, Sci::Line lineDoc
, int x
, const ViewStyle
&vs
);
133 Sci::Line
DisplayFromPosition(Surface
*surface
, const EditModel
&model
, Sci::Position pos
, const ViewStyle
&vs
);
134 Sci::Position
StartEndDisplayLine(Surface
*surface
, const EditModel
&model
, Sci::Position pos
, bool start
, const ViewStyle
&vs
);
137 void DrawEOL(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
138 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, Sci::Position lineEnd
, XYPOSITION subLineStart
, ColourOptional background
);
139 void DrawFoldDisplayText(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
140 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, XYPOSITION subLineStart
, DrawPhase phase
);
141 void DrawEOLAnnotationText(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
142 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, XYPOSITION subLineStart
, DrawPhase phase
);
143 void DrawAnnotation(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
144 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, DrawPhase phase
);
145 void DrawCarets(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
146 Sci::Line lineDoc
, int xStart
, PRectangle rcLine
, int subLine
) const;
147 void DrawIndentGuide(Surface
*surface
, XYPOSITION start
, PRectangle rcSegment
, bool highlight
, bool offset
);
148 void DrawForeground(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
149 int xStart
, PRectangle rcLine
, int subLine
, Sci::Line lineVisible
, Range lineRange
, Sci::Position posLineStart
,
150 ColourOptional background
);
151 void DrawIndentGuidesOverEmpty(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
152 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, Sci::Line lineVisible
);
153 void DrawLine(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
154 Sci::Line line
, Sci::Line lineVisible
, int xStart
, PRectangle rcLine
, int subLine
, DrawPhase phase
);
157 void PaintText(Surface
*surfaceWindow
, const EditModel
&model
, const ViewStyle
&vsDraw
,
158 PRectangle rcArea
, PRectangle rcClient
);
159 Sci::Position
FormatRange(bool draw
, CharacterRangeFull chrg
, Rectangle rc
, Surface
*surface
, Surface
*surfaceMeasure
,
160 const EditModel
&model
, const ViewStyle
&vs
);