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.
15 struct PrintParameters
{
23 * The view may be drawn in separate phases.
27 drawIndicatorsBack
= 0x2,
29 drawIndentationGuides
= 0x8,
30 drawIndicatorsFore
= 0x10,
31 drawSelectionTranslucent
= 0x20,
32 drawLineTranslucent
= 0x40,
38 bool ValidStyledText(const ViewStyle
&vs
, size_t styleOffset
, const StyledText
&st
);
39 int WidestLineWidth(Surface
*surface
, const ViewStyle
&vs
, int styleOffset
, const StyledText
&st
);
40 void DrawTextNoClipPhase(Surface
*surface
, PRectangle rc
, const Style
&style
, XYPOSITION ybase
,
41 const char *s
, int len
, DrawPhase phase
);
42 void DrawStyledText(Surface
*surface
, const ViewStyle
&vs
, int styleOffset
, PRectangle rcText
,
43 const StyledText
&st
, size_t start
, size_t length
, DrawPhase phase
);
45 typedef void (*DrawTabArrowFn
)(Surface
*surface
, PRectangle rcTab
, int ymid
);
48 * EditView draws the main text area.
52 PrintParameters printParameters
;
56 bool drawOverstrikeCaret
;
58 /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to
59 * the screen. This avoids flashing but is about 30% slower. */
61 /** In phasesTwo mode, drawing is performed in two phases, first the background
62 * and then the foreground. This avoids chopping off characters that overlap the next run.
63 * In multiPhaseDraw mode, drawing is performed in multiple phases with each phase drawing
64 * one feature over the whole drawing area, instead of within one line. This allows text to
65 * overlap from one line to the next. */
66 enum PhasesDraw
{ phasesOne
, phasesTwo
, phasesMultiple
};
67 PhasesDraw phasesDraw
;
71 bool additionalCaretsBlink
;
72 bool additionalCaretsVisible
;
74 bool imeCaretBlockOverride
;
77 Surface
*pixmapIndentGuide
;
78 Surface
*pixmapIndentGuideHighlight
;
81 PositionCache posCache
;
83 int tabArrowHeight
; // draw arrow heads this many pixels above/below line midpoint
84 /** Some platforms, notably PLAT_CURSES, do not support Scintilla's native
85 * DrawTabArrow function for drawing tab characters. Allow those platforms to
86 * override it instead of creating a new method in the Surface class that
87 * existing platforms must implement as empty. */
88 DrawTabArrowFn customDrawTabArrow
;
89 DrawWrapMarkerFn customDrawWrapMarker
;
94 bool SetTwoPhaseDraw(bool twoPhaseDraw
);
95 bool SetPhasesDraw(int phases
);
96 bool LinesOverlap() const;
98 void ClearAllTabstops();
99 XYPOSITION
NextTabstopPos(int line
, XYPOSITION x
, XYPOSITION tabWidth
) const;
100 bool ClearTabstops(int line
);
101 bool AddTabstop(int line
, int x
);
102 int GetNextTabstop(int line
, int x
) const;
103 void LinesAddedOrRemoved(int lineOfPos
, int linesAdded
);
105 void DropGraphics(bool freeObjects
);
106 void AllocateGraphics(const ViewStyle
&vsDraw
);
107 void RefreshPixMaps(Surface
*surfaceWindow
, WindowID wid
, const ViewStyle
&vsDraw
);
109 LineLayout
*RetrieveLineLayout(int lineNumber
, const EditModel
&model
);
110 void LayoutLine(const EditModel
&model
, int line
, Surface
*surface
, const ViewStyle
&vstyle
,
111 LineLayout
*ll
, int width
= LineLayout::wrapWidthInfinite
);
113 Point
LocationFromPosition(Surface
*surface
, const EditModel
&model
, SelectionPosition pos
, int topLine
, const ViewStyle
&vs
);
114 SelectionPosition
SPositionFromLocation(Surface
*surface
, const EditModel
&model
, Point pt
, bool canReturnInvalid
,
115 bool charPosition
, bool virtualSpace
, const ViewStyle
&vs
);
116 SelectionPosition
SPositionFromLineX(Surface
*surface
, const EditModel
&model
, int lineDoc
, int x
, const ViewStyle
&vs
);
117 int DisplayFromPosition(Surface
*surface
, const EditModel
&model
, int pos
, const ViewStyle
&vs
);
118 int StartEndDisplayLine(Surface
*surface
, const EditModel
&model
, int pos
, bool start
, const ViewStyle
&vs
);
120 void DrawIndentGuide(Surface
*surface
, int lineVisible
, int lineHeight
, int start
, PRectangle rcSegment
, bool highlight
);
121 void DrawEOL(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, PRectangle rcLine
,
122 int line
, int lineEnd
, int xStart
, int subLine
, XYACCUMULATOR subLineStart
,
123 ColourOptional background
);
124 void DrawAnnotation(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
125 int line
, int xStart
, PRectangle rcLine
, int subLine
, DrawPhase phase
);
126 void DrawCarets(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, int line
,
127 int xStart
, PRectangle rcLine
, int subLine
) const;
128 void DrawBackground(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, PRectangle rcLine
,
129 Range lineRange
, int posLineStart
, int xStart
,
130 int subLine
, ColourOptional background
) const;
131 void DrawForeground(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, int lineVisible
,
132 PRectangle rcLine
, Range lineRange
, int posLineStart
, int xStart
,
133 int subLine
, ColourOptional background
);
134 void DrawIndentGuidesOverEmpty(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
,
135 int line
, int lineVisible
, PRectangle rcLine
, int xStart
, int subLine
);
136 void DrawLine(Surface
*surface
, const EditModel
&model
, const ViewStyle
&vsDraw
, const LineLayout
*ll
, int line
,
137 int lineVisible
, int xStart
, PRectangle rcLine
, int subLine
, DrawPhase phase
);
138 void PaintText(Surface
*surfaceWindow
, const EditModel
&model
, PRectangle rcArea
, PRectangle rcClient
,
139 const ViewStyle
&vsDraw
);
140 long FormatRange(bool draw
, Sci_RangeToFormat
*pfr
, Surface
*surface
, Surface
*surfaceMeasure
,
141 const EditModel
&model
, const ViewStyle
&vs
);
145 * Convenience class to ensure LineLayout objects are always disposed.
147 class AutoLineLayout
{
148 LineLayoutCache
&llc
;
150 AutoLineLayout
&operator=(const AutoLineLayout
&);
152 AutoLineLayout(LineLayoutCache
&llc_
, LineLayout
*ll_
) : llc(llc_
), ll(ll_
) {}
157 LineLayout
*operator->() const {
160 operator LineLayout
*() const {
163 void Set(LineLayout
*ll_
) {