1 // This module defines the "official" high-level API of the Qt port of
2 // Scintilla.
3 //
4 // Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
5 //
6 // This file is part of QScintilla.
7 //
8 // This file may be used under the terms of the GNU General Public License
9 // version 3.0 as published by the Free Software Foundation and appearing in
10 // the file LICENSE included in the packaging of this file.  Please review the
11 // following information to ensure the GNU General Public License version 3.0
12 // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
13 //
14 // If you do not wish to use this file under the terms of the GPL version 3.0
15 // then you may purchase a commercial license.  For more information contact
16 // info@riverbankcomputing.com.
17 //
18 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 
21 
22 #ifndef QSCISCINTILLA_H
23 #define QSCISCINTILLA_H
24 
25 #include <QByteArray>
26 #include <QList>
27 #include <QObject>
28 #include <QPointer>
29 #include <QStringList>
30 
31 #include <Qsci/qsciglobal.h>
32 #include <Qsci/qscicommand.h>
33 #include <Qsci/qscidocument.h>
34 #include <Qsci/qsciscintillabase.h>
35 
36 
37 QT_BEGIN_NAMESPACE
38 class QAction;
39 class QImage;
40 class QIODevice;
41 class QMenu;
42 class QPoint;
43 QT_END_NAMESPACE
44 
45 class QsciCommandSet;
46 class QsciLexer;
47 class QsciStyle;
48 class QsciStyledText;
49 class QsciListBoxQt;
50 
51 
52 //! \brief The QsciScintilla class implements a higher level, more Qt-like,
53 //! API to the Scintilla editor widget.
54 //!
55 //! QsciScintilla implements methods, signals and slots similar to those found
56 //! in other Qt editor classes. It also provides a higher level interface to
57 //! features specific to Scintilla such as syntax styling, call tips,
58 //! auto-indenting and auto-completion than that provided by QsciScintillaBase.
59 class QSCINTILLA_EXPORT QsciScintilla : public QsciScintillaBase
60 {
61     Q_OBJECT
62 
63 public:
64     //! This enum defines the different auto-indentation styles.
65     enum {
66         //! A line is automatically indented to match the previous line.
67         AiMaintain = 0x01,
68 
69         //! If the language supported by the current lexer has a specific start
70         //! of block character (e.g. { in C++), then a line that begins with
71         //! that character is indented as well as the lines that make up the
72         //! block.  It may be logically ored with AiClosing.
73         AiOpening = 0x02,
74 
75         //! If the language supported by the current lexer has a specific end
76         //! of block character (e.g. } in C++), then a line that begins with
77         //! that character is indented as well as the lines that make up the
78         //! block.  It may be logically ored with AiOpening.
79         AiClosing = 0x04
80     };
81 
82     //! This enum defines the different annotation display styles.
83     enum AnnotationDisplay {
84         //! Annotations are not displayed.
85         AnnotationHidden = ANNOTATION_HIDDEN,
86 
87         //! Annotations are drawn left justified with no adornment.
88         AnnotationStandard = ANNOTATION_STANDARD,
89 
90         //! Annotations are surrounded by a box.
91         AnnotationBoxed = ANNOTATION_BOXED,
92 
93         //! Annotations are indented to match the text.
94         AnnotationIndented = ANNOTATION_INDENTED,
95     };
96 
97     //! This enum defines the behavior if an auto-completion list contains a
98     //! single entry.
99     enum AutoCompletionUseSingle {
100         //! The single entry is not used automatically and the auto-completion
101         //! list is displayed.
102         AcusNever,
103 
104         //! The single entry is used automatically when auto-completion is
105         //! explicitly requested (using autoCompleteFromAPIs() or
106         //! autoCompleteFromDocument()) but not when auto-completion is
107         //! triggered as the user types.
108         AcusExplicit,
109 
110         //! The single entry is used automatically and the auto-completion list
111         //! is not displayed.
112         AcusAlways
113     };
114 
115     //! This enum defines the different sources for auto-completion lists.
116     enum AutoCompletionSource {
117         //! No sources are used, ie. automatic auto-completion is disabled.
118         AcsNone,
119 
120         //! The source is all available sources.
121         AcsAll,
122 
123         //! The source is the current document.
124         AcsDocument,
125 
126         //! The source is any installed APIs.
127         AcsAPIs
128     };
129 
130     //! This enum defines the different brace matching modes.  The character
131     //! pairs {}, [] and () are treated as braces.  The Python lexer will also
132     //! match a : with the end of the corresponding indented block.
133     enum BraceMatch {
134         //! Brace matching is disabled.
135         NoBraceMatch,
136 
137         //! Brace matching is enabled for a brace immediately before the
138         //! current position.
139         StrictBraceMatch,
140 
141         //! Brace matching is enabled for a brace immediately before or after
142         //! the current position.
143         SloppyBraceMatch
144     };
145 
146     //! This enum defines the different call tip positions.
147     enum CallTipsPosition {
148         //! Call tips are placed below the text.
149         CallTipsBelowText,
150 
151         //! Call tips are placed above the text.
152         CallTipsAboveText,
153     };
154 
155     //! This enum defines the different call tip styles.
156     enum CallTipsStyle {
157         //! Call tips are disabled.
158         CallTipsNone,
159 
160         //! Call tips are displayed without a context.  A context is any scope
161         //! (e.g. a C++ namespace or a Python module) prior to the function
162         //! name.
163         CallTipsNoContext,
164 
165         //! Call tips are displayed with a context only if the user hasn't
166         //! already implicitly identified the context using autocompletion.
167         //! Note that this style may not always be able to align the call tip
168         //! with the text being entered.
169         CallTipsNoAutoCompletionContext,
170 
171         //! Call tips are displayed with a context.  Note that this style
172         //! may not always be able to align the call tip with the text being
173         //! entered.
174         CallTipsContext
175     };
176 
177     //! This enum defines the different edge modes for long lines.
178     enum EdgeMode {
179         //! Long lines are not marked.
180         EdgeNone = EDGE_NONE,
181 
182         //! A vertical line is drawn at the column set by setEdgeColumn().
183         //! This is recommended for monospace fonts.
184         EdgeLine = EDGE_LINE,
185 
186         //! The background color of characters after the column limit is
187         //! changed to the color set by setEdgeColor().  This is recommended
188         //! for proportional fonts.
189         EdgeBackground = EDGE_BACKGROUND,
190 
191         //! Multiple vertical lines are drawn at the columns defined by
192         //! multiple calls to addEdgeColumn().
193         EdgeMultipleLines = EDGE_MULTILINE,
194     };
195 
196     //! This enum defines the different end-of-line modes.
197     enum EolMode {
198         //! A carriage return/line feed as used on Windows systems.
199         EolWindows = SC_EOL_CRLF,
200 
201         //! A line feed as used on Unix systems, including OS/X.
202         EolUnix = SC_EOL_LF,
203 
204         //! A carriage return as used on Mac systems prior to OS/X.
205         EolMac = SC_EOL_CR
206     };
207 
208     //! This enum defines the different styles for the folding margin.
209     enum FoldStyle {
210         //! Folding is disabled.
211         NoFoldStyle,
212 
213         //! Plain folding style using plus and minus symbols.
214         PlainFoldStyle,
215 
216         //! Circled folding style using circled plus and minus symbols.
217         CircledFoldStyle,
218 
219         //! Boxed folding style using boxed plus and minus symbols.
220         BoxedFoldStyle,
221 
222         //! Circled tree style using a flattened tree with circled plus and
223         //! minus symbols and rounded corners.
224         CircledTreeFoldStyle,
225 
226         //! Boxed tree style using a flattened tree with boxed plus and minus
227         //! symbols and right-angled corners.
228         BoxedTreeFoldStyle
229     };
230 
231     //! This enum defines the different indicator styles.
232     enum IndicatorStyle {
233         //! A single straight underline.
234         PlainIndicator = INDIC_PLAIN,
235 
236         //! A squiggly underline that requires 3 pixels of descender space.
237         SquiggleIndicator = INDIC_SQUIGGLE,
238 
239         //! A line of small T shapes.
240         TTIndicator = INDIC_TT,
241 
242         //! Diagonal hatching.
243         DiagonalIndicator = INDIC_DIAGONAL,
244 
245         //! Strike out.
246         StrikeIndicator = INDIC_STRIKE,
247 
248         //! An indicator with no visual appearence.
249         HiddenIndicator = INDIC_HIDDEN,
250 
251         //! A rectangle around the text.
252         BoxIndicator = INDIC_BOX,
253 
254         //! A rectangle with rounded corners around the text with the interior
255         //! usually more transparent than the border.
256         RoundBoxIndicator = INDIC_ROUNDBOX,
257 
258         //! A rectangle around the text with the interior usually more
259         //! transparent than the border.  It does not colour the top pixel of
260         //! the line so that indicators on contiguous lines are visually
261         //! distinct and disconnected.
262         StraightBoxIndicator = INDIC_STRAIGHTBOX,
263 
264         //! A rectangle around the text with the interior usually more
265         //! transparent than the border.  Unlike StraightBoxIndicator it covers
266         //! the entire character area.
267         FullBoxIndicator = INDIC_FULLBOX,
268 
269         //! A dashed underline.
270         DashesIndicator = INDIC_DASH,
271 
272         //! A dotted underline.
273         DotsIndicator = INDIC_DOTS,
274 
275         //! A squiggly underline that requires 2 pixels of descender space and
276         //! so will fit under smaller fonts.
277         SquiggleLowIndicator = INDIC_SQUIGGLELOW,
278 
279         //! A dotted rectangle around the text with the interior usually more
280         //! transparent than the border.
281         DotBoxIndicator = INDIC_DOTBOX,
282 
283         //! A version of SquiggleIndicator that uses a pixmap.  This is quicker
284         //! but may be of lower quality.
285         SquigglePixmapIndicator = INDIC_SQUIGGLEPIXMAP,
286 
287         //! A thick underline typically used for the target during Asian
288         //! language input composition.
289         ThickCompositionIndicator = INDIC_COMPOSITIONTHICK,
290 
291         //! A thin underline typically used for non-target ranges during Asian
292         //! language input composition.
293         ThinCompositionIndicator = INDIC_COMPOSITIONTHIN,
294 
295         //! The color of the text is set to the color of the indicator's
296         //! foreground.
297         TextColorIndicator = INDIC_TEXTFORE,
298 
299         //! A triangle below the start of the indicator range.
300         TriangleIndicator = INDIC_POINT,
301 
302         //! A triangle below the centre of the first character in the indicator
303         //! range.
304         TriangleCharacterIndicator = INDIC_POINTCHARACTER,
305 
306         //! A vertical gradient between the indicator's foreground colour at
307         //! top to fully transparent at the bottom.
308         GradientIndicator = INDIC_GRADIENT,
309 
310         //! A vertical gradient with the indicator's foreground colour in the
311         //! middle and fading to fully transparent at the top and bottom.
312         CentreGradientIndicator = INDIC_GRADIENTCENTRE,
313     };
314 
315     //! This enum defines the different margin options.
316     enum {
317         //! Reset all margin options.
318         MoNone = SC_MARGINOPTION_NONE,
319 
320         //! If this is set then only the first sub-line of a wrapped line will
321         //! be selected when clicking on a margin.
322         MoSublineSelect = SC_MARGINOPTION_SUBLINESELECT
323     };
324 
325     //! This enum defines the different margin types.
326     enum MarginType {
327         //! The margin contains symbols, including those used for folding.
328         SymbolMargin = SC_MARGIN_SYMBOL,
329 
330         //! The margin contains symbols and uses the default foreground color
331         //! as its background color.
332         SymbolMarginDefaultForegroundColor = SC_MARGIN_FORE,
333 
334         //! The margin contains symbols and uses the default background color
335         //! as its background color.
336         SymbolMarginDefaultBackgroundColor = SC_MARGIN_BACK,
337 
338         //! The margin contains line numbers.
339         NumberMargin = SC_MARGIN_NUMBER,
340 
341         //! The margin contains styled text.
342         TextMargin = SC_MARGIN_TEXT,
343 
344         //! The margin contains right justified styled text.
345         TextMarginRightJustified = SC_MARGIN_RTEXT,
346 
347         //! The margin contains symbols and uses the color set by
348         //! setMarginBackgroundColor() as its background color.
349         SymbolMarginColor = SC_MARGIN_COLOUR,
350     };
351 
352     //! This enum defines the different pre-defined marker symbols.
353     enum MarkerSymbol {
354         //! A circle.
355         Circle = SC_MARK_CIRCLE,
356 
357         //! A rectangle.
358         Rectangle = SC_MARK_ROUNDRECT,
359 
360         //! A triangle pointing to the right.
361         RightTriangle = SC_MARK_ARROW,
362 
363         //! A smaller rectangle.
364         SmallRectangle = SC_MARK_SMALLRECT,
365 
366         //! An arrow pointing to the right.
367         RightArrow = SC_MARK_SHORTARROW,
368 
369         //! An invisible marker that allows code to track the movement
370         //! of lines.
371         Invisible = SC_MARK_EMPTY,
372 
373         //! A triangle pointing down.
374         DownTriangle = SC_MARK_ARROWDOWN,
375 
376         //! A drawn minus sign.
377         Minus = SC_MARK_MINUS,
378 
379         //! A drawn plus sign.
380         Plus = SC_MARK_PLUS,
381 
382         //! A vertical line drawn in the background colour.
383         VerticalLine = SC_MARK_VLINE,
384 
385         //! A bottom left corner drawn in the background colour.
386         BottomLeftCorner = SC_MARK_LCORNER,
387 
388         //! A vertical line with a centre right horizontal line drawn
389         //! in the background colour.
390         LeftSideSplitter = SC_MARK_TCORNER,
391 
392         //! A drawn plus sign in a box.
393         BoxedPlus = SC_MARK_BOXPLUS,
394 
395         //! A drawn plus sign in a connected box.
396         BoxedPlusConnected = SC_MARK_BOXPLUSCONNECTED,
397 
398         //! A drawn minus sign in a box.
399         BoxedMinus = SC_MARK_BOXMINUS,
400 
401         //! A drawn minus sign in a connected box.
402         BoxedMinusConnected = SC_MARK_BOXMINUSCONNECTED,
403 
404         //! A rounded bottom left corner drawn in the background
405         //! colour.
406         RoundedBottomLeftCorner = SC_MARK_LCORNERCURVE,
407 
408         //! A vertical line with a centre right curved line drawn in the
409         //! background colour.
410         LeftSideRoundedSplitter = SC_MARK_TCORNERCURVE,
411 
412         //! A drawn plus sign in a circle.
413         CircledPlus = SC_MARK_CIRCLEPLUS,
414 
415         //! A drawn plus sign in a connected box.
416         CircledPlusConnected = SC_MARK_CIRCLEPLUSCONNECTED,
417 
418         //! A drawn minus sign in a circle.
419         CircledMinus = SC_MARK_CIRCLEMINUS,
420 
421         //! A drawn minus sign in a connected circle.
422         CircledMinusConnected = SC_MARK_CIRCLEMINUSCONNECTED,
423 
424         //! No symbol is drawn but the line is drawn with the same background
425         //! color as the marker's.
426         Background = SC_MARK_BACKGROUND,
427 
428         //! Three drawn dots.
429         ThreeDots = SC_MARK_DOTDOTDOT,
430 
431         //! Three drawn arrows pointing right.
432         ThreeRightArrows = SC_MARK_ARROWS,
433 
434         //! A full rectangle (ie. the margin background) using the marker's
435         //! background color.
436         FullRectangle = SC_MARK_FULLRECT,
437 
438         //! A left rectangle (ie. the left part of the margin background) using
439         //! the marker's background color.
440         LeftRectangle = SC_MARK_LEFTRECT,
441 
442         //! No symbol is drawn but the line is drawn underlined using the
443         //! marker's background color.
444         Underline = SC_MARK_UNDERLINE,
445 
446         //! A bookmark.
447         Bookmark = SC_MARK_BOOKMARK,
448     };
449 
450     //! This enum defines how tab characters are drawn when whitespace is
451     //! visible.
452     enum TabDrawMode {
453         //! An arrow stretching to the tab stop.
454         TabLongArrow = SCTD_LONGARROW,
455 
456         //! A horizontal line stretching to the tab stop.
457         TabStrikeOut = SCTD_STRIKEOUT,
458     };
459 
460     //! This enum defines the different whitespace visibility modes.  When
461     //! whitespace is visible spaces are displayed as small centred dots and
462     //! tabs are displayed as light arrows pointing to the right.
463     enum WhitespaceVisibility {
464         //! Whitespace is invisible.
465         WsInvisible = SCWS_INVISIBLE,
466 
467         //! Whitespace is always visible.
468         WsVisible = SCWS_VISIBLEALWAYS,
469 
470         //! Whitespace is visible after the whitespace used for indentation.
471         WsVisibleAfterIndent = SCWS_VISIBLEAFTERINDENT,
472 
473         //! Whitespace used for indentation is visible.
474         WsVisibleOnlyInIndent = SCWS_VISIBLEONLYININDENT,
475     };
476 
477     //! This enum defines the different line wrap modes.
478     enum WrapMode {
479         //! Lines are not wrapped.
480         WrapNone = SC_WRAP_NONE,
481 
482         //! Lines are wrapped at word boundaries.
483         WrapWord = SC_WRAP_WORD,
484 
485         //! Lines are wrapped at character boundaries.
486         WrapCharacter = SC_WRAP_CHAR,
487 
488         //! Lines are wrapped at whitespace boundaries.
489         WrapWhitespace = SC_WRAP_WHITESPACE,
490     };
491 
492     //! This enum defines the different line wrap visual flags.
493     enum WrapVisualFlag {
494         //! No wrap flag is displayed.
495         WrapFlagNone,
496 
497         //! A wrap flag is displayed by the text.
498         WrapFlagByText,
499 
500         //! A wrap flag is displayed by the border.
501         WrapFlagByBorder,
502 
503         //! A wrap flag is displayed in the line number margin.
504         WrapFlagInMargin
505     };
506 
507     //! This enum defines the different line wrap indentation modes.
508     enum WrapIndentMode {
509         //! Wrapped sub-lines are indented by the amount set by
510         //! setWrapVisualFlags().
511         WrapIndentFixed = SC_WRAPINDENT_FIXED,
512 
513         //! Wrapped sub-lines are indented by the same amount as the first
514         //! sub-line.
515         WrapIndentSame = SC_WRAPINDENT_SAME,
516 
517         //! Wrapped sub-lines are indented by the same amount as the first
518         //! sub-line plus one more level of indentation.
519         WrapIndentIndented = SC_WRAPINDENT_INDENT,
520 
521         //! Wrapped sub-lines are indented by the same amount as the first
522         //! sub-line plus two more level of indentation.
523         WrapIndentDeeplyIndented = SC_WRAPINDENT_DEEPINDENT
524     };
525 
526     //! Construct an empty QsciScintilla with parent \a parent.
527     QsciScintilla(QWidget *parent = 0);
528 
529     //! Destroys the QsciScintilla instance.
530     virtual ~QsciScintilla();
531 
532     //! Returns the API context, which is a list of words, before the position
533     //! \a pos in the document.  The context can be used by auto-completion and
534     //! call tips to help to identify which API call the user is referring to.
535     //! In the default implementation the current lexer determines what
536     //! characters make up a word, and what characters determine the boundaries
537     //! of words (ie. the start characters).  If there is no current lexer then
538     //! the context will consist of a single word.  On return \a context_start
539     //! will contain the position in the document of the start of the context
540     //! and \a last_word_start will contain the position in the document of the
541     //! start of the last word of the context.
542     virtual QStringList apiContext(int pos, int &context_start,
543             int &last_word_start);
544 
545     //! Annotate the line \a line with the text \a text using the style number
546     //! \a style.
547     void annotate(int line, const QString &text, int style);
548 
549     //! Annotate the line \a line with the text \a text using the style \a
550     //! style.
551     void annotate(int line, const QString &text, const QsciStyle &style);
552 
553     //! Annotate the line \a line with the styled text \a text.
554     void annotate(int line, const QsciStyledText &text);
555 
556     //! Annotate the line \a line with the list of styled text \a text.
557     void annotate(int line, const QList<QsciStyledText> &text);
558 
559     //! Returns the annotation on line \a line, if any.
560     QString annotation(int line) const;
561 
562     //! Returns the display style for annotations.
563     //!
564     //! \sa setAnnotationDisplay()
565     AnnotationDisplay annotationDisplay() const;
566 
567     //! The annotations on line \a line are removed.  If \a line is negative
568     //! then all annotations are removed.
569     void clearAnnotations(int line = -1);
570 
571     //! Returns true if auto-completion lists are case sensitive.
572     //!
573     //! \sa setAutoCompletionCaseSensitivity()
574     bool autoCompletionCaseSensitivity() const;
575 
576     //! Returns true if auto-completion fill-up characters are enabled.
577     //!
578     //! \sa setAutoCompletionFillups(), setAutoCompletionFillupsEnabled()
579     bool autoCompletionFillupsEnabled() const;
580 
581     //! Returns true if the rest of the word to the right of the current cursor
582     //! is removed when an item from an auto-completion list is selected.
583     //!
584     //! \sa setAutoCompletionReplaceWord()
585     bool autoCompletionReplaceWord() const;
586 
587     //! Returns true if the only item in an auto-completion list with a single
588     //! entry is automatically used and the list not displayed.  Note that this
589     //! is deprecated and autoCompletionUseSingle() should be used instead.
590     //!
591     //! \sa setAutoCompletionShowSingle()
592     bool autoCompletionShowSingle() const;
593 
594     //! Returns the current source for the auto-completion list when it is
595     //! being displayed automatically as the user types.
596     //!
597     //! \sa setAutoCompletionSource()
autoCompletionSource()598     AutoCompletionSource autoCompletionSource() const {return acSource;}
599 
600     //! Returns the current threshold for the automatic display of the
601     //! auto-completion list as the user types.
602     //!
603     //! \sa setAutoCompletionThreshold()
autoCompletionThreshold()604     int autoCompletionThreshold() const {return acThresh;}
605 
606     //! Returns the current behavior when an auto-completion list contains a
607     //! single entry.
608     //!
609     //! \sa setAutoCompletionUseSingle()
610     AutoCompletionUseSingle autoCompletionUseSingle() const;
611 
612     //! Returns true if auto-indentation is enabled.
613     //!
614     //! \sa setAutoIndent()
autoIndent()615     bool autoIndent() const {return autoInd;}
616 
617     //! Returns true if the backspace key unindents a line instead of deleting
618     //! a character.  The default is false.
619     //!
620     //! \sa setBackspaceUnindents(), tabIndents(), setTabIndents()
621     bool backspaceUnindents() const;
622 
623     //! Mark the beginning of a sequence of actions that can be undone by a
624     //! single call to undo().
625     //!
626     //! \sa endUndoAction(), undo()
627     void beginUndoAction();
628 
629     //! Returns the brace matching mode.
630     //!
631     //! \sa setBraceMatching()
braceMatching()632     BraceMatch braceMatching() const {return braceMode;}
633 
634     //! Returns the encoded text between positions \a start and \a end.  This
635     //! is typically used by QsciLexerCustom::styleText().
636     //!
637     //! \sa text()
638     QByteArray bytes(int start, int end) const;
639 
640     //! Returns the current call tip position.
641     //!
642     //! \sa setCallTipsPosition()
callTipsPosition()643     CallTipsPosition callTipsPosition() const {return call_tips_position;}
644 
645     //! Returns the current call tip style.
646     //!
647     //! \sa setCallTipsStyle()
callTipsStyle()648     CallTipsStyle callTipsStyle() const {return call_tips_style;}
649 
650     //! Returns the maximum number of call tips that are displayed.
651     //!
652     //! \sa setCallTipsVisible()
callTipsVisible()653     int callTipsVisible() const {return maxCallTips;}
654 
655     //! Cancel any previous call to findFirst(), findFirstInSelection() or
656     //! findNext() so that replace() does nothing.
657     void cancelFind();
658 
659     //! Cancel any current auto-completion or user defined list.
660     void cancelList();
661 
662     //! Returns true if the current language lexer is case sensitive.  If there
663     //! is no current lexer then true is returned.
664     bool caseSensitive() const;
665 
666     //! Clear all current folds, i.e. ensure that all lines are displayed
667     //! unfolded.
668     //!
669     //! \sa setFolding()
670     void clearFolds();
671 
672     //! Clears the range of text with indicator \a indicatorNumber starting at
673     //! position \a indexFrom in line \a lineFrom and finishing at position
674     //! \a indexTo in line \a lineTo.
675     //!
676     //! \sa fillIndicatorRange()
677     void clearIndicatorRange(int lineFrom, int indexFrom, int lineTo,
678             int indexTo, int indicatorNumber);
679 
680     //! Clear all registered images.
681     //!
682     //! \sa registerImage()
683     void clearRegisteredImages();
684 
685     //! Returns the widget's text (ie. foreground) colour.
686     //!
687     //! \sa setColor()
688     QColor color() const;
689 
690     //! Returns a list of the line numbers that have contracted folds.  This is
691     //! typically used to save the fold state of a document.
692     //!
693     //! \sa setContractedFolds()
694     QList<int> contractedFolds() const;
695 
696     //! All the lines of the text have their end-of-lines converted to mode
697     //! \a mode.
698     //!
699     //! \sa eolMode(), setEolMode()
700     void convertEols(EolMode mode);
701 
702     //! Create the standard context menu which is shown when the user clicks
703     //! with the right mouse button.  It is called from contextMenuEvent().
704     //! The menu's ownership is transferred to the caller.
705     QMenu *createStandardContextMenu();
706 
707     //! Returns the attached document.
708     //!
709     //! \sa setDocument()
document()710     QsciDocument document() const {return doc;}
711 
712     //! Mark the end of a sequence of actions that can be undone by a single
713     //! call to undo().
714     //!
715     //! \sa beginUndoAction(), undo()
716     void endUndoAction();
717 
718     //! Returns the color of the marker used to show that a line has exceeded
719     //! the length set by setEdgeColumn().
720     //!
721     //! \sa setEdgeColor(), \sa setEdgeColumn
722     QColor edgeColor() const;
723 
724     //! Returns the number of the column after which lines are considered to be
725     //! long.
726     //!
727     //! \sa setEdgeColumn()
728     int edgeColumn() const;
729 
730     //! Returns the edge mode which determines how long lines are marked.
731     //!
732     //! \sa setEdgeMode()
733     EdgeMode edgeMode() const;
734 
735     //! Set the default font.  This has no effect if a language lexer has been
736     //! set.
737     void setFont(const QFont &f);
738 
739     //! Returns the end-of-line mode.
740     //!
741     //! \sa setEolMode()
742     EolMode eolMode() const;
743 
744     //! Returns the visibility of end-of-lines.
745     //!
746     //! \sa setEolVisibility()
747     bool eolVisibility() const;
748 
749     //! Returns the extra space added to the height of a line above the
750     //! baseline of the text.
751     //!
752     //! \sa setExtraAscent(), extraDescent()
753     int extraAscent() const;
754 
755     //! Returns the extra space added to the height of a line below the
756     //! baseline of the text.
757     //!
758     //! \sa setExtraDescent(), extraAscent()
759     int extraDescent() const;
760 
761     //! Fills the range of text with indicator \a indicatorNumber starting at
762     //! position \a indexFrom in line \a lineFrom and finishing at position
763     //! \a indexTo in line \a lineTo.
764     //!
765     //! \sa clearIndicatorRange()
766     void fillIndicatorRange(int lineFrom, int indexFrom, int lineTo,
767             int indexTo, int indicatorNumber);
768 
769     //! Find the first occurrence of the string \a expr and return true if
770     //! \a expr was found, otherwise returns false.  If \a expr is found it
771     //! becomes the current selection.
772     //!
773     //! If \a re is true then \a expr is interpreted as a regular expression
774     //! rather than a simple string.
775     //!
776     //! If \a cs is true then the search is case sensitive.
777     //!
778     //! If \a wo is true then the search looks for whole word matches only,
779     //! otherwise it searches for any matching text.
780     //!
781     //! If \a wrap is true then the search wraps around the end of the text.
782     //!
783     //! If \a forward is true (the default) then the search is forward from the
784     //! starting position to the end of the text, otherwise it is backwards to
785     //! the beginning of the text.
786     //!
787     //! If either \a line or \a index are negative (the default) then the
788     //! search begins from the current cursor position.  Otherwise the search
789     //! begins at position \a index of line \a line.
790     //!
791     //! If \a show is true (the default) then any text found is made visible
792     //! (ie. it is unfolded).
793     //!
794     //! If \a posix is true then a regular expression is treated in a more
795     //! POSIX compatible manner by interpreting bare ( and ) as tagged sections
796     //! rather than \( and \).
797     //!
798     //! If \a cxx11 is true then a regular expression is treated as a Cxx11
799     //! regular expression.
800     //!
801     //! \sa cancelFind(), findFirstInSelection(), findNext(), replace()
802     virtual bool findFirst(const QString &expr, bool re, bool cs, bool wo,
803             bool wrap, bool forward = true, int line = -1, int index = -1,
804             bool show = true, bool posix = false, bool cxx11 = false);
805 
806     //! Find the first occurrence of the string \a expr in the current
807     //! selection and return true if \a expr was found, otherwise returns
808     //! false.  If \a expr is found it becomes the current selection.  The
809     //! original selection is restored when a subsequent call to findNext()
810     //! returns false.
811     //!
812     //! If \a re is true then \a expr is interpreted as a regular expression
813     //! rather than a simple string.
814     //!
815     //! If \a cs is true then the search is case sensitive.
816     //!
817     //! If \a wo is true then the search looks for whole word matches only,
818     //! otherwise it searches for any matching text.
819     //!
820     //! If \a forward is true (the default) then the search is forward from the
821     //! start to the end of the selection, otherwise it is backwards from the
822     //! end to the start of the selection.
823     //!
824     //! If \a show is true (the default) then any text found is made visible
825     //! (ie. it is unfolded).
826     //!
827     //! If \a posix is true then a regular expression is treated in a more
828     //! POSIX compatible manner by interpreting bare ( and ) as tagged sections
829     //! rather than \( and \).
830     //!
831     //! If \a cxx11 is true then a regular expression is treated as a Cxx11
832     //! regular expression.
833     //!
834     //! \sa cancelFind(), findFirst(), findNext(), replace()
835     virtual bool findFirstInSelection(const QString &expr, bool re, bool cs,
836             bool wo, bool forward = true, bool show = true,
837             bool posix = false, bool cxx11 = false);
838 
839     //! Find the next occurence of the string found using findFirst() or
840     //! findFirstInSelection().
841     //!
842     //! \sa cancelFind(), findFirst(), findFirstInSelection(), replace()
843     virtual bool findNext();
844 
845     //! Find a brace and it's match.  \a brace is updated with the position of
846     //! the brace and will be -1 if there is none.  \a is updated with the
847     //! position of the matching brace and will be -1 if there is none.
848     //! \a mode specifies how braces are matched.  true is returned if the
849     //! current position is inside a pair of braces.
850     bool findMatchingBrace(long &brace, long &other, BraceMatch mode);
851 
852     //! Returns the number of the first visible line.
853     //!
854     //! \sa setFirstVisibleLine()
855     int firstVisibleLine() const;
856 
857     //! Returns the current folding style.
858     //!
859     //! \sa setFolding()
folding()860     FoldStyle folding() const {return fold;}
861 
862     //! Sets \a *line and \a *index to the line and index of the cursor.
863     //!
864     //! \sa setCursorPosition()
865     void getCursorPosition(int *line, int *index) const;
866 
867     //! If there is a selection, \a *lineFrom is set to the line number in
868     //! which the selection begins and \a *lineTo is set to the line number in
869     //! which the selection ends.  (They could be the same.)  \a *indexFrom is
870     //! set to the index at which the selection begins within \a *lineFrom, and
871     //! \a *indexTo is set to the index at which the selection ends within
872     //! \a *lineTo.  If there is no selection, \a *lineFrom, \a *indexFrom,
873     //! \a *lineTo and \a *indexTo are all set to -1.
874     //!
875     //! \sa setSelection()
876     void getSelection(int *lineFrom, int *indexFrom, int *lineTo,
877             int *indexTo) const;
878 
879     //! Returns true if some text is selected.
880     //!
881     //! \sa selectedText()
hasSelectedText()882     bool hasSelectedText() const {return selText;}
883 
884     //! Returns the number of characters that line \a line is indented by.
885     //!
886     //! \sa setIndentation()
887     int indentation(int line) const;
888 
889     //! Returns true if the display of indentation guides is enabled.
890     //!
891     //! \sa setIndentationGuides()
892     bool indentationGuides() const;
893 
894     //! Returns true if indentations are created using tabs and spaces, rather
895     //! than just spaces.  The default is true.
896     //!
897     //! \sa setIndentationsUseTabs()
898     bool indentationsUseTabs() const;
899 
900     //! Returns the indentation width in characters.  The default is 0 which
901     //! means that the value returned by tabWidth() is actually used.
902     //!
903     //! \sa setIndentationWidth(), tabWidth()
904     int indentationWidth() const;
905 
906     //! Define a type of indicator using the style \a style with the indicator
907     //! number \a indicatorNumber.  If \a indicatorNumber is -1 then the
908     //! indicator number is automatically allocated.  The indicator number is
909     //! returned or -1 if too many types of indicator have been defined.
910     //!
911     //! Indicators are used to display additional information over the top of
912     //! styling.  They can be used to show, for example, syntax errors,
913     //! deprecated names and bad indentation by drawing lines under text or
914     //! boxes around text.
915     //!
916     //! There may be up to 32 types of indicator defined at a time.  The first
917     //! 8 are normally used by lexers.  By default indicator number 0 is a
918     //! dark green SquiggleIndicator, 1 is a blue TTIndicator, and 2 is a red
919     //! PlainIndicator.
920     int indicatorDefine(IndicatorStyle style, int indicatorNumber = -1);
921 
922     //! Returns true if the indicator \a indicatorNumber is drawn under the
923     //! text (i.e. in the background).  The default is false.
924     //!
925     //! \sa setIndicatorDrawUnder()
926     bool indicatorDrawUnder(int indicatorNumber) const;
927 
928     //! Returns true if a call tip is currently active.
929     bool isCallTipActive() const;
930 
931     //! Returns true if an auto-completion or user defined list is currently
932     //! active.
933     bool isListActive() const;
934 
935     //! Returns true if the text has been modified.
936     //!
937     //! \sa setModified(), modificationChanged()
938     bool isModified() const;
939 
940     //! Returns true if the text edit is read-only.
941     //!
942     //! \sa setReadOnly()
943     bool isReadOnly() const;
944 
945     //! Returns true if there is something that can be redone.
946     //!
947     //! \sa redo()
948     bool isRedoAvailable() const;
949 
950     //! Returns true if there is something that can be undone.
951     //!
952     //! \sa undo()
953     bool isUndoAvailable() const;
954 
955     //! Returns true if text is interpreted as being UTF8 encoded.  The default
956     //! is to interpret the text as Latin1 encoded.
957     //!
958     //! \sa setUtf8()
959     bool isUtf8() const;
960 
961     //! Returns true if character \a ch is a valid word character.
962     //!
963     //! \sa wordCharacters()
964     bool isWordCharacter(char ch) const;
965 
966     //! Returns the line which is at \a point pixel coordinates or -1 if there
967     //! is no line at that point.
968     int lineAt(const QPoint &point) const;
969 
970     //! QScintilla uses the combination of a line number and a character index
971     //! from the start of that line to specify the position of a character
972     //! within the text.  The underlying Scintilla instead uses a byte index
973     //! from the start of the text.  This will convert the \a position byte
974     //! index to the \a *line line number and \a *index character index.
975     //!
976     //! \sa positionFromLineIndex()
977     void lineIndexFromPosition(int position, int *line, int *index) const;
978 
979     //! Returns the length of line \a line int bytes or -1 if there is no such
980     //! line.  In order to get the length in characters use text(line).length().
981     int lineLength(int line) const;
982 
983     //! Returns the number of lines of text.
984     int lines() const;
985 
986     //! Returns the length of the text edit's text in bytes.  In order to get
987     //! the length in characters use text().length().
988     int length() const;
989 
990     //! Returns the current language lexer used to style text.  If it is 0 then
991     //! syntax styling is disabled.
992     //!
993     //! \sa setLexer()
994     QsciLexer *lexer() const;
995 
996     //! Returns the background color of margin \a margin.
997     //!
998     //! \sa setMarginBackgroundColor()
999     QColor marginBackgroundColor(int margin) const;
1000 
1001     //! Returns true if line numbers are enabled for margin \a margin.
1002     //!
1003     //! \sa setMarginLineNumbers(), marginType(), SCI_GETMARGINTYPEN
1004     bool marginLineNumbers(int margin) const;
1005 
1006     //! Returns the marker mask of margin \a margin.
1007     //!
1008     //! \sa setMarginMask(), QsciMarker, SCI_GETMARGINMASKN
1009     int marginMarkerMask(int margin) const;
1010 
1011     //! Returns the margin options.  The default is MoNone.
1012     //!
1013     //! \sa setMarginOptions(), MoNone, MoSublineSelect.
1014     int marginOptions() const;
1015 
1016     //! Returns true if margin \a margin is sensitive to mouse clicks.
1017     //!
1018     //! \sa setMarginSensitivity(), marginClicked(), SCI_GETMARGINTYPEN
1019     bool marginSensitivity(int margin) const;
1020 
1021     //! Returns the type of margin \a margin.
1022     //!
1023     //! \sa setMarginType(), SCI_GETMARGINTYPEN
1024     MarginType marginType(int margin) const;
1025 
1026     //! Returns the width in pixels of margin \a margin.
1027     //!
1028     //! \sa setMarginWidth(), SCI_GETMARGINWIDTHN
1029     int marginWidth(int margin) const;
1030 
1031     //! Returns the number of margins.
1032     //!
1033     //! \sa setMargins()
1034     int margins() const;
1035 
1036     //! Define a type of marker using the symbol \a sym with the marker number
1037     //! \a markerNumber.  If \a markerNumber is -1 then the marker number is
1038     //! automatically allocated.  The marker number is returned or -1 if too
1039     //! many types of marker have been defined.
1040     //!
1041     //! Markers are small geometric symbols and characters used, for example,
1042     //! to indicate the current line or, in debuggers, to indicate breakpoints.
1043     //! If a margin has a width of 0 then its markers are not drawn, but their
1044     //! background colours affect the background colour of the corresponding
1045     //! line of text.
1046     //!
1047     //! There may be up to 32 types of marker defined at a time and each line
1048     //! of text has a set of marker instances associated with it.  Markers are
1049     //! drawn according to their numerical identifier.  Markers try to move
1050     //! with their text by tracking where the start of their line moves to.
1051     //! For example, when a line is deleted its markers are added to previous
1052     //! line's markers.
1053     //!
1054     //! Each marker type is identified by a marker number.  Each instance of a
1055     //! marker is identified by a marker handle.
1056     int markerDefine(MarkerSymbol sym, int markerNumber = -1);
1057 
1058     //! Define a marker using the character \a ch with the marker number
1059     //! \a markerNumber.  If \a markerNumber is -1 then the marker number is
1060     //! automatically allocated.  The marker number is returned or -1 if too
1061     //! many markers have been defined.
1062     int markerDefine(char ch, int markerNumber = -1);
1063 
1064     //! Define a marker using a copy of the pixmap \a pm with the marker number
1065     //! \a markerNumber.  If \a markerNumber is -1 then the marker number is
1066     //! automatically allocated.  The marker number is returned or -1 if too
1067     //! many markers have been defined.
1068     int markerDefine(const QPixmap &pm, int markerNumber = -1);
1069 
1070     //! Define a marker using a copy of the image \a im with the marker number
1071     //! \a markerNumber.  If \a markerNumber is -1 then the marker number is
1072     //! automatically allocated.  The marker number is returned or -1 if too
1073     //! many markers have been defined.
1074     int markerDefine(const QImage &im, int markerNumber = -1);
1075 
1076     //! Add an instance of marker number \a markerNumber to line number
1077     //! \a linenr.  A handle for the marker is returned which can be used to
1078     //! track the marker's position, or -1 if the \a markerNumber was invalid.
1079     //!
1080     //! \sa markerDelete(), markerDeleteAll(), markerDeleteHandle()
1081     int markerAdd(int linenr, int markerNumber);
1082 
1083     //! Returns the 32 bit mask of marker numbers at line number \a linenr.
1084     //!
1085     //! \sa markerAdd()
1086     unsigned markersAtLine(int linenr) const;
1087 
1088     //! Delete all markers with the marker number \a markerNumber in the line
1089     //! \a linenr.  If \a markerNumber is -1 then delete all markers from line
1090     //! \a linenr.
1091     //!
1092     //! \sa markerAdd(), markerDeleteAll(), markerDeleteHandle()
1093     void markerDelete(int linenr, int markerNumber = -1);
1094 
1095     //! Delete the all markers with the marker number \a markerNumber.  If
1096     //! \a markerNumber is -1 then delete all markers.
1097     //!
1098     //! \sa markerAdd(), markerDelete(), markerDeleteHandle()
1099     void markerDeleteAll(int markerNumber = -1);
1100 
1101     //! Delete the the marker instance with the marker handle \a mhandle.
1102     //!
1103     //! \sa markerAdd(), markerDelete(), markerDeleteAll()
1104     void markerDeleteHandle(int mhandle);
1105 
1106     //! Return the line number that contains the marker instance with the
1107     //! marker handle \a mhandle.
1108     int markerLine(int mhandle) const;
1109 
1110     //! Return the number of the next line to contain at least one marker from
1111     //! a 32 bit mask of markers.  \a linenr is the line number to start the
1112     //! search from.  \a mask is the mask of markers to search for.
1113     //!
1114     //! \sa markerFindPrevious()
1115     int markerFindNext(int linenr, unsigned mask) const;
1116 
1117     //! Return the number of the previous line to contain at least one marker
1118     //! from a 32 bit mask of markers.  \a linenr is the line number to start
1119     //! the search from.  \a mask is the mask of markers to search for.
1120     //!
1121     //! \sa markerFindNext()
1122     int markerFindPrevious(int linenr, unsigned mask) const;
1123 
1124     //! Returns true if text entered by the user will overwrite existing text.
1125     //!
1126     //! \sa setOverwriteMode()
1127     bool overwriteMode() const;
1128 
1129     //! Returns the widget's paper (ie. background) colour.
1130     //!
1131     //! \sa setPaper()
1132     QColor paper() const;
1133 
1134     //! QScintilla uses the combination of a line number and a character index
1135     //! from the start of that line to specify the position of a character
1136     //! within the text.  The underlying Scintilla instead uses a byte index
1137     //! from the start of the text.  This will return the byte index
1138     //! corresponding to the \a line line number and \a index character index.
1139     //!
1140     //! \sa lineIndexFromPosition()
1141     int positionFromLineIndex(int line, int index) const;
1142 
1143     //! Reads the current document from the \a io device and returns true if
1144     //! there was no error.
1145     //!
1146     //! \sa write()
1147     bool read(QIODevice *io);
1148 
1149     //! Recolours the document between the \a start and \a end positions.
1150     //! \a start defaults to the start of the document and \a end defaults to
1151     //! the end of the document.
1152     virtual void recolor(int start = 0, int end = -1);
1153 
1154     //! Register an image \a pm with ID \a id.  Registered images can be
1155     //! displayed in auto-completion lists.
1156     //!
1157     //! \sa clearRegisteredImages(), QsciLexer::apiLoad()
1158     void registerImage(int id, const QPixmap &pm);
1159 
1160     //! Register an image \a im with ID \a id.  Registered images can be
1161     //! displayed in auto-completion lists.
1162     //!
1163     //! \sa clearRegisteredImages(), QsciLexer::apiLoad()
1164     void registerImage(int id, const QImage &im);
1165 
1166     //! Replace the current selection, set by a previous call to findFirst(),
1167     //! findFirstInSelection() or findNext(), with \a replaceStr.
1168     //!
1169     //! \sa cancelFind(), findFirst(), findFirstInSelection(), findNext()
1170     virtual void replace(const QString &replaceStr);
1171 
1172     //! Reset the fold margin colours to their defaults.
1173     //!
1174     //! \sa setFoldMarginColors()
1175     void resetFoldMarginColors();
1176 
1177     //! Resets the background colour of an active hotspot area to the default.
1178     //!
1179     //! \sa setHotspotBackgroundColor(), resetHotspotForegroundColor()
1180     void resetHotspotBackgroundColor();
1181 
1182     //! Resets the foreground colour of an active hotspot area to the default.
1183     //!
1184     //! \sa setHotspotForegroundColor(), resetHotspotBackgroundColor()
1185     void resetHotspotForegroundColor();
1186 
1187     //! Gets the assumed document width in pixels.
1188     //!
1189     //! \sa setScrollWidth(), setScrollWidthTracking()
1190     int scrollWidth() const;
1191 
1192     //! Returns true if scroll width tracking is enabled.
1193     //!
1194     //! \sa scrollWidth(), setScrollWidthTracking()
1195     bool scrollWidthTracking() const;
1196 
1197     //! The fold margin may be drawn as a one pixel sized checkerboard pattern
1198     //! of two colours, \a fore and \a back.
1199     //!
1200     //! \sa resetFoldMarginColors()
1201     void setFoldMarginColors(const QColor &fore, const QColor &back);
1202 
1203     //! Set the display style for annotations.  The default is
1204     //! AnnotationStandard.
1205     //!
1206     //! \sa annotationDisplay()
1207     void setAnnotationDisplay(AnnotationDisplay display);
1208 
1209     //! Enable the use of fill-up characters, either those explicitly set or
1210     //! those set by a lexer.  By default, fill-up characters are disabled.
1211     //!
1212     //! \sa autoCompletionFillupsEnabled(), setAutoCompletionFillups()
1213     void setAutoCompletionFillupsEnabled(bool enabled);
1214 
1215     //! A fill-up character is one that, when entered while an auto-completion
1216     //! list is being displayed, causes the currently selected item from the
1217     //! list to be added to the text followed by the fill-up character.
1218     //! \a fillups is the set of fill-up characters.  If a language lexer has
1219     //! been set then this is ignored and the lexer defines the fill-up
1220     //! characters.  The default is that no fill-up characters are set.
1221     //!
1222     //! \sa autoCompletionFillupsEnabled(), setAutoCompletionFillupsEnabled()
1223     void setAutoCompletionFillups(const char *fillups);
1224 
1225     //! A word separator is a sequence of characters that, when entered, causes
1226     //! the auto-completion list to be displayed.  If a language lexer has been
1227     //! set then this is ignored and the lexer defines the word separators.
1228     //! The default is that no word separators are set.
1229     //!
1230     //! \sa setAutoCompletionThreshold()
1231     void setAutoCompletionWordSeparators(const QStringList &separators);
1232 
1233     //! Set the background colour of call tips to \a col.  The default is
1234     //! white.
1235     void setCallTipsBackgroundColor(const QColor &col);
1236 
1237     //! Set the foreground colour of call tips to \a col.  The default is
1238     //! mid-gray.
1239     void setCallTipsForegroundColor(const QColor &col);
1240 
1241     //! Set the highlighted colour of call tip text to \a col.  The default is
1242     //! dark blue.
1243     void setCallTipsHighlightColor(const QColor &col);
1244 
1245     //! Set the current call tip position.  The default is CallTipsBelowText.
1246     //!
1247     //! \sa callTipsPosition()
1248     void setCallTipsPosition(CallTipsPosition position);
1249 
1250     //! Set the current call tip style.  The default is CallTipsNoContext.
1251     //!
1252     //! \sa callTipsStyle()
1253     void setCallTipsStyle(CallTipsStyle style);
1254 
1255     //! Set the maximum number of call tips that are displayed to \a nr.  If
1256     //! the maximum number is 0 then all applicable call tips are displayed.
1257     //! If the maximum number is -1 then one call tip will be displayed with up
1258     //! and down arrows that allow the use to scroll through the full list.
1259     //! The default is -1.
1260     //!
1261     //! \sa callTipsVisible()
1262     void setCallTipsVisible(int nr);
1263 
1264     //! Sets each line in the \a folds list of line numbers to be a contracted
1265     //! fold.  This is typically used to restore the fold state of a document.
1266     //!
1267     //! \sa contractedFolds()
1268     void setContractedFolds(const QList<int> &folds);
1269 
1270     //! Attach the document \a document, replacing the currently attached
1271     //! document.
1272     //!
1273     //! \sa document()
1274     void setDocument(const QsciDocument &document);
1275 
1276     //! Add \a colnr to the columns which are displayed with a vertical line.
1277     //! The edge mode must be set to EdgeMultipleLines.
1278     //!
1279     //! \sa clearEdgeColumns()
1280     void addEdgeColumn(int colnr, const QColor &col);
1281 
1282     //! Remove any columns added by previous calls to addEdgeColumn().
1283     //!
1284     //! \sa addEdgeColumn()
1285     void clearEdgeColumns();
1286 
1287     //! Set the color of the marker used to show that a line has exceeded the
1288     //! length set by setEdgeColumn().
1289     //!
1290     //! \sa edgeColor(), \sa setEdgeColumn
1291     void setEdgeColor(const QColor &col);
1292 
1293     //! Set the number of the column after which lines are considered to be
1294     //! long.
1295     //!
1296     //! \sa edgeColumn()
1297     void setEdgeColumn(int colnr);
1298 
1299     //! Set the edge mode which determines how long lines are marked.
1300     //!
1301     //! \sa edgeMode()
1302     void setEdgeMode(EdgeMode mode);
1303 
1304     //! Set the number of the first visible line to \a linenr.
1305     //!
1306     //! \sa firstVisibleLine()
1307     void setFirstVisibleLine(int linenr);
1308 
1309     //! Enables or disables, according to \a under, if the indicator
1310     //! \a indicatorNumber is drawn under or over the text (i.e. in the
1311     //! background or foreground).  If \a indicatorNumber is -1 then the state
1312     //! of all indicators is set.
1313     //!
1314     //! \sa indicatorDrawUnder()
1315     void setIndicatorDrawUnder(bool under, int indicatorNumber = -1);
1316 
1317     //! Set the foreground colour of indicator \a indicatorNumber to \a col.
1318     //! If \a indicatorNumber is -1 then the colour of all indicators is set.
1319     void setIndicatorForegroundColor(const QColor &col, int indicatorNumber = -1);
1320 
1321     //! Set the foreground colour of indicator \a indicatorNumber to \a col
1322     //! when the mouse is over it or the caret moved into it.  If
1323     //! \a indicatorNumber is -1 then the colour of all indicators is set.
1324     void setIndicatorHoverForegroundColor(const QColor &col, int indicatorNumber = -1);
1325 
1326     //! Set the style of indicator \a indicatorNumber to \a style when the
1327     //! mouse is over it or the caret moved into it.  If \a indicatorNumber is
1328     //! -1 then the style of all indicators is set.
1329     void setIndicatorHoverStyle(IndicatorStyle style, int indicatorNumber = -1);
1330 
1331     //! Set the outline colour of indicator \a indicatorNumber to \a col.
1332     //! If \a indicatorNumber is -1 then the colour of all indicators is set.
1333     //! At the moment only the alpha value of the colour has any affect.
1334     void setIndicatorOutlineColor(const QColor &col, int indicatorNumber = -1);
1335 
1336     //! Sets the background color of margin \a margin to \a col.
1337     //!
1338     //! \sa marginBackgroundColor()
1339     void setMarginBackgroundColor(int margin, const QColor &col);
1340 
1341     //! Set the margin options to \a options.
1342     //!
1343     //! \sa marginOptions(), MoNone, MoSublineSelect.
1344     void setMarginOptions(int options);
1345 
1346     //! Set the margin text of line \a line with the text \a text using the
1347     //! style number \a style.
1348     void setMarginText(int line, const QString &text, int style);
1349 
1350     //! Set the margin text of line \a line with the text \a text using the
1351     //! style \a style.
1352     void setMarginText(int line, const QString &text, const QsciStyle &style);
1353 
1354     //! Set the margin text of line \a line with the styled text \a text.
1355     void setMarginText(int line, const QsciStyledText &text);
1356 
1357     //! Set the margin text of line \a line with the list of styled text \a
1358     //! text.
1359     void setMarginText(int line, const QList<QsciStyledText> &text);
1360 
1361     //! Set the type of margin \a margin to type \a type.
1362     //!
1363     //! \sa marginType(), SCI_SETMARGINTYPEN
1364     void setMarginType(int margin, MarginType type);
1365 
1366     //! The margin text on line \a line is removed.  If \a line is negative
1367     //! then all margin text is removed.
1368     void clearMarginText(int line = -1);
1369 
1370     //! Set the number of margins to \a margins.
1371     //!
1372     //! \sa margins()
1373     void setMargins(int margins);
1374 
1375     //! Set the background colour, including the alpha component, of marker
1376     //! \a markerNumber to \a col.  If \a markerNumber is -1 then the colour of
1377     //! all markers is set.  The default is white.
1378     //!
1379     //! \sa setMarkerForegroundColor()
1380     void setMarkerBackgroundColor(const QColor &col, int markerNumber = -1);
1381 
1382     //! Set the foreground colour of marker \a markerNumber to \a col.  If
1383     //! \a markerNumber is -1 then the colour of all markers is set.  The
1384     //! default is black.
1385     //!
1386     //! \sa setMarkerBackgroundColor()
1387     void setMarkerForegroundColor(const QColor &col, int markerNumber = -1);
1388 
1389     //! Set the background colour used to display matched braces to \a col.  It
1390     //! is ignored if an indicator is being used.  The default is white.
1391     //!
1392     //! \sa setMatchedBraceForegroundColor(), setMatchedBraceIndicator()
1393     void setMatchedBraceBackgroundColor(const QColor &col);
1394 
1395     //! Set the foreground colour used to display matched braces to \a col.  It
1396     //! is ignored if an indicator is being used.  The default is red.
1397     //!
1398     //! \sa setMatchedBraceBackgroundColor(), setMatchedBraceIndicator()
1399     void setMatchedBraceForegroundColor(const QColor &col);
1400 
1401     //! Set the indicator used to display matched braces to \a indicatorNumber.
1402     //! The default is not to use an indicator.
1403     //!
1404     //! \sa resetMatchedBraceIndicator(), setMatchedBraceBackgroundColor()
1405     void setMatchedBraceIndicator(int indicatorNumber);
1406 
1407     //! Stop using an indicator to display matched braces.
1408     //!
1409     //! \sa setMatchedBraceIndicator()
1410     void resetMatchedBraceIndicator();
1411 
1412     //! For performance, QScintilla does not measure the display width of the
1413     //! document to determine the properties of the horizontal scroll bar.
1414     //! Instead, an assumed width is used.  This sets the document width in
1415     //! pixels assumed by QScintilla to \a pixelWidth.  The default value is
1416     //! 2000.
1417     //!
1418     //! \sa scrollWidth(), setScrollWidthTracking()
1419     void setScrollWidth(int pixelWidth);
1420 
1421     //! If scroll width tracking is enabled then the scroll width is adjusted
1422     //! to ensure that all of the lines currently displayed can be completely
1423     //! scrolled.  This mode never adjusts the scroll width to be narrower.
1424     //! This sets the scroll width tracking to \a enabled.
1425     //!
1426     //! \sa setScrollWidth(), scrollWidthTracking()
1427     void setScrollWidthTracking(bool enabled);
1428 
1429     //! Sets the mode used to draw tab characters when whitespace is visible to
1430     //! \a mode.  The default is to use an arrow.
1431     //!
1432     //! \sa tabDrawMode()
1433     void setTabDrawMode(TabDrawMode mode);
1434 
1435     //! Set the background colour used to display unmatched braces to \a col.
1436     //! It is ignored if an indicator is being used.  The default is white.
1437     //!
1438     //! \sa setUnmatchedBraceForegroundColor(), setUnmatchedBraceIndicator()
1439     void setUnmatchedBraceBackgroundColor(const QColor &col);
1440 
1441     //! Set the foreground colour used to display unmatched braces to \a col.
1442     //! It is ignored if an indicator is being used.  The default is blue.
1443     //!
1444     //! \sa setUnmatchedBraceBackgroundColor(), setUnmatchedBraceIndicator()
1445     void setUnmatchedBraceForegroundColor(const QColor &col);
1446 
1447     //! Set the indicator used to display unmatched braces to
1448     //! \a indicatorNumber.  The default is not to use an indicator.
1449     //!
1450     //! \sa resetUnmatchedBraceIndicator(), setUnmatchedBraceBackgroundColor()
1451     void setUnmatchedBraceIndicator(int indicatorNumber);
1452 
1453     //! Stop using an indicator to display unmatched braces.
1454     //!
1455     //! \sa setUnmatchedBraceIndicator()
1456     void resetUnmatchedBraceIndicator();
1457 
1458     //! Set the visual flags displayed when a line is wrapped.  \a endFlag
1459     //! determines if and where the flag at the end of a line is displayed.
1460     //! \a startFlag determines if and where the flag at the start of a line is
1461     //! displayed.  \a indent is the number of characters a wrapped line is
1462     //! indented by.  By default no visual flags are displayed.
1463     void setWrapVisualFlags(WrapVisualFlag endFlag,
1464             WrapVisualFlag startFlag = WrapFlagNone, int indent = 0);
1465 
1466     //! Returns the selected text or an empty string if there is no currently
1467     //! selected text.
1468     //!
1469     //! \sa hasSelectedText()
1470     QString selectedText() const;
1471 
1472     //! Returns whether or not the selection is drawn up to the right hand
1473     //! border.
1474     //!
1475     //! \sa setSelectionToEol()
1476     bool selectionToEol() const;
1477 
1478     //! Sets the background colour of an active hotspot area to \a col.
1479     //!
1480     //! \sa resetHotspotBackgroundColor(), setHotspotForegroundColor()
1481     void setHotspotBackgroundColor(const QColor &col);
1482 
1483     //! Sets the foreground colour of an active hotspot area to \a col.
1484     //!
1485     //! \sa resetHotspotForegroundColor(), setHotspotBackgroundColor()
1486     void setHotspotForegroundColor(const QColor &col);
1487 
1488     //! Enables or disables, according to \a enable, the underlining of an
1489     //! active hotspot area.  The default is false.
1490     void setHotspotUnderline(bool enable);
1491 
1492     //! Enables or disables, according to \a enable, the wrapping of a hotspot
1493     //! area to following lines.  The default is true.
1494     void setHotspotWrap(bool enable);
1495 
1496     //! Sets whether or not the selection is drawn up to the right hand border.
1497     //! \a filled is set if the selection is drawn to the border.
1498     //!
1499     //! \sa selectionToEol()
1500     void setSelectionToEol(bool filled);
1501 
1502     //! Sets the extra space added to the height of a line above the baseline
1503     //! of the text to \a extra.
1504     //!
1505     //! \sa extraAscent(), setExtraDescent()
1506     void setExtraAscent(int extra);
1507 
1508     //! Sets the extra space added to the height of a line below the baseline
1509     //! of the text to \a extra.
1510     //!
1511     //! \sa extraDescent(), setExtraAscent()
1512     void setExtraDescent(int extra);
1513 
1514     //! Text entered by the user will overwrite existing text if \a overwrite
1515     //! is true.
1516     //!
1517     //! \sa overwriteMode()
1518     void setOverwriteMode(bool overwrite);
1519 
1520     //! Sets the background colour of visible whitespace to \a col.  If \a col
1521     //! is an invalid color (the default) then the color specified by the
1522     //! current lexer is used.
1523     void setWhitespaceBackgroundColor(const QColor &col);
1524 
1525     //! Sets the foreground colour of visible whitespace to \a col.  If \a col
1526     //! is an invalid color (the default) then the color specified by the
1527     //! current lexer is used.
1528     void setWhitespaceForegroundColor(const QColor &col);
1529 
1530     //! Sets the size of the dots used to represent visible whitespace.
1531     //!
1532     //! \sa whitespaceSize()
1533     void setWhitespaceSize(int size);
1534 
1535     //! Sets the line wrap indentation mode to \a mode.  The default is
1536     //! WrapIndentFixed.
1537     //!
1538     //! \sa wrapIndentMode()
1539     void setWrapIndentMode(WrapIndentMode mode);
1540 
1541     //! Displays a user defined list which can be interacted with like an
1542     //! auto-completion list.  \a id is an identifier for the list which is
1543     //! passed as an argument to the userListActivated() signal and must be at
1544     //! least 1.  \a list is the text with which the list is populated.
1545     //!
1546     //! \sa cancelList(), isListActive(), userListActivated()
1547     void showUserList(int id, const QStringList &list);
1548 
1549     //! The standard command set is returned.
standardCommands()1550     QsciCommandSet *standardCommands() const {return stdCmds;}
1551 
1552     //! Returns the mode used to draw tab characters when whitespace is
1553     //! visible.
1554     //!
1555     //! \sa setTabDrawMode()
1556     TabDrawMode tabDrawMode() const;
1557 
1558     //! Returns true if the tab key indents a line instead of inserting a tab
1559     //! character.  The default is true.
1560     //!
1561     //! \sa setTabIndents(), backspaceUnindents(), setBackspaceUnindents()
1562     bool tabIndents() const;
1563 
1564     //! Returns the tab width in characters.  The default is 8.
1565     //!
1566     //! \sa setTabWidth()
1567     int tabWidth() const;
1568 
1569     //! Returns the text of the current document.
1570     //!
1571     //! \sa setText()
1572     QString text() const;
1573 
1574     //! \overload
1575     //!
1576     //! Returns the text of line \a line.
1577     //!
1578     //! \sa setText()
1579     QString text(int line) const;
1580 
1581     //! \overload
1582     //!
1583     //! Returns the text between positions \a start and \a end.  This is
1584     //! typically used by QsciLexerCustom::styleText().
1585     //!
1586     //! \sa bytes(), setText()
1587     QString text(int start, int end) const;
1588 
1589     //! Returns the height in pixels of the text in line number \a linenr.
1590     int textHeight(int linenr) const;
1591 
1592     //! Returns the size of the dots used to represent visible whitespace.
1593     //!
1594     //! \sa setWhitespaceSize()
1595     int whitespaceSize() const;
1596 
1597     //! Returns the visibility of whitespace.
1598     //!
1599     //! \sa setWhitespaceVisibility()
1600     WhitespaceVisibility whitespaceVisibility() const;
1601 
1602     //! Returns the word at the \a line line number and \a index character
1603     //! index.
1604     QString wordAtLineIndex(int line, int index) const;
1605 
1606     //! Returns the word at the \a point pixel coordinates.
1607     QString wordAtPoint(const QPoint &point) const;
1608 
1609     //! Returns the set of valid word character as defined by the current
1610     //! language lexer.  If there is no current lexer then the set contains an
1611     //! an underscore, numbers and all upper and lower case alphabetic
1612     //! characters.
1613     //!
1614     //! \sa isWordCharacter()
1615     const char *wordCharacters() const;
1616 
1617     //! Returns the line wrap mode.
1618     //!
1619     //! \sa setWrapMode()
1620     WrapMode wrapMode() const;
1621 
1622     //! Returns the line wrap indentation mode.
1623     //!
1624     //! \sa setWrapIndentMode()
1625     WrapIndentMode wrapIndentMode() const;
1626 
1627     //! Writes the current document to the \a io device and returns true if
1628     //! there was no error.
1629     //!
1630     //! \sa read()
1631     bool write(QIODevice *io) const;
1632 
1633 public slots:
1634     //! Appends the text \a text to the end of the text edit.  Note that the
1635     //! undo/redo history is cleared by this function.
1636     virtual void append(const QString &text);
1637 
1638     //! Display an auto-completion list based on any installed APIs, the
1639     //! current contents of the document and the characters immediately to the
1640     //! left of the cursor.
1641     //!
1642     //! \sa autoCompleteFromAPIs(), autoCompleteFromDocument()
1643     virtual void autoCompleteFromAll();
1644 
1645     //! Display an auto-completion list based on any installed APIs and the
1646     //! characters immediately to the left of the cursor.
1647     //!
1648     //! \sa autoCompleteFromAll(), autoCompleteFromDocument(),
1649     //! setAutoCompletionAPIs()
1650     virtual void autoCompleteFromAPIs();
1651 
1652     //! Display an auto-completion list based on the current contents of the
1653     //! document and the characters immediately to the left of the cursor.
1654     //!
1655     //! \sa autoCompleteFromAll(), autoCompleteFromAPIs()
1656     virtual void autoCompleteFromDocument();
1657 
1658     //! Display a call tip based on the the characters immediately to the left
1659     //! of the cursor.
1660     virtual void callTip();
1661 
1662     //! Deletes all the text in the text edit.
1663     virtual void clear();
1664 
1665     //! Copies any selected text to the clipboard.
1666     //!
1667     //! \sa copyAvailable(), cut(), paste()
1668     virtual void copy();
1669 
1670     //! Copies any selected text to the clipboard and then deletes the text.
1671     //!
1672     //! \sa copy(), paste()
1673     virtual void cut();
1674 
1675     //! Ensures that the cursor is visible.
1676     virtual void ensureCursorVisible();
1677 
1678     //! Ensures that the line number \a line is visible.
1679     virtual void ensureLineVisible(int line);
1680 
1681     //! If any lines are currently folded then they are all unfolded.
1682     //! Otherwise all lines are folded.  This has the same effect as clicking
1683     //! in the fold margin with the shift and control keys pressed.  If
1684     //! \a children is not set (the default) then only the top level fold
1685     //! points are affected, otherwise the state of all fold points are
1686     //! changed.
1687     virtual void foldAll(bool children = false);
1688 
1689     //! If the line \a line is folded then it is unfolded.  Otherwise it is
1690     //! folded.  This has the same effect as clicking in the fold margin.
1691     virtual void foldLine(int line);
1692 
1693     //! Increases the indentation of line \a line by an indentation width.
1694     //!
1695     //! \sa unindent()
1696     virtual void indent(int line);
1697 
1698     //! Insert the text \a text at the current position.
1699     virtual void insert(const QString &text);
1700 
1701     //! Insert the text \a text in the line \a line at the position
1702     //! \a index.
1703     virtual void insertAt(const QString &text, int line, int index);
1704 
1705     //! If the cursor is either side of a brace character then move it to the
1706     //! position of the corresponding brace.
1707     virtual void moveToMatchingBrace();
1708 
1709     //! Pastes any text from the clipboard into the text edit at the current
1710     //! cursor position.
1711     //!
1712     //! \sa copy(), cut()
1713     virtual void paste();
1714 
1715     //! Redo the last change or sequence of changes.
1716     //!
1717     //! \sa isRedoAvailable()
1718     virtual void redo();
1719 
1720     //! Removes any selected text.
1721     //!
1722     //! \sa replaceSelectedText()
1723     virtual void removeSelectedText();
1724 
1725     //! Replaces any selected text with \a text.
1726     //!
1727     //! \sa removeSelectedText()
1728     virtual void replaceSelectedText(const QString &text);
1729 
1730     //! Resets the background colour of selected text to the default.
1731     //!
1732     //! \sa setSelectionBackgroundColor(), resetSelectionForegroundColor()
1733     virtual void resetSelectionBackgroundColor();
1734 
1735     //! Resets the foreground colour of selected text to the default.
1736     //!
1737     //! \sa setSelectionForegroundColor(), resetSelectionBackgroundColor()
1738     virtual void resetSelectionForegroundColor();
1739 
1740     //! If \a select is true (the default) then all the text is selected.  If
1741     //! \a select is false then any currently selected text is deselected.
1742     virtual void selectAll(bool select = true);
1743 
1744     //! If the cursor is either side of a brace character then move it to the
1745     //! position of the corresponding brace and select the text between the
1746     //! braces.
1747     virtual void selectToMatchingBrace();
1748 
1749     //! If \a cs is true then auto-completion lists are case sensitive.  The
1750     //! default is true.  Note that setting a lexer may change the case
1751     //! sensitivity.
1752     //!
1753     //! \sa autoCompletionCaseSensitivity()
1754     virtual void setAutoCompletionCaseSensitivity(bool cs);
1755 
1756     //! If \a replace is true then when an item from an auto-completion list is
1757     //! selected, the rest of the word to the right of the current cursor is
1758     //! removed.  The default is false.
1759     //!
1760     //! \sa autoCompletionReplaceWord()
1761     virtual void setAutoCompletionReplaceWord(bool replace);
1762 
1763     //! If \a single is true then when there is only a single entry in an
1764     //! auto-completion list it is automatically used and the list is not
1765     //! displayed.  This only has an effect when auto-completion is explicitly
1766     //! requested (using autoCompleteFromAPIs() and autoCompleteFromDocument())
1767     //! and has no effect when auto-completion is triggered as the user types.
1768     //! The default is false.  Note that this is deprecated and
1769     //! setAutoCompletionUseSingle() should be used instead.
1770     //!
1771     //! \sa autoCompletionShowSingle()
1772     virtual void setAutoCompletionShowSingle(bool single);
1773 
1774     //! Sets the source for the auto-completion list when it is being displayed
1775     //! automatically as the user types to \a source.  The default is AcsNone,
1776     //! ie. it is disabled.
1777     //!
1778     //! \sa autoCompletionSource()
1779     virtual void setAutoCompletionSource(AutoCompletionSource source);
1780 
1781     //! Sets the threshold for the automatic display of the auto-completion
1782     //! list as the user types to \a thresh.  The threshold is the number of
1783     //! characters that the user must type before the list is displayed.  If
1784     //! the threshold is less than or equal to 0 then the list is disabled.
1785     //! The default is -1.
1786     //!
1787     //! \sa autoCompletionThreshold(), setAutoCompletionWordSeparators()
1788     virtual void setAutoCompletionThreshold(int thresh);
1789 
1790     //! Sets the behavior of the auto-completion list when it has a single
1791     //! entry.  The default is AcusNever.
1792     //!
1793     //! \sa autoCompletionUseSingle()
1794     virtual void setAutoCompletionUseSingle(AutoCompletionUseSingle single);
1795 
1796     //! If \a autoindent is true then auto-indentation is enabled.  The default
1797     //! is false.
1798     //!
1799     //! \sa autoIndent()
1800     virtual void setAutoIndent(bool autoindent);
1801 
1802     //! Sets the brace matching mode to \a bm.  The default is NoBraceMatching.
1803     //!
1804     //! \sa braceMatching()
1805     virtual void setBraceMatching(BraceMatch bm);
1806 
1807     //! If \a deindent is true then the backspace key will unindent a line
1808     //! rather then delete a character.
1809     //!
1810     //! \sa backspaceUnindents(), tabIndents(), setTabIndents()
1811     virtual void setBackspaceUnindents(bool unindent);
1812 
1813     //! Sets the foreground colour of the caret to \a col.
1814     virtual void setCaretForegroundColor(const QColor &col);
1815 
1816     //! Sets the background colour, including the alpha component, of the line
1817     //! containing the caret to \a col.
1818     //!
1819     //! \sa setCaretLineVisible()
1820     virtual void setCaretLineBackgroundColor(const QColor &col);
1821 
1822     //! Sets the width of the frame of the line containing the caret to \a
1823     //! width.
1824     virtual void setCaretLineFrameWidth(int width);
1825 
1826     //! Enables or disables, according to \a enable, the background color of
1827     //! the line containing the caret.
1828     //!
1829     //! \sa setCaretLineBackgroundColor()
1830     virtual void setCaretLineVisible(bool enable);
1831 
1832     //! Sets the width of the caret to \a width pixels.  A \a width of 0 makes
1833     //! the caret invisible.
1834     virtual void setCaretWidth(int width);
1835 
1836     //! The widget's text (ie. foreground) colour is set to \a c.  This has no
1837     //! effect if a language lexer has been set.
1838     //!
1839     //! \sa color()
1840     virtual void setColor(const QColor &c);
1841 
1842     //! Sets the cursor to the line \a line at the position \a index.
1843     //!
1844     //! \sa getCursorPosition()
1845     virtual void setCursorPosition(int line, int index);
1846 
1847     //! Sets the end-of-line mode to \a mode.  The default is the platform's
1848     //! natural mode.
1849     //!
1850     //! \sa eolMode()
1851     virtual void setEolMode(EolMode mode);
1852 
1853     //! If \a visible is true then end-of-lines are made visible.  The default
1854     //! is that they are invisible.
1855     //!
1856     //! \sa eolVisibility()
1857     virtual void setEolVisibility(bool visible);
1858 
1859     //! Sets the folding style for margin \a margin to \a fold.  The default
1860     //! style is NoFoldStyle (ie. folding is disabled) and the default margin
1861     //! is 2.
1862     //!
1863     //! \sa folding()
1864     virtual void setFolding(FoldStyle fold, int margin = 2);
1865 
1866     //! Sets the indentation of line \a line to \a indentation characters.
1867     //!
1868     //! \sa indentation()
1869     virtual void setIndentation(int line, int indentation);
1870 
1871     //! Enables or disables, according to \a enable, this display of
1872     //! indentation guides.
1873     //!
1874     //! \sa indentationGuides()
1875     virtual void setIndentationGuides(bool enable);
1876 
1877     //! Set the background colour of indentation guides to \a col.
1878     //!
1879     //! \sa setIndentationGuidesForegroundColor()
1880     virtual void setIndentationGuidesBackgroundColor(const QColor &col);
1881 
1882     //! Set the foreground colour of indentation guides to \a col.
1883     //!
1884     //! \sa setIndentationGuidesBackgroundColor()
1885     virtual void setIndentationGuidesForegroundColor(const QColor &col);
1886 
1887     //! If \a tabs is true then indentations are created using tabs and spaces,
1888     //! rather than just spaces.
1889     //!
1890     //! \sa indentationsUseTabs()
1891     virtual void setIndentationsUseTabs(bool tabs);
1892 
1893     //! Sets the indentation width to \a width characters.  If \a width is 0
1894     //! then the value returned by tabWidth() is used.
1895     //!
1896     //! \sa indentationWidth(), tabWidth()
1897     virtual void setIndentationWidth(int width);
1898 
1899     //! Sets the specific language lexer used to style text to \a lex.  If
1900     //! \a lex is 0 then syntax styling is disabled.
1901     //!
1902     //! \sa lexer()
1903     virtual void setLexer(QsciLexer *lexer = 0);
1904 
1905     //! Set the background colour of all margins to \a col.  The default is a
1906     //! gray.
1907     //!
1908     //! \sa setMarginsForegroundColor()
1909     virtual void setMarginsBackgroundColor(const QColor &col);
1910 
1911     //! Set the font used in all margins to \a f.
1912     virtual void setMarginsFont(const QFont &f);
1913 
1914     //! Set the foreground colour of all margins to \a col.  The default is
1915     //! black.
1916     //!
1917     //! \sa setMarginsBackgroundColor()
1918     virtual void setMarginsForegroundColor(const QColor &col);
1919 
1920     //! Enables or disables, according to \a lnrs, the display of line numbers
1921     //! in margin \a margin.
1922     //!
1923     //! \sa marginLineNumbers(), setMarginType(), SCI_SETMARGINTYPEN
1924     virtual void setMarginLineNumbers(int margin, bool lnrs);
1925 
1926     //! Sets the marker mask of margin \a margin to \a mask.  Only those
1927     //! markers whose bit is set in the mask are displayed in the margin.
1928     //!
1929     //! \sa marginMarkerMask(), QsciMarker, SCI_SETMARGINMASKN
1930     virtual void setMarginMarkerMask(int margin, int mask);
1931 
1932     //! Enables or disables, according to \a sens, the sensitivity of margin
1933     //! \a margin to mouse clicks.  If the user clicks in a sensitive margin
1934     //! the marginClicked() signal is emitted.
1935     //!
1936     //! \sa marginSensitivity(), marginClicked(), SCI_SETMARGINSENSITIVEN
1937     virtual void setMarginSensitivity(int margin, bool sens);
1938 
1939     //! Sets the width of margin \a margin to \a width pixels.  If the width of
1940     //! a margin is 0 then it is not displayed.
1941     //!
1942     //! \sa marginWidth(), SCI_SETMARGINWIDTHN
1943     virtual void setMarginWidth(int margin, int width);
1944 
1945     //! Sets the width of margin \a margin so that it is wide enough to display
1946     //! \a s in the current margin font.
1947     //!
1948     //! \sa marginWidth(), SCI_SETMARGINWIDTHN
1949     virtual void setMarginWidth(int margin, const QString &s);
1950 
1951     //! Sets the modified state of the text edit to \a m.  Note that it is only
1952     //! possible to clear the modified state (where \a m is false).  Attempts
1953     //! to set the modified state (where \a m is true) are ignored.
1954     //!
1955     //! \sa isModified(), modificationChanged()
1956     virtual void setModified(bool m);
1957 
1958     //! The widget's paper (ie. background) colour is set to \a c.  This has no
1959     //! effect if a language lexer has been set.
1960     //!
1961     //! \sa paper()
1962     virtual void setPaper(const QColor &c);
1963 
1964     //! Sets the read-only state of the text edit to \a ro.
1965     //!
1966     //! \sa isReadOnly()
1967     virtual void setReadOnly(bool ro);
1968 
1969     //! Sets the selection which starts at position \a indexFrom in line
1970     //! \a lineFrom and ends at position \a indexTo in line \a lineTo.  The
1971     //! cursor is moved to position \a indexTo in \a lineTo.
1972     //!
1973     //! \sa getSelection()
1974     virtual void setSelection(int lineFrom, int indexFrom, int lineTo,
1975             int indexTo);
1976 
1977     //! Sets the background colour, including the alpha component, of selected
1978     //! text to \a col.
1979     //!
1980     //! \sa resetSelectionBackgroundColor(), setSelectionForegroundColor()
1981     virtual void setSelectionBackgroundColor(const QColor &col);
1982 
1983     //! Sets the foreground colour of selected text to \a col.
1984     //!
1985     //! \sa resetSelectionForegroundColor(), setSelectionBackgroundColor()
1986     virtual void setSelectionForegroundColor(const QColor &col);
1987 
1988     //! If \a indent is true then the tab key will indent a line rather than
1989     //! insert a tab character.
1990     //!
1991     //! \sa tabIndents(), backspaceUnindents(), setBackspaceUnindents()
1992     virtual void setTabIndents(bool indent);
1993 
1994     //! Sets the tab width to \a width characters.
1995     //!
1996     //! \sa tabWidth()
1997     virtual void setTabWidth(int width);
1998 
1999     //! Replaces all of the current text with \a text.  Note that the
2000     //! undo/redo history is cleared by this function.
2001     //!
2002     //! \sa text()
2003     virtual void setText(const QString &text);
2004 
2005     //! Sets the current text encoding.  If \a cp is true then UTF8 is used,
2006     //! otherwise Latin1 is used.
2007     //!
2008     //! \sa isUtf8()
2009     virtual void setUtf8(bool cp);
2010 
2011     //! Sets the visibility of whitespace to mode \a mode.  The default is that
2012     //! whitespace is invisible.
2013     //!
2014     //! \sa whitespaceVisibility()
2015     virtual void setWhitespaceVisibility(WhitespaceVisibility mode);
2016 
2017     //! Sets the line wrap mode to \a mode.  The default is that lines are not
2018     //! wrapped.
2019     //!
2020     //! \sa wrapMode()
2021     virtual void setWrapMode(WrapMode mode);
2022 
2023     //! Undo the last change or sequence of changes.
2024     //!
2025     //! Scintilla has multiple level undo and redo.  It will continue to record
2026     //! undoable actions until memory runs out.  Sequences of typing or
2027     //! deleting are compressed into single actions to make it easier to undo
2028     //! and redo at a sensible level of detail.  Sequences of actions can be
2029     //! combined into actions that are undone as a unit.  These sequences occur
2030     //! between calls to beginUndoAction() and endUndoAction().  These
2031     //! sequences can be nested and only the top level sequences are undone as
2032     //! units.
2033     //!
2034     //! \sa beginUndoAction(), endUndoAction(), isUndoAvailable()
2035     virtual void undo();
2036 
2037     //! Decreases the indentation of line \a line by an indentation width.
2038     //!
2039     //! \sa indent()
2040     virtual void unindent(int line);
2041 
2042     //! Zooms in on the text by by making the base font size \a range points
2043     //! larger and recalculating all font sizes.
2044     //!
2045     //! \sa zoomOut(), zoomTo()
2046     virtual void zoomIn(int range);
2047 
2048     //! \overload
2049     //!
2050     //! Zooms in on the text by by making the base font size one point larger
2051     //! and recalculating all font sizes.
2052     virtual void zoomIn();
2053 
2054     //! Zooms out on the text by by making the base font size \a range points
2055     //! smaller and recalculating all font sizes.
2056     //!
2057     //! \sa zoomIn(), zoomTo()
2058     virtual void zoomOut(int range);
2059 
2060     //! \overload
2061     //!
2062     //! Zooms out on the text by by making the base font size one point larger
2063     //! and recalculating all font sizes.
2064     virtual void zoomOut();
2065 
2066     //! Zooms the text by making the base font size \a size points and
2067     //! recalculating all font sizes.
2068     //!
2069     //! \sa zoomIn(), zoomOut()
2070     virtual void zoomTo(int size);
2071 
2072 signals:
2073     //! This signal is emitted whenever the cursor position changes.  \a line
2074     //! contains the line number and \a index contains the character index
2075     //! within the line.
2076     void cursorPositionChanged(int line, int index);
2077 
2078     //! This signal is emitted whenever text is selected or de-selected.
2079     //! \a yes is true if text has been selected and false if text has been
2080     //! deselected.  If \a yes is true then copy() can be used to copy the
2081     //! selection to the clipboard.  If \a yes is false then copy() does
2082     //! nothing.
2083     //!
2084     //! \sa copy(), selectionChanged()
2085     void copyAvailable(bool yes);
2086 
2087     //! This signal is emitted whenever the user clicks on an indicator.  \a
2088     //! line is the number of the line where the user clicked.  \a index is the
2089     //! character index within the line.  \a state is the state of the modifier
2090     //! keys (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and
2091     //! Qt::MetaModifier) when the user clicked.
2092     //!
2093     //! \sa indicatorReleased()
2094     void indicatorClicked(int line, int index, Qt::KeyboardModifiers state);
2095 
2096     //! This signal is emitted whenever the user releases the mouse on an
2097     //! indicator.  \a line is the number of the line where the user clicked.
2098     //! \a index is the character index within the line.  \a state is the state
2099     //! of the modifier keys (Qt::ShiftModifier, Qt::ControlModifier,
2100     //! Qt::AltModifer and Qt::MetaModifier) when the user released the mouse.
2101     //!
2102     //! \sa indicatorClicked()
2103     void indicatorReleased(int line, int index, Qt::KeyboardModifiers state);
2104 
2105     //! This signal is emitted whenever the number of lines of text changes.
2106     void linesChanged();
2107 
2108     //! This signal is emitted whenever the user clicks on a sensitive margin.
2109     //! \a margin is the margin.  \a line is the number of the line where the
2110     //! user clicked.  \a state is the state of the modifier keys
2111     //! (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and
2112     //! Qt::MetaModifier) when the user clicked.
2113     //!
2114     //! \sa marginSensitivity(), setMarginSensitivity()
2115     void marginClicked(int margin, int line, Qt::KeyboardModifiers state);
2116 
2117     //! This signal is emitted whenever the user right-clicks on a sensitive
2118     //! margin.  \a margin is the margin.  \a line is the number of the line
2119     //! where the user clicked.  \a state is the state of the modifier keys
2120     //! (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and
2121     //! Qt::MetaModifier) when the user clicked.
2122     //!
2123     //! \sa marginSensitivity(), setMarginSensitivity()
2124     void marginRightClicked(int margin, int line, Qt::KeyboardModifiers state);
2125 
2126     //! This signal is emitted whenever the user attempts to modify read-only
2127     //! text.
2128     //!
2129     //! \sa isReadOnly(), setReadOnly()
2130     void modificationAttempted();
2131 
2132     //! This signal is emitted whenever the modification state of the text
2133     //! changes.  \a m is true if the text has been modified.
2134     //!
2135     //! \sa isModified(), setModified()
2136     void modificationChanged(bool m);
2137 
2138     //! This signal is emitted whenever the selection changes.
2139     //!
2140     //! \sa copyAvailable()
2141     void selectionChanged();
2142 
2143     //! This signal is emitted whenever the text in the text edit changes.
2144     void textChanged();
2145 
2146     //! This signal is emitted when an item in a user defined list is activated
2147     //! (selected).  \a id is the list identifier.  \a string is the text of
2148     //! the item.
2149     //!
2150     //! \sa showUserList()
2151     void userListActivated(int id, const QString &string);
2152 
2153 protected:
2154     //! \reimp
2155     virtual bool event(QEvent *e);
2156 
2157     //! \reimp
2158     virtual void changeEvent(QEvent *e);
2159 
2160     //! \reimp
2161     virtual void contextMenuEvent(QContextMenuEvent *e);
2162 
2163     //! \reimp
2164     virtual void wheelEvent(QWheelEvent *e);
2165 
2166 private slots:
2167     void handleCallTipClick(int dir);
2168     void handleCharAdded(int charadded);
2169     void handleIndicatorClick(int pos, int modifiers);
2170     void handleIndicatorRelease(int pos, int modifiers);
2171     void handleMarginClick(int pos, int margin, int modifiers);
2172     void handleMarginRightClick(int pos, int margin, int modifiers);
2173     void handleModified(int pos, int mtype, const char *text, int len,
2174             int added, int line, int foldNow, int foldPrev, int token,
2175             int annotationLinesAdded);
2176     void handlePropertyChange(const char *prop, const char *val);
2177     void handleSavePointReached();
2178     void handleSavePointLeft();
2179     void handleSelectionChanged(bool yes);
2180     void handleAutoCompletionSelection();
2181     void handleUserListSelection(const char *text, int id);
2182 
2183     void handleStyleColorChange(const QColor &c, int style);
2184     void handleStyleEolFillChange(bool eolfill, int style);
2185     void handleStyleFontChange(const QFont &f, int style);
2186     void handleStylePaperChange(const QColor &c, int style);
2187 
2188     void handleUpdateUI(int updated);
2189 
2190     void delete_selection();
2191 
2192 private:
2193     void detachLexer();
2194 
2195     enum IndentState {
2196         isNone,
2197         isKeywordStart,
2198         isBlockStart,
2199         isBlockEnd
2200     };
2201 
2202     void maintainIndentation(char ch, long pos);
2203     void autoIndentation(char ch, long pos);
2204     void autoIndentLine(long pos, int line, int indent);
2205     int blockIndent(int line);
2206     IndentState getIndentState(int line);
2207     bool rangeIsWhitespace(long spos, long epos);
2208     int findStyledWord(const char *text, int style, const char *words);
2209 
2210     void checkMarker(int &markerNumber);
2211     void checkIndicator(int &indicatorNumber);
2212     static void allocateId(int &id, unsigned &allocated, int min, int max);
2213     int currentIndent() const;
2214     int indentWidth() const;
2215     bool doFind();
2216     int simpleFind();
2217     void foldClick(int lineClick, int bstate);
2218     void foldChanged(int line, int levelNow, int levelPrev);
2219     void foldExpand(int &line, bool doExpand, bool force = false,
2220             int visLevels = 0, int level = -1);
2221     void setFoldMarker(int marknr, int mark = SC_MARK_EMPTY);
2222     void setLexerStyle(int style);
2223     void setStylesFont(const QFont &f, int style);
2224     void setEnabledColors(int style, QColor &fore, QColor &back);
2225 
2226     void braceMatch();
2227     long checkBrace(long pos, int brace_style, bool &colonMode);
2228     void gotoMatchingBrace(bool select);
2229 
2230     void startAutoCompletion(AutoCompletionSource acs, bool checkThresh,
2231             bool choose_single);
2232 
2233     int adjustedCallTipPosition(int ctshift) const;
2234     bool getSeparator(int &pos) const;
2235     QString getWord(int &pos) const;
2236     char getCharacter(int &pos) const;
2237     bool isStartChar(char ch) const;
2238 
2239     bool ensureRW();
2240     void insertAtPos(const QString &text, int pos);
2241     static int mapModifiers(int modifiers);
2242 
2243     QString wordAtPosition(int position) const;
2244 
2245     ScintillaBytes styleText(const QList<QsciStyledText> &styled_text,
2246             char **styles, int style_offset = 0);
2247 
2248     struct FindState
2249     {
2250         enum Status
2251         {
2252             Finding,
2253             FindingInSelection,
2254             Idle
2255         };
2256 
FindStateFindState2257         FindState() : status(Idle) {}
2258 
2259         Status status;
2260         QString expr;
2261         bool wrap;
2262         bool forward;
2263         int flags;
2264         long startpos, startpos_orig;
2265         long endpos, endpos_orig;
2266         bool show;
2267     };
2268 
2269     FindState findState;
2270 
2271     unsigned allocatedMarkers;
2272     unsigned allocatedIndicators;
2273     int oldPos;
2274     int ctPos;
2275     bool selText;
2276     FoldStyle fold;
2277     int foldmargin;
2278     bool autoInd;
2279     BraceMatch braceMode;
2280     AutoCompletionSource acSource;
2281     int acThresh;
2282     QStringList wseps;
2283     const char *wchars;
2284     CallTipsPosition call_tips_position;
2285     CallTipsStyle call_tips_style;
2286     int maxCallTips;
2287     QStringList ct_entries;
2288     int ct_cursor;
2289     QList<int> ct_shifts;
2290     AutoCompletionUseSingle use_single;
2291     QPointer<QsciLexer> lex;
2292     QsciCommandSet *stdCmds;
2293     QsciDocument doc;
2294     QColor nl_text_colour;
2295     QColor nl_paper_colour;
2296     QByteArray explicit_fillups;
2297     bool fillups_enabled;
2298 
2299     // The following allow QsciListBoxQt to distinguish between an
2300     // auto-completion list and a user list, and to return the full selection
2301     // of an auto-completion list.
2302     friend class QsciListBoxQt;
2303 
2304     QString acSelection;
2305     bool isAutoCompletionList() const;
2306 
2307     void set_shortcut(QAction *action, QsciCommand::Command cmd_id) const;
2308 
2309     QsciScintilla(const QsciScintilla &);
2310     QsciScintilla &operator=(const QsciScintilla &);
2311 };
2312 
2313 #endif
2314