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
;
82 std::unique_ptr
<IPositionCache
> posCache
;
84 unsigned int maxLayoutThreads
;
85 static constexpr int bytesPerLayoutThread
= 1000;
87 int tabArrowHeight
; // draw arrow heads this many pixels above/below line midpoint
88 /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native
89 * DrawTabArrow function for drawing tab characters. Allow those platforms to
90 * override it instead of creating a new method in the Surface class that
91 * existing platforms must implement as empty. */
92 DrawTabArrowFn customDrawTabArrow
;
93 DrawWrapMarkerFn customDrawWrapMarker
;
96 // Deleted so EditView objects can not be copied.
97 EditView(const EditView
&) = delete;
98 EditView(EditView
&&) = delete;
99 void operator=(const EditView
&) = delete;
100 void operator=(EditView
&&) = delete;
103 bool SetTwoPhaseDraw(bool twoPhaseDraw
) noexcept
;
104 bool SetPhasesDraw(int phases
) noexcept
;
105 bool LinesOverlap() const noexcept
;
107 void SetLayoutThreads(unsigned int threads
) noexcept
;
108 unsigned int GetLayoutThreads() const noexcept
;
110 void ClearAllTabstops() noexcept
;
111 XYPOSITION
NextTabstopPos(Sci::Line line
, XYPOSITION x
, XYPOSITION tabWidth
) const noexcept
;
112 bool ClearTabstops(Sci::Line line
) noexcept
;
113 bool AddTabstop(Sci::Line line
, int x
);
114 int GetNextTabstop(Sci::Line line
, int x
) const noexcept
;
115 void LinesAddedOrRemoved(Sci::Line lineOfPos
, Sci::Line linesAdded
);
117 void DropGraphics() noexcept
;
118 void RefreshPixMaps(Surface
*surfaceWindow
, const ViewStyle
&vsDraw
);
120 std::shared_ptr
<LineLayout
> RetrieveLineLayout(Sci::Line lineNumber
, const EditModel
&model
);
121 void LayoutLine(const EditModel
&model
, Surface
*surface
, const ViewStyle
&vstyle
,
122 LineLayout
*ll
, int width
, bool callerMultiThreaded
=false);
124 static void UpdateBidiData(const EditModel
&model
, const ViewStyle
&vstyle
, LineLayout
*ll
);
126 Point
LocationFromPosition(Surface
*surface
, const EditModel
&model
, SelectionPosition pos
, Sci::Line topLine
,
127 const ViewStyle
&vs
, PointEnd pe
, const PRectangle rcClient
);
128 Range
RangeDisplayLine(Surface
*surface
, const EditModel
&model
, Sci::Line lineVisible
, const ViewStyle
&vs
);
129 SelectionPosition
SPositionFromLocation(Surface
*surface
, const EditModel
&model
, PointDocument pt
, bool canReturnInvalid
,
130 bool charPosition
, bool virtualSpace
, const ViewStyle
&vs
, const PRectangle rcClient
);
131 SelectionPosition
SPositionFromLineX(Surface
*surface
, const EditModel
&model
, Sci::Line lineDoc
, int x
, const ViewStyle
&vs
);
132 Sci::Line
DisplayFromPosition(Surface
*surface
, const EditModel
&model
, Sci::Position pos
, const ViewStyle
&vs
);
133 Sci::Position
StartEndDisplayLine(Surface
*surface
, const EditModel
&model
, Sci::Position pos
, bool start
, const ViewStyle
&vs
);
136 void DrawEOL(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
137 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, Sci::Position lineEnd
, XYPOSITION subLineStart
, ColourOptional background
);
138 void DrawFoldDisplayText(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
139 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, XYPOSITION subLineStart
, DrawPhase phase
);
140 void DrawEOLAnnotationText(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
141 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, XYPOSITION subLineStart
, DrawPhase phase
);
142 void DrawAnnotation(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
143 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, DrawPhase phase
);
144 void DrawCarets(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
145 Sci::Line lineDoc
, int xStart
, PRectangle rcLine
, int subLine
) const;
146 void DrawIndentGuide(Surface
*surface
, XYPOSITION start
, PRectangle rcSegment
, bool highlight
, bool offset
);
147 void DrawForeground(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
148 int xStart
, PRectangle rcLine
, int subLine
, Sci::Line lineVisible
, Range lineRange
, Sci::Position posLineStart
,
149 ColourOptional background
);
150 void DrawIndentGuidesOverEmpty(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
151 Sci::Line line
, int xStart
, PRectangle rcLine
, int subLine
, Sci::Line lineVisible
);
152 void DrawLine(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
153 Sci::Line line
, Sci::Line lineVisible
, int xStart
, PRectangle rcLine
, int subLine
, DrawPhase phase
);
156 void PaintText(Surface
*surfaceWindow
, const EditModel
&model
, const ViewStyle
&vsDraw
,
157 PRectangle rcArea
, PRectangle rcClient
);
158 Sci::Position
FormatRange(bool draw
, CharacterRangeFull chrg
, Rectangle rc
, Surface
*surface
, Surface
*surfaceMeasure
,
159 const EditModel
&model
, const ViewStyle
&vs
);