1 // This module defines the "official" high-level API of the Qt port of 2 // Scintilla. 3 // 4 // Copyright (c) 2019 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 //! Returns the number of the first visible line. 846 //! 847 //! \sa setFirstVisibleLine() 848 int firstVisibleLine() const; 849 850 //! Returns the current folding style. 851 //! 852 //! \sa setFolding() folding()853 FoldStyle folding() const {return fold;} 854 855 //! Sets \a *line and \a *index to the line and index of the cursor. 856 //! 857 //! \sa setCursorPosition() 858 void getCursorPosition(int *line, int *index) const; 859 860 //! If there is a selection, \a *lineFrom is set to the line number in 861 //! which the selection begins and \a *lineTo is set to the line number in 862 //! which the selection ends. (They could be the same.) \a *indexFrom is 863 //! set to the index at which the selection begins within \a *lineFrom, and 864 //! \a *indexTo is set to the index at which the selection ends within 865 //! \a *lineTo. If there is no selection, \a *lineFrom, \a *indexFrom, 866 //! \a *lineTo and \a *indexTo are all set to -1. 867 //! 868 //! \sa setSelection() 869 void getSelection(int *lineFrom, int *indexFrom, int *lineTo, 870 int *indexTo) const; 871 872 //! Returns true if some text is selected. 873 //! 874 //! \sa selectedText() hasSelectedText()875 bool hasSelectedText() const {return selText;} 876 877 //! Returns the number of characters that line \a line is indented by. 878 //! 879 //! \sa setIndentation() 880 int indentation(int line) const; 881 882 //! Returns true if the display of indentation guides is enabled. 883 //! 884 //! \sa setIndentationGuides() 885 bool indentationGuides() const; 886 887 //! Returns true if indentations are created using tabs and spaces, rather 888 //! than just spaces. The default is true. 889 //! 890 //! \sa setIndentationsUseTabs() 891 bool indentationsUseTabs() const; 892 893 //! Returns the indentation width in characters. The default is 0 which 894 //! means that the value returned by tabWidth() is actually used. 895 //! 896 //! \sa setIndentationWidth(), tabWidth() 897 int indentationWidth() const; 898 899 //! Define a type of indicator using the style \a style with the indicator 900 //! number \a indicatorNumber. If \a indicatorNumber is -1 then the 901 //! indicator number is automatically allocated. The indicator number is 902 //! returned or -1 if too many types of indicator have been defined. 903 //! 904 //! Indicators are used to display additional information over the top of 905 //! styling. They can be used to show, for example, syntax errors, 906 //! deprecated names and bad indentation by drawing lines under text or 907 //! boxes around text. 908 //! 909 //! There may be up to 32 types of indicator defined at a time. The first 910 //! 8 are normally used by lexers. By default indicator number 0 is a 911 //! dark green SquiggleIndicator, 1 is a blue TTIndicator, and 2 is a red 912 //! PlainIndicator. 913 int indicatorDefine(IndicatorStyle style, int indicatorNumber = -1); 914 915 //! Returns true if the indicator \a indicatorNumber is drawn under the 916 //! text (i.e. in the background). The default is false. 917 //! 918 //! \sa setIndicatorDrawUnder() 919 bool indicatorDrawUnder(int indicatorNumber) const; 920 921 //! Returns true if a call tip is currently active. 922 bool isCallTipActive() const; 923 924 //! Returns true if an auto-completion or user defined list is currently 925 //! active. 926 bool isListActive() const; 927 928 //! Returns true if the text has been modified. 929 //! 930 //! \sa setModified(), modificationChanged() 931 bool isModified() const; 932 933 //! Returns true if the text edit is read-only. 934 //! 935 //! \sa setReadOnly() 936 bool isReadOnly() const; 937 938 //! Returns true if there is something that can be redone. 939 //! 940 //! \sa redo() 941 bool isRedoAvailable() const; 942 943 //! Returns true if there is something that can be undone. 944 //! 945 //! \sa undo() 946 bool isUndoAvailable() const; 947 948 //! Returns true if text is interpreted as being UTF8 encoded. The default 949 //! is to interpret the text as Latin1 encoded. 950 //! 951 //! \sa setUtf8() 952 bool isUtf8() const; 953 954 //! Returns true if character \a ch is a valid word character. 955 //! 956 //! \sa wordCharacters() 957 bool isWordCharacter(char ch) const; 958 959 //! Returns the line which is at \a point pixel coordinates or -1 if there 960 //! is no line at that point. 961 int lineAt(const QPoint &point) const; 962 963 //! QScintilla uses the combination of a line number and a character index 964 //! from the start of that line to specify the position of a character 965 //! within the text. The underlying Scintilla instead uses a byte index 966 //! from the start of the text. This will convert the \a position byte 967 //! index to the \a *line line number and \a *index character index. 968 //! 969 //! \sa positionFromLineIndex() 970 void lineIndexFromPosition(int position, int *line, int *index) const; 971 972 //! Returns the length of line \a line int bytes or -1 if there is no such 973 //! line. In order to get the length in characters use text(line).length(). 974 int lineLength(int line) const; 975 976 //! Returns the number of lines of text. 977 int lines() const; 978 979 //! Returns the length of the text edit's text in bytes. In order to get 980 //! the length in characters use text().length(). 981 int length() const; 982 983 //! Returns the current language lexer used to style text. If it is 0 then 984 //! syntax styling is disabled. 985 //! 986 //! \sa setLexer() 987 QsciLexer *lexer() const; 988 989 //! Returns the background color of margin \a margin. 990 //! 991 //! \sa setMarginBackgroundColor() 992 QColor marginBackgroundColor(int margin) const; 993 994 //! Returns true if line numbers are enabled for margin \a margin. 995 //! 996 //! \sa setMarginLineNumbers(), marginType(), SCI_GETMARGINTYPEN 997 bool marginLineNumbers(int margin) const; 998 999 //! Returns the marker mask of margin \a margin. 1000 //! 1001 //! \sa setMarginMask(), QsciMarker, SCI_GETMARGINMASKN 1002 int marginMarkerMask(int margin) const; 1003 1004 //! Returns the margin options. The default is MoNone. 1005 //! 1006 //! \sa setMarginOptions(), MoNone, MoSublineSelect. 1007 int marginOptions() const; 1008 1009 //! Returns true if margin \a margin is sensitive to mouse clicks. 1010 //! 1011 //! \sa setMarginSensitivity(), marginClicked(), SCI_GETMARGINTYPEN 1012 bool marginSensitivity(int margin) const; 1013 1014 //! Returns the type of margin \a margin. 1015 //! 1016 //! \sa setMarginType(), SCI_GETMARGINTYPEN 1017 MarginType marginType(int margin) const; 1018 1019 //! Returns the width in pixels of margin \a margin. 1020 //! 1021 //! \sa setMarginWidth(), SCI_GETMARGINWIDTHN 1022 int marginWidth(int margin) const; 1023 1024 //! Returns the number of margins. 1025 //! 1026 //! \sa setMargins() 1027 int margins() const; 1028 1029 //! Define a type of marker using the symbol \a sym with the marker number 1030 //! \a markerNumber. If \a markerNumber is -1 then the marker number is 1031 //! automatically allocated. The marker number is returned or -1 if too 1032 //! many types of marker have been defined. 1033 //! 1034 //! Markers are small geometric symbols and characters used, for example, 1035 //! to indicate the current line or, in debuggers, to indicate breakpoints. 1036 //! If a margin has a width of 0 then its markers are not drawn, but their 1037 //! background colours affect the background colour of the corresponding 1038 //! line of text. 1039 //! 1040 //! There may be up to 32 types of marker defined at a time and each line 1041 //! of text has a set of marker instances associated with it. Markers are 1042 //! drawn according to their numerical identifier. Markers try to move 1043 //! with their text by tracking where the start of their line moves to. 1044 //! For example, when a line is deleted its markers are added to previous 1045 //! line's markers. 1046 //! 1047 //! Each marker type is identified by a marker number. Each instance of a 1048 //! marker is identified by a marker handle. 1049 int markerDefine(MarkerSymbol sym, int markerNumber = -1); 1050 1051 //! Define a marker using the character \a ch with the marker number 1052 //! \a markerNumber. If \a markerNumber is -1 then the marker number is 1053 //! automatically allocated. The marker number is returned or -1 if too 1054 //! many markers have been defined. 1055 int markerDefine(char ch, int markerNumber = -1); 1056 1057 //! Define a marker using a copy of the pixmap \a pm with the marker number 1058 //! \a markerNumber. If \a markerNumber is -1 then the marker number is 1059 //! automatically allocated. The marker number is returned or -1 if too 1060 //! many markers have been defined. 1061 int markerDefine(const QPixmap &pm, int markerNumber = -1); 1062 1063 //! Define a marker using a copy of the image \a im with the marker number 1064 //! \a markerNumber. If \a markerNumber is -1 then the marker number is 1065 //! automatically allocated. The marker number is returned or -1 if too 1066 //! many markers have been defined. 1067 int markerDefine(const QImage &im, int markerNumber = -1); 1068 1069 //! Add an instance of marker number \a markerNumber to line number 1070 //! \a linenr. A handle for the marker is returned which can be used to 1071 //! track the marker's position, or -1 if the \a markerNumber was invalid. 1072 //! 1073 //! \sa markerDelete(), markerDeleteAll(), markerDeleteHandle() 1074 int markerAdd(int linenr, int markerNumber); 1075 1076 //! Returns the 32 bit mask of marker numbers at line number \a linenr. 1077 //! 1078 //! \sa markerAdd() 1079 unsigned markersAtLine(int linenr) const; 1080 1081 //! Delete all markers with the marker number \a markerNumber in the line 1082 //! \a linenr. If \a markerNumber is -1 then delete all markers from line 1083 //! \a linenr. 1084 //! 1085 //! \sa markerAdd(), markerDeleteAll(), markerDeleteHandle() 1086 void markerDelete(int linenr, int markerNumber = -1); 1087 1088 //! Delete the all markers with the marker number \a markerNumber. If 1089 //! \a markerNumber is -1 then delete all markers. 1090 //! 1091 //! \sa markerAdd(), markerDelete(), markerDeleteHandle() 1092 void markerDeleteAll(int markerNumber = -1); 1093 1094 //! Delete the the marker instance with the marker handle \a mhandle. 1095 //! 1096 //! \sa markerAdd(), markerDelete(), markerDeleteAll() 1097 void markerDeleteHandle(int mhandle); 1098 1099 //! Return the line number that contains the marker instance with the 1100 //! marker handle \a mhandle. 1101 int markerLine(int mhandle) const; 1102 1103 //! Return the number of the next line to contain at least one marker from 1104 //! a 32 bit mask of markers. \a linenr is the line number to start the 1105 //! search from. \a mask is the mask of markers to search for. 1106 //! 1107 //! \sa markerFindPrevious() 1108 int markerFindNext(int linenr, unsigned mask) const; 1109 1110 //! Return the number of the previous line to contain at least one marker 1111 //! from a 32 bit mask of markers. \a linenr is the line number to start 1112 //! the search from. \a mask is the mask of markers to search for. 1113 //! 1114 //! \sa markerFindNext() 1115 int markerFindPrevious(int linenr, unsigned mask) const; 1116 1117 //! Returns true if text entered by the user will overwrite existing text. 1118 //! 1119 //! \sa setOverwriteMode() 1120 bool overwriteMode() const; 1121 1122 //! Returns the widget's paper (ie. background) colour. 1123 //! 1124 //! \sa setPaper() 1125 QColor paper() const; 1126 1127 //! QScintilla uses the combination of a line number and a character index 1128 //! from the start of that line to specify the position of a character 1129 //! within the text. The underlying Scintilla instead uses a byte index 1130 //! from the start of the text. This will return the byte index 1131 //! corresponding to the \a line line number and \a index character index. 1132 //! 1133 //! \sa lineIndexFromPosition() 1134 int positionFromLineIndex(int line, int index) const; 1135 1136 //! Reads the current document from the \a io device and returns true if 1137 //! there was no error. 1138 //! 1139 //! \sa write() 1140 bool read(QIODevice *io); 1141 1142 //! Recolours the document between the \a start and \a end positions. 1143 //! \a start defaults to the start of the document and \a end defaults to 1144 //! the end of the document. 1145 virtual void recolor(int start = 0, int end = -1); 1146 1147 //! Register an image \a pm with ID \a id. Registered images can be 1148 //! displayed in auto-completion lists. 1149 //! 1150 //! \sa clearRegisteredImages(), QsciLexer::apiLoad() 1151 void registerImage(int id, const QPixmap &pm); 1152 1153 //! Register an image \a im with ID \a id. Registered images can be 1154 //! displayed in auto-completion lists. 1155 //! 1156 //! \sa clearRegisteredImages(), QsciLexer::apiLoad() 1157 void registerImage(int id, const QImage &im); 1158 1159 //! Replace the current selection, set by a previous call to findFirst(), 1160 //! findFirstInSelection() or findNext(), with \a replaceStr. 1161 //! 1162 //! \sa cancelFind(), findFirst(), findFirstInSelection(), findNext() 1163 virtual void replace(const QString &replaceStr); 1164 1165 //! Reset the fold margin colours to their defaults. 1166 //! 1167 //! \sa setFoldMarginColors() 1168 void resetFoldMarginColors(); 1169 1170 //! Resets the background colour of an active hotspot area to the default. 1171 //! 1172 //! \sa setHotspotBackgroundColor(), resetHotspotForegroundColor() 1173 void resetHotspotBackgroundColor(); 1174 1175 //! Resets the foreground colour of an active hotspot area to the default. 1176 //! 1177 //! \sa setHotspotForegroundColor(), resetHotspotBackgroundColor() 1178 void resetHotspotForegroundColor(); 1179 1180 //! Gets the assumed document width in pixels. 1181 //! 1182 //! \sa setScrollWidth(), setScrollWidthTracking() 1183 int scrollWidth() const; 1184 1185 //! Returns true if scroll width tracking is enabled. 1186 //! 1187 //! \sa scrollWidth(), setScrollWidthTracking() 1188 bool scrollWidthTracking() const; 1189 1190 //! The fold margin may be drawn as a one pixel sized checkerboard pattern 1191 //! of two colours, \a fore and \a back. 1192 //! 1193 //! \sa resetFoldMarginColors() 1194 void setFoldMarginColors(const QColor &fore, const QColor &back); 1195 1196 //! Set the display style for annotations. The default is 1197 //! AnnotationStandard. 1198 //! 1199 //! \sa annotationDisplay() 1200 void setAnnotationDisplay(AnnotationDisplay display); 1201 1202 //! Enable the use of fill-up characters, either those explicitly set or 1203 //! those set by a lexer. By default, fill-up characters are disabled. 1204 //! 1205 //! \sa autoCompletionFillupsEnabled(), setAutoCompletionFillups() 1206 void setAutoCompletionFillupsEnabled(bool enabled); 1207 1208 //! A fill-up character is one that, when entered while an auto-completion 1209 //! list is being displayed, causes the currently selected item from the 1210 //! list to be added to the text followed by the fill-up character. 1211 //! \a fillups is the set of fill-up characters. If a language lexer has 1212 //! been set then this is ignored and the lexer defines the fill-up 1213 //! characters. The default is that no fill-up characters are set. 1214 //! 1215 //! \sa autoCompletionFillupsEnabled(), setAutoCompletionFillupsEnabled() 1216 void setAutoCompletionFillups(const char *fillups); 1217 1218 //! A word separator is a sequence of characters that, when entered, causes 1219 //! the auto-completion list to be displayed. If a language lexer has been 1220 //! set then this is ignored and the lexer defines the word separators. 1221 //! The default is that no word separators are set. 1222 //! 1223 //! \sa setAutoCompletionThreshold() 1224 void setAutoCompletionWordSeparators(const QStringList &separators); 1225 1226 //! Set the background colour of call tips to \a col. The default is 1227 //! white. 1228 void setCallTipsBackgroundColor(const QColor &col); 1229 1230 //! Set the foreground colour of call tips to \a col. The default is 1231 //! mid-gray. 1232 void setCallTipsForegroundColor(const QColor &col); 1233 1234 //! Set the highlighted colour of call tip text to \a col. The default is 1235 //! dark blue. 1236 void setCallTipsHighlightColor(const QColor &col); 1237 1238 //! Set the current call tip position. The default is CallTipsBelowText. 1239 //! 1240 //! \sa callTipsPosition() 1241 void setCallTipsPosition(CallTipsPosition position); 1242 1243 //! Set the current call tip style. The default is CallTipsNoContext. 1244 //! 1245 //! \sa callTipsStyle() 1246 void setCallTipsStyle(CallTipsStyle style); 1247 1248 //! Set the maximum number of call tips that are displayed to \a nr. If 1249 //! the maximum number is 0 then all applicable call tips are displayed. 1250 //! If the maximum number is -1 then one call tip will be displayed with up 1251 //! and down arrows that allow the use to scroll through the full list. 1252 //! The default is -1. 1253 //! 1254 //! \sa callTipsVisible() 1255 void setCallTipsVisible(int nr); 1256 1257 //! Sets each line in the \a folds list of line numbers to be a contracted 1258 //! fold. This is typically used to restore the fold state of a document. 1259 //! 1260 //! \sa contractedFolds() 1261 void setContractedFolds(const QList<int> &folds); 1262 1263 //! Attach the document \a document, replacing the currently attached 1264 //! document. 1265 //! 1266 //! \sa document() 1267 void setDocument(const QsciDocument &document); 1268 1269 //! Add \a colnr to the columns which are displayed with a vertical line. 1270 //! The edge mode must be set to EdgeMultipleLines. 1271 //! 1272 //! \sa clearEdgeColumns() 1273 void addEdgeColumn(int colnr, const QColor &col); 1274 1275 //! Remove any columns added by previous calls to addEdgeColumn(). 1276 //! 1277 //! \sa addEdgeColumn() 1278 void clearEdgeColumns(); 1279 1280 //! Set the color of the marker used to show that a line has exceeded the 1281 //! length set by setEdgeColumn(). 1282 //! 1283 //! \sa edgeColor(), \sa setEdgeColumn 1284 void setEdgeColor(const QColor &col); 1285 1286 //! Set the number of the column after which lines are considered to be 1287 //! long. 1288 //! 1289 //! \sa edgeColumn() 1290 void setEdgeColumn(int colnr); 1291 1292 //! Set the edge mode which determines how long lines are marked. 1293 //! 1294 //! \sa edgeMode() 1295 void setEdgeMode(EdgeMode mode); 1296 1297 //! Set the number of the first visible line to \a linenr. 1298 //! 1299 //! \sa firstVisibleLine() 1300 void setFirstVisibleLine(int linenr); 1301 1302 //! Enables or disables, according to \a under, if the indicator 1303 //! \a indicatorNumber is drawn under or over the text (i.e. in the 1304 //! background or foreground). If \a indicatorNumber is -1 then the state 1305 //! of all indicators is set. 1306 //! 1307 //! \sa indicatorDrawUnder() 1308 void setIndicatorDrawUnder(bool under, int indicatorNumber = -1); 1309 1310 //! Set the foreground colour of indicator \a indicatorNumber to \a col. 1311 //! If \a indicatorNumber is -1 then the colour of all indicators is set. 1312 void setIndicatorForegroundColor(const QColor &col, int indicatorNumber = -1); 1313 1314 //! Set the foreground colour of indicator \a indicatorNumber to \a col 1315 //! when the mouse is over it or the caret moved into it. If 1316 //! \a indicatorNumber is -1 then the colour of all indicators is set. 1317 void setIndicatorHoverForegroundColor(const QColor &col, int indicatorNumber = -1); 1318 1319 //! Set the style of indicator \a indicatorNumber to \a style when the 1320 //! mouse is over it or the caret moved into it. If \a indicatorNumber is 1321 //! -1 then the style of all indicators is set. 1322 void setIndicatorHoverStyle(IndicatorStyle style, int indicatorNumber = -1); 1323 1324 //! Set the outline colour of indicator \a indicatorNumber to \a col. 1325 //! If \a indicatorNumber is -1 then the colour of all indicators is set. 1326 //! At the moment only the alpha value of the colour has any affect. 1327 void setIndicatorOutlineColor(const QColor &col, int indicatorNumber = -1); 1328 1329 //! Sets the background color of margin \a margin to \a col. 1330 //! 1331 //! \sa marginBackgroundColor() 1332 void setMarginBackgroundColor(int margin, const QColor &col); 1333 1334 //! Set the margin options to \a options. 1335 //! 1336 //! \sa marginOptions(), MoNone, MoSublineSelect. 1337 void setMarginOptions(int options); 1338 1339 //! Set the margin text of line \a line with the text \a text using the 1340 //! style number \a style. 1341 void setMarginText(int line, const QString &text, int style); 1342 1343 //! Set the margin text of line \a line with the text \a text using the 1344 //! style \a style. 1345 void setMarginText(int line, const QString &text, const QsciStyle &style); 1346 1347 //! Set the margin text of line \a line with the styled text \a text. 1348 void setMarginText(int line, const QsciStyledText &text); 1349 1350 //! Set the margin text of line \a line with the list of styled text \a 1351 //! text. 1352 void setMarginText(int line, const QList<QsciStyledText> &text); 1353 1354 //! Set the type of margin \a margin to type \a type. 1355 //! 1356 //! \sa marginType(), SCI_SETMARGINTYPEN 1357 void setMarginType(int margin, MarginType type); 1358 1359 //! The margin text on line \a line is removed. If \a line is negative 1360 //! then all margin text is removed. 1361 void clearMarginText(int line = -1); 1362 1363 //! Set the number of margins to \a margins. 1364 //! 1365 //! \sa margins() 1366 void setMargins(int margins); 1367 1368 //! Set the background colour, including the alpha component, of marker 1369 //! \a markerNumber to \a col. If \a markerNumber is -1 then the colour of 1370 //! all markers is set. The default is white. 1371 //! 1372 //! \sa setMarkerForegroundColor() 1373 void setMarkerBackgroundColor(const QColor &col, int markerNumber = -1); 1374 1375 //! Set the foreground colour of marker \a markerNumber to \a col. If 1376 //! \a markerNumber is -1 then the colour of all markers is set. The 1377 //! default is black. 1378 //! 1379 //! \sa setMarkerBackgroundColor() 1380 void setMarkerForegroundColor(const QColor &col, int markerNumber = -1); 1381 1382 //! Set the background colour used to display matched braces to \a col. It 1383 //! is ignored if an indicator is being used. The default is white. 1384 //! 1385 //! \sa setMatchedBraceForegroundColor(), setMatchedBraceIndicator() 1386 void setMatchedBraceBackgroundColor(const QColor &col); 1387 1388 //! Set the foreground colour used to display matched braces to \a col. It 1389 //! is ignored if an indicator is being used. The default is red. 1390 //! 1391 //! \sa setMatchedBraceBackgroundColor(), setMatchedBraceIndicator() 1392 void setMatchedBraceForegroundColor(const QColor &col); 1393 1394 //! Set the indicator used to display matched braces to \a indicatorNumber. 1395 //! The default is not to use an indicator. 1396 //! 1397 //! \sa resetMatchedBraceIndicator(), setMatchedBraceBackgroundColor() 1398 void setMatchedBraceIndicator(int indicatorNumber); 1399 1400 //! Stop using an indicator to display matched braces. 1401 //! 1402 //! \sa setMatchedBraceIndicator() 1403 void resetMatchedBraceIndicator(); 1404 1405 //! For performance, QScintilla does not measure the display width of the 1406 //! document to determine the properties of the horizontal scroll bar. 1407 //! Instead, an assumed width is used. This sets the document width in 1408 //! pixels assumed by QScintilla to \a pixelWidth. The default value is 1409 //! 2000. 1410 //! 1411 //! \sa scrollWidth(), setScrollWidthTracking() 1412 void setScrollWidth(int pixelWidth); 1413 1414 //! If scroll width tracking is enabled then the scroll width is adjusted 1415 //! to ensure that all of the lines currently displayed can be completely 1416 //! scrolled. This mode never adjusts the scroll width to be narrower. 1417 //! This sets the scroll width tracking to \a enabled. 1418 //! 1419 //! \sa setScrollWidth(), scrollWidthTracking() 1420 void setScrollWidthTracking(bool enabled); 1421 1422 //! Sets the mode used to draw tab characters when whitespace is visible to 1423 //! \a mode. The default is to use an arrow. 1424 //! 1425 //! \sa tabDrawMode() 1426 void setTabDrawMode(TabDrawMode mode); 1427 1428 //! Set the background colour used to display unmatched braces to \a col. 1429 //! It is ignored if an indicator is being used. The default is white. 1430 //! 1431 //! \sa setUnmatchedBraceForegroundColor(), setUnmatchedBraceIndicator() 1432 void setUnmatchedBraceBackgroundColor(const QColor &col); 1433 1434 //! Set the foreground colour used to display unmatched braces to \a col. 1435 //! It is ignored if an indicator is being used. The default is blue. 1436 //! 1437 //! \sa setUnmatchedBraceBackgroundColor(), setUnmatchedBraceIndicator() 1438 void setUnmatchedBraceForegroundColor(const QColor &col); 1439 1440 //! Set the indicator used to display unmatched braces to 1441 //! \a indicatorNumber. The default is not to use an indicator. 1442 //! 1443 //! \sa resetUnmatchedBraceIndicator(), setUnmatchedBraceBackgroundColor() 1444 void setUnmatchedBraceIndicator(int indicatorNumber); 1445 1446 //! Stop using an indicator to display unmatched braces. 1447 //! 1448 //! \sa setUnmatchedBraceIndicator() 1449 void resetUnmatchedBraceIndicator(); 1450 1451 //! Set the visual flags displayed when a line is wrapped. \a endFlag 1452 //! determines if and where the flag at the end of a line is displayed. 1453 //! \a startFlag determines if and where the flag at the start of a line is 1454 //! displayed. \a indent is the number of characters a wrapped line is 1455 //! indented by. By default no visual flags are displayed. 1456 void setWrapVisualFlags(WrapVisualFlag endFlag, 1457 WrapVisualFlag startFlag = WrapFlagNone, int indent = 0); 1458 1459 //! Returns the selected text or an empty string if there is no currently 1460 //! selected text. 1461 //! 1462 //! \sa hasSelectedText() 1463 QString selectedText() const; 1464 1465 //! Returns whether or not the selection is drawn up to the right hand 1466 //! border. 1467 //! 1468 //! \sa setSelectionToEol() 1469 bool selectionToEol() const; 1470 1471 //! Sets the background colour of an active hotspot area to \a col. 1472 //! 1473 //! \sa resetHotspotBackgroundColor(), setHotspotForegroundColor() 1474 void setHotspotBackgroundColor(const QColor &col); 1475 1476 //! Sets the foreground colour of an active hotspot area to \a col. 1477 //! 1478 //! \sa resetHotspotForegroundColor(), setHotspotBackgroundColor() 1479 void setHotspotForegroundColor(const QColor &col); 1480 1481 //! Enables or disables, according to \a enable, the underlining of an 1482 //! active hotspot area. The default is false. 1483 void setHotspotUnderline(bool enable); 1484 1485 //! Enables or disables, according to \a enable, the wrapping of a hotspot 1486 //! area to following lines. The default is true. 1487 void setHotspotWrap(bool enable); 1488 1489 //! Sets whether or not the selection is drawn up to the right hand border. 1490 //! \a filled is set if the selection is drawn to the border. 1491 //! 1492 //! \sa selectionToEol() 1493 void setSelectionToEol(bool filled); 1494 1495 //! Sets the extra space added to the height of a line above the baseline 1496 //! of the text to \a extra. 1497 //! 1498 //! \sa extraAscent(), setExtraDescent() 1499 void setExtraAscent(int extra); 1500 1501 //! Sets the extra space added to the height of a line below the baseline 1502 //! of the text to \a extra. 1503 //! 1504 //! \sa extraDescent(), setExtraAscent() 1505 void setExtraDescent(int extra); 1506 1507 //! Text entered by the user will overwrite existing text if \a overwrite 1508 //! is true. 1509 //! 1510 //! \sa overwriteMode() 1511 void setOverwriteMode(bool overwrite); 1512 1513 //! Sets the background colour of visible whitespace to \a col. If \a col 1514 //! is an invalid color (the default) then the color specified by the 1515 //! current lexer is used. 1516 void setWhitespaceBackgroundColor(const QColor &col); 1517 1518 //! Sets the foreground colour of visible whitespace to \a col. If \a col 1519 //! is an invalid color (the default) then the color specified by the 1520 //! current lexer is used. 1521 void setWhitespaceForegroundColor(const QColor &col); 1522 1523 //! Sets the size of the dots used to represent visible whitespace. 1524 //! 1525 //! \sa whitespaceSize() 1526 void setWhitespaceSize(int size); 1527 1528 //! Sets the line wrap indentation mode to \a mode. The default is 1529 //! WrapIndentFixed. 1530 //! 1531 //! \sa wrapIndentMode() 1532 void setWrapIndentMode(WrapIndentMode mode); 1533 1534 //! Displays a user defined list which can be interacted with like an 1535 //! auto-completion list. \a id is an identifier for the list which is 1536 //! passed as an argument to the userListActivated() signal and must be at 1537 //! least 1. \a list is the text with which the list is populated. 1538 //! 1539 //! \sa cancelList(), isListActive(), userListActivated() 1540 void showUserList(int id, const QStringList &list); 1541 1542 //! The standard command set is returned. standardCommands()1543 QsciCommandSet *standardCommands() const {return stdCmds;} 1544 1545 //! Returns the mode used to draw tab characters when whitespace is 1546 //! visible. 1547 //! 1548 //! \sa setTabDrawMode() 1549 TabDrawMode tabDrawMode() const; 1550 1551 //! Returns true if the tab key indents a line instead of inserting a tab 1552 //! character. The default is true. 1553 //! 1554 //! \sa setTabIndents(), backspaceUnindents(), setBackspaceUnindents() 1555 bool tabIndents() const; 1556 1557 //! Returns the tab width in characters. The default is 8. 1558 //! 1559 //! \sa setTabWidth() 1560 int tabWidth() const; 1561 1562 //! Returns the text of the current document. 1563 //! 1564 //! \sa setText() 1565 QString text() const; 1566 1567 //! \overload 1568 //! 1569 //! Returns the text of line \a line. 1570 //! 1571 //! \sa setText() 1572 QString text(int line) const; 1573 1574 //! \overload 1575 //! 1576 //! Returns the text between positions \a start and \a end. This is 1577 //! typically used by QsciLexerCustom::styleText(). 1578 //! 1579 //! \sa bytes(), setText() 1580 QString text(int start, int end) const; 1581 1582 //! Returns the height in pixels of the text in line number \a linenr. 1583 int textHeight(int linenr) const; 1584 1585 //! Returns the size of the dots used to represent visible whitespace. 1586 //! 1587 //! \sa setWhitespaceSize() 1588 int whitespaceSize() const; 1589 1590 //! Returns the visibility of whitespace. 1591 //! 1592 //! \sa setWhitespaceVisibility() 1593 WhitespaceVisibility whitespaceVisibility() const; 1594 1595 //! Returns the word at the \a line line number and \a index character 1596 //! index. 1597 QString wordAtLineIndex(int line, int index) const; 1598 1599 //! Returns the word at the \a point pixel coordinates. 1600 QString wordAtPoint(const QPoint &point) const; 1601 1602 //! Returns the set of valid word character as defined by the current 1603 //! language lexer. If there is no current lexer then the set contains an 1604 //! an underscore, numbers and all upper and lower case alphabetic 1605 //! characters. 1606 //! 1607 //! \sa isWordCharacter() 1608 const char *wordCharacters() const; 1609 1610 //! Returns the line wrap mode. 1611 //! 1612 //! \sa setWrapMode() 1613 WrapMode wrapMode() const; 1614 1615 //! Returns the line wrap indentation mode. 1616 //! 1617 //! \sa setWrapIndentMode() 1618 WrapIndentMode wrapIndentMode() const; 1619 1620 //! Writes the current document to the \a io device and returns true if 1621 //! there was no error. 1622 //! 1623 //! \sa read() 1624 bool write(QIODevice *io) const; 1625 1626 public slots: 1627 //! Appends the text \a text to the end of the text edit. Note that the 1628 //! undo/redo history is cleared by this function. 1629 virtual void append(const QString &text); 1630 1631 //! Display an auto-completion list based on any installed APIs, the 1632 //! current contents of the document and the characters immediately to the 1633 //! left of the cursor. 1634 //! 1635 //! \sa autoCompleteFromAPIs(), autoCompleteFromDocument() 1636 virtual void autoCompleteFromAll(); 1637 1638 //! Display an auto-completion list based on any installed APIs and the 1639 //! characters immediately to the left of the cursor. 1640 //! 1641 //! \sa autoCompleteFromAll(), autoCompleteFromDocument(), 1642 //! setAutoCompletionAPIs() 1643 virtual void autoCompleteFromAPIs(); 1644 1645 //! Display an auto-completion list based on the current contents of the 1646 //! document and the characters immediately to the left of the cursor. 1647 //! 1648 //! \sa autoCompleteFromAll(), autoCompleteFromAPIs() 1649 virtual void autoCompleteFromDocument(); 1650 1651 //! Display a call tip based on the the characters immediately to the left 1652 //! of the cursor. 1653 virtual void callTip(); 1654 1655 //! Deletes all the text in the text edit. 1656 virtual void clear(); 1657 1658 //! Copies any selected text to the clipboard. 1659 //! 1660 //! \sa copyAvailable(), cut(), paste() 1661 virtual void copy(); 1662 1663 //! Copies any selected text to the clipboard and then deletes the text. 1664 //! 1665 //! \sa copy(), paste() 1666 virtual void cut(); 1667 1668 //! Ensures that the cursor is visible. 1669 virtual void ensureCursorVisible(); 1670 1671 //! Ensures that the line number \a line is visible. 1672 virtual void ensureLineVisible(int line); 1673 1674 //! If any lines are currently folded then they are all unfolded. 1675 //! Otherwise all lines are folded. This has the same effect as clicking 1676 //! in the fold margin with the shift and control keys pressed. If 1677 //! \a children is not set (the default) then only the top level fold 1678 //! points are affected, otherwise the state of all fold points are 1679 //! changed. 1680 virtual void foldAll(bool children = false); 1681 1682 //! If the line \a line is folded then it is unfolded. Otherwise it is 1683 //! folded. This has the same effect as clicking in the fold margin. 1684 virtual void foldLine(int line); 1685 1686 //! Increases the indentation of line \a line by an indentation width. 1687 //! 1688 //! \sa unindent() 1689 virtual void indent(int line); 1690 1691 //! Insert the text \a text at the current position. 1692 virtual void insert(const QString &text); 1693 1694 //! Insert the text \a text in the line \a line at the position 1695 //! \a index. 1696 virtual void insertAt(const QString &text, int line, int index); 1697 1698 //! If the cursor is either side of a brace character then move it to the 1699 //! position of the corresponding brace. 1700 virtual void moveToMatchingBrace(); 1701 1702 //! Pastes any text from the clipboard into the text edit at the current 1703 //! cursor position. 1704 //! 1705 //! \sa copy(), cut() 1706 virtual void paste(); 1707 1708 //! Redo the last change or sequence of changes. 1709 //! 1710 //! \sa isRedoAvailable() 1711 virtual void redo(); 1712 1713 //! Removes any selected text. 1714 //! 1715 //! \sa replaceSelectedText() 1716 virtual void removeSelectedText(); 1717 1718 //! Replaces any selected text with \a text. 1719 //! 1720 //! \sa removeSelectedText() 1721 virtual void replaceSelectedText(const QString &text); 1722 1723 //! Resets the background colour of selected text to the default. 1724 //! 1725 //! \sa setSelectionBackgroundColor(), resetSelectionForegroundColor() 1726 virtual void resetSelectionBackgroundColor(); 1727 1728 //! Resets the foreground colour of selected text to the default. 1729 //! 1730 //! \sa setSelectionForegroundColor(), resetSelectionBackgroundColor() 1731 virtual void resetSelectionForegroundColor(); 1732 1733 //! If \a select is true (the default) then all the text is selected. If 1734 //! \a select is false then any currently selected text is deselected. 1735 virtual void selectAll(bool select = true); 1736 1737 //! If the cursor is either side of a brace character then move it to the 1738 //! position of the corresponding brace and select the text between the 1739 //! braces. 1740 virtual void selectToMatchingBrace(); 1741 1742 //! If \a cs is true then auto-completion lists are case sensitive. The 1743 //! default is true. Note that setting a lexer may change the case 1744 //! sensitivity. 1745 //! 1746 //! \sa autoCompletionCaseSensitivity() 1747 virtual void setAutoCompletionCaseSensitivity(bool cs); 1748 1749 //! If \a replace is true then when an item from an auto-completion list is 1750 //! selected, the rest of the word to the right of the current cursor is 1751 //! removed. The default is false. 1752 //! 1753 //! \sa autoCompletionReplaceWord() 1754 virtual void setAutoCompletionReplaceWord(bool replace); 1755 1756 //! If \a single is true then when there is only a single entry in an 1757 //! auto-completion list it is automatically used and the list is not 1758 //! displayed. This only has an effect when auto-completion is explicitly 1759 //! requested (using autoCompleteFromAPIs() and autoCompleteFromDocument()) 1760 //! and has no effect when auto-completion is triggered as the user types. 1761 //! The default is false. Note that this is deprecated and 1762 //! setAutoCompletionUseSingle() should be used instead. 1763 //! 1764 //! \sa autoCompletionShowSingle() 1765 virtual void setAutoCompletionShowSingle(bool single); 1766 1767 //! Sets the source for the auto-completion list when it is being displayed 1768 //! automatically as the user types to \a source. The default is AcsNone, 1769 //! ie. it is disabled. 1770 //! 1771 //! \sa autoCompletionSource() 1772 virtual void setAutoCompletionSource(AutoCompletionSource source); 1773 1774 //! Sets the threshold for the automatic display of the auto-completion 1775 //! list as the user types to \a thresh. The threshold is the number of 1776 //! characters that the user must type before the list is displayed. If 1777 //! the threshold is less than or equal to 0 then the list is disabled. 1778 //! The default is -1. 1779 //! 1780 //! \sa autoCompletionThreshold(), setAutoCompletionWordSeparators() 1781 virtual void setAutoCompletionThreshold(int thresh); 1782 1783 //! Sets the behavior of the auto-completion list when it has a single 1784 //! entry. The default is AcusNever. 1785 //! 1786 //! \sa autoCompletionUseSingle() 1787 virtual void setAutoCompletionUseSingle(AutoCompletionUseSingle single); 1788 1789 //! If \a autoindent is true then auto-indentation is enabled. The default 1790 //! is false. 1791 //! 1792 //! \sa autoIndent() 1793 virtual void setAutoIndent(bool autoindent); 1794 1795 //! Sets the brace matching mode to \a bm. The default is NoBraceMatching. 1796 //! 1797 //! \sa braceMatching() 1798 virtual void setBraceMatching(BraceMatch bm); 1799 1800 //! If \a deindent is true then the backspace key will unindent a line 1801 //! rather then delete a character. 1802 //! 1803 //! \sa backspaceUnindents(), tabIndents(), setTabIndents() 1804 virtual void setBackspaceUnindents(bool unindent); 1805 1806 //! Sets the foreground colour of the caret to \a col. 1807 virtual void setCaretForegroundColor(const QColor &col); 1808 1809 //! Sets the background colour, including the alpha component, of the line 1810 //! containing the caret to \a col. 1811 //! 1812 //! \sa setCaretLineVisible() 1813 virtual void setCaretLineBackgroundColor(const QColor &col); 1814 1815 //! Sets the width of the frame of the line containing the caret to \a 1816 //! width. 1817 virtual void setCaretLineFrameWidth(int width); 1818 1819 //! Enables or disables, according to \a enable, the background color of 1820 //! the line containing the caret. 1821 //! 1822 //! \sa setCaretLineBackgroundColor() 1823 virtual void setCaretLineVisible(bool enable); 1824 1825 //! Sets the width of the caret to \a width pixels. A \a width of 0 makes 1826 //! the caret invisible. 1827 virtual void setCaretWidth(int width); 1828 1829 //! The widget's text (ie. foreground) colour is set to \a c. This has no 1830 //! effect if a language lexer has been set. 1831 //! 1832 //! \sa color() 1833 virtual void setColor(const QColor &c); 1834 1835 //! Sets the cursor to the line \a line at the position \a index. 1836 //! 1837 //! \sa getCursorPosition() 1838 virtual void setCursorPosition(int line, int index); 1839 1840 //! Sets the end-of-line mode to \a mode. The default is the platform's 1841 //! natural mode. 1842 //! 1843 //! \sa eolMode() 1844 virtual void setEolMode(EolMode mode); 1845 1846 //! If \a visible is true then end-of-lines are made visible. The default 1847 //! is that they are invisible. 1848 //! 1849 //! \sa eolVisibility() 1850 virtual void setEolVisibility(bool visible); 1851 1852 //! Sets the folding style for margin \a margin to \a fold. The default 1853 //! style is NoFoldStyle (ie. folding is disabled) and the default margin 1854 //! is 2. 1855 //! 1856 //! \sa folding() 1857 virtual void setFolding(FoldStyle fold, int margin = 2); 1858 1859 //! Sets the indentation of line \a line to \a indentation characters. 1860 //! 1861 //! \sa indentation() 1862 virtual void setIndentation(int line, int indentation); 1863 1864 //! Enables or disables, according to \a enable, this display of 1865 //! indentation guides. 1866 //! 1867 //! \sa indentationGuides() 1868 virtual void setIndentationGuides(bool enable); 1869 1870 //! Set the background colour of indentation guides to \a col. 1871 //! 1872 //! \sa setIndentationGuidesForegroundColor() 1873 virtual void setIndentationGuidesBackgroundColor(const QColor &col); 1874 1875 //! Set the foreground colour of indentation guides to \a col. 1876 //! 1877 //! \sa setIndentationGuidesBackgroundColor() 1878 virtual void setIndentationGuidesForegroundColor(const QColor &col); 1879 1880 //! If \a tabs is true then indentations are created using tabs and spaces, 1881 //! rather than just spaces. 1882 //! 1883 //! \sa indentationsUseTabs() 1884 virtual void setIndentationsUseTabs(bool tabs); 1885 1886 //! Sets the indentation width to \a width characters. If \a width is 0 1887 //! then the value returned by tabWidth() is used. 1888 //! 1889 //! \sa indentationWidth(), tabWidth() 1890 virtual void setIndentationWidth(int width); 1891 1892 //! Sets the specific language lexer used to style text to \a lex. If 1893 //! \a lex is 0 then syntax styling is disabled. 1894 //! 1895 //! \sa lexer() 1896 virtual void setLexer(QsciLexer *lexer = 0); 1897 1898 //! Set the background colour of all margins to \a col. The default is a 1899 //! gray. 1900 //! 1901 //! \sa setMarginsForegroundColor() 1902 virtual void setMarginsBackgroundColor(const QColor &col); 1903 1904 //! Set the font used in all margins to \a f. 1905 virtual void setMarginsFont(const QFont &f); 1906 1907 //! Set the foreground colour of all margins to \a col. The default is 1908 //! black. 1909 //! 1910 //! \sa setMarginsBackgroundColor() 1911 virtual void setMarginsForegroundColor(const QColor &col); 1912 1913 //! Enables or disables, according to \a lnrs, the display of line numbers 1914 //! in margin \a margin. 1915 //! 1916 //! \sa marginLineNumbers(), setMarginType(), SCI_SETMARGINTYPEN 1917 virtual void setMarginLineNumbers(int margin, bool lnrs); 1918 1919 //! Sets the marker mask of margin \a margin to \a mask. Only those 1920 //! markers whose bit is set in the mask are displayed in the margin. 1921 //! 1922 //! \sa marginMarkerMask(), QsciMarker, SCI_SETMARGINMASKN 1923 virtual void setMarginMarkerMask(int margin, int mask); 1924 1925 //! Enables or disables, according to \a sens, the sensitivity of margin 1926 //! \a margin to mouse clicks. If the user clicks in a sensitive margin 1927 //! the marginClicked() signal is emitted. 1928 //! 1929 //! \sa marginSensitivity(), marginClicked(), SCI_SETMARGINSENSITIVEN 1930 virtual void setMarginSensitivity(int margin, bool sens); 1931 1932 //! Sets the width of margin \a margin to \a width pixels. If the width of 1933 //! a margin is 0 then it is not displayed. 1934 //! 1935 //! \sa marginWidth(), SCI_SETMARGINWIDTHN 1936 virtual void setMarginWidth(int margin, int width); 1937 1938 //! Sets the width of margin \a margin so that it is wide enough to display 1939 //! \a s in the current margin font. 1940 //! 1941 //! \sa marginWidth(), SCI_SETMARGINWIDTHN 1942 virtual void setMarginWidth(int margin, const QString &s); 1943 1944 //! Sets the modified state of the text edit to \a m. Note that it is only 1945 //! possible to clear the modified state (where \a m is false). Attempts 1946 //! to set the modified state (where \a m is true) are ignored. 1947 //! 1948 //! \sa isModified(), modificationChanged() 1949 virtual void setModified(bool m); 1950 1951 //! The widget's paper (ie. background) colour is set to \a c. This has no 1952 //! effect if a language lexer has been set. 1953 //! 1954 //! \sa paper() 1955 virtual void setPaper(const QColor &c); 1956 1957 //! Sets the read-only state of the text edit to \a ro. 1958 //! 1959 //! \sa isReadOnly() 1960 virtual void setReadOnly(bool ro); 1961 1962 //! Sets the selection which starts at position \a indexFrom in line 1963 //! \a lineFrom and ends at position \a indexTo in line \a lineTo. The 1964 //! cursor is moved to position \a indexTo in \a lineTo. 1965 //! 1966 //! \sa getSelection() 1967 virtual void setSelection(int lineFrom, int indexFrom, int lineTo, 1968 int indexTo); 1969 1970 //! Sets the background colour, including the alpha component, of selected 1971 //! text to \a col. 1972 //! 1973 //! \sa resetSelectionBackgroundColor(), setSelectionForegroundColor() 1974 virtual void setSelectionBackgroundColor(const QColor &col); 1975 1976 //! Sets the foreground colour of selected text to \a col. 1977 //! 1978 //! \sa resetSelectionForegroundColor(), setSelectionBackgroundColor() 1979 virtual void setSelectionForegroundColor(const QColor &col); 1980 1981 //! If \a indent is true then the tab key will indent a line rather than 1982 //! insert a tab character. 1983 //! 1984 //! \sa tabIndents(), backspaceUnindents(), setBackspaceUnindents() 1985 virtual void setTabIndents(bool indent); 1986 1987 //! Sets the tab width to \a width characters. 1988 //! 1989 //! \sa tabWidth() 1990 virtual void setTabWidth(int width); 1991 1992 //! Replaces all of the current text with \a text. Note that the 1993 //! undo/redo history is cleared by this function. 1994 //! 1995 //! \sa text() 1996 virtual void setText(const QString &text); 1997 1998 //! Sets the current text encoding. If \a cp is true then UTF8 is used, 1999 //! otherwise Latin1 is used. 2000 //! 2001 //! \sa isUtf8() 2002 virtual void setUtf8(bool cp); 2003 2004 //! Sets the visibility of whitespace to mode \a mode. The default is that 2005 //! whitespace is invisible. 2006 //! 2007 //! \sa whitespaceVisibility() 2008 virtual void setWhitespaceVisibility(WhitespaceVisibility mode); 2009 2010 //! Sets the line wrap mode to \a mode. The default is that lines are not 2011 //! wrapped. 2012 //! 2013 //! \sa wrapMode() 2014 virtual void setWrapMode(WrapMode mode); 2015 2016 //! Undo the last change or sequence of changes. 2017 //! 2018 //! Scintilla has multiple level undo and redo. It will continue to record 2019 //! undoable actions until memory runs out. Sequences of typing or 2020 //! deleting are compressed into single actions to make it easier to undo 2021 //! and redo at a sensible level of detail. Sequences of actions can be 2022 //! combined into actions that are undone as a unit. These sequences occur 2023 //! between calls to beginUndoAction() and endUndoAction(). These 2024 //! sequences can be nested and only the top level sequences are undone as 2025 //! units. 2026 //! 2027 //! \sa beginUndoAction(), endUndoAction(), isUndoAvailable() 2028 virtual void undo(); 2029 2030 //! Decreases the indentation of line \a line by an indentation width. 2031 //! 2032 //! \sa indent() 2033 virtual void unindent(int line); 2034 2035 //! Zooms in on the text by by making the base font size \a range points 2036 //! larger and recalculating all font sizes. 2037 //! 2038 //! \sa zoomOut(), zoomTo() 2039 virtual void zoomIn(int range); 2040 2041 //! \overload 2042 //! 2043 //! Zooms in on the text by by making the base font size one point larger 2044 //! and recalculating all font sizes. 2045 virtual void zoomIn(); 2046 2047 //! Zooms out on the text by by making the base font size \a range points 2048 //! smaller and recalculating all font sizes. 2049 //! 2050 //! \sa zoomIn(), zoomTo() 2051 virtual void zoomOut(int range); 2052 2053 //! \overload 2054 //! 2055 //! Zooms out on the text by by making the base font size one point larger 2056 //! and recalculating all font sizes. 2057 virtual void zoomOut(); 2058 2059 //! Zooms the text by making the base font size \a size points and 2060 //! recalculating all font sizes. 2061 //! 2062 //! \sa zoomIn(), zoomOut() 2063 virtual void zoomTo(int size); 2064 2065 signals: 2066 //! This signal is emitted whenever the cursor position changes. \a line 2067 //! contains the line number and \a index contains the character index 2068 //! within the line. 2069 void cursorPositionChanged(int line, int index); 2070 2071 //! This signal is emitted whenever text is selected or de-selected. 2072 //! \a yes is true if text has been selected and false if text has been 2073 //! deselected. If \a yes is true then copy() can be used to copy the 2074 //! selection to the clipboard. If \a yes is false then copy() does 2075 //! nothing. 2076 //! 2077 //! \sa copy(), selectionChanged() 2078 void copyAvailable(bool yes); 2079 2080 //! This signal is emitted whenever the user clicks on an indicator. \a 2081 //! line is the number of the line where the user clicked. \a index is the 2082 //! character index within the line. \a state is the state of the modifier 2083 //! keys (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and 2084 //! Qt::MetaModifier) when the user clicked. 2085 //! 2086 //! \sa indicatorReleased() 2087 void indicatorClicked(int line, int index, Qt::KeyboardModifiers state); 2088 2089 //! This signal is emitted whenever the user releases the mouse on an 2090 //! indicator. \a line is the number of the line where the user clicked. 2091 //! \a index is the character index within the line. \a state is the state 2092 //! of the modifier keys (Qt::ShiftModifier, Qt::ControlModifier, 2093 //! Qt::AltModifer and Qt::MetaModifier) when the user released the mouse. 2094 //! 2095 //! \sa indicatorClicked() 2096 void indicatorReleased(int line, int index, Qt::KeyboardModifiers state); 2097 2098 //! This signal is emitted whenever the number of lines of text changes. 2099 void linesChanged(); 2100 2101 //! This signal is emitted whenever the user clicks on a sensitive margin. 2102 //! \a margin is the margin. \a line is the number of the line where the 2103 //! user clicked. \a state is the state of the modifier keys 2104 //! (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and 2105 //! Qt::MetaModifier) when the user clicked. 2106 //! 2107 //! \sa marginSensitivity(), setMarginSensitivity() 2108 void marginClicked(int margin, int line, Qt::KeyboardModifiers state); 2109 2110 //! This signal is emitted whenever the user right-clicks on a sensitive 2111 //! margin. \a margin is the margin. \a line is the number of the line 2112 //! where the user clicked. \a state is the state of the modifier keys 2113 //! (Qt::ShiftModifier, Qt::ControlModifier, Qt::AltModifer and 2114 //! Qt::MetaModifier) when the user clicked. 2115 //! 2116 //! \sa marginSensitivity(), setMarginSensitivity() 2117 void marginRightClicked(int margin, int line, Qt::KeyboardModifiers state); 2118 2119 //! This signal is emitted whenever the user attempts to modify read-only 2120 //! text. 2121 //! 2122 //! \sa isReadOnly(), setReadOnly() 2123 void modificationAttempted(); 2124 2125 //! This signal is emitted whenever the modification state of the text 2126 //! changes. \a m is true if the text has been modified. 2127 //! 2128 //! \sa isModified(), setModified() 2129 void modificationChanged(bool m); 2130 2131 //! This signal is emitted whenever the selection changes. 2132 //! 2133 //! \sa copyAvailable() 2134 void selectionChanged(); 2135 2136 //! This signal is emitted whenever the text in the text edit changes. 2137 void textChanged(); 2138 2139 //! This signal is emitted when an item in a user defined list is activated 2140 //! (selected). \a id is the list identifier. \a string is the text of 2141 //! the item. 2142 //! 2143 //! \sa showUserList() 2144 void userListActivated(int id, const QString &string); 2145 2146 protected: 2147 //! \reimp 2148 virtual bool event(QEvent *e); 2149 2150 //! \reimp 2151 virtual void changeEvent(QEvent *e); 2152 2153 //! \reimp 2154 virtual void contextMenuEvent(QContextMenuEvent *e); 2155 2156 //! \reimp 2157 virtual void wheelEvent(QWheelEvent *e); 2158 2159 private slots: 2160 void handleCallTipClick(int dir); 2161 void handleCharAdded(int charadded); 2162 void handleIndicatorClick(int pos, int modifiers); 2163 void handleIndicatorRelease(int pos, int modifiers); 2164 void handleMarginClick(int pos, int margin, int modifiers); 2165 void handleMarginRightClick(int pos, int margin, int modifiers); 2166 void handleModified(int pos, int mtype, const char *text, int len, 2167 int added, int line, int foldNow, int foldPrev, int token, 2168 int annotationLinesAdded); 2169 void handlePropertyChange(const char *prop, const char *val); 2170 void handleSavePointReached(); 2171 void handleSavePointLeft(); 2172 void handleSelectionChanged(bool yes); 2173 void handleAutoCompletionSelection(); 2174 void handleUserListSelection(const char *text, int id); 2175 2176 void handleStyleColorChange(const QColor &c, int style); 2177 void handleStyleEolFillChange(bool eolfill, int style); 2178 void handleStyleFontChange(const QFont &f, int style); 2179 void handleStylePaperChange(const QColor &c, int style); 2180 2181 void handleUpdateUI(int updated); 2182 2183 void delete_selection(); 2184 2185 private: 2186 void detachLexer(); 2187 2188 enum IndentState { 2189 isNone, 2190 isKeywordStart, 2191 isBlockStart, 2192 isBlockEnd 2193 }; 2194 2195 void maintainIndentation(char ch, long pos); 2196 void autoIndentation(char ch, long pos); 2197 void autoIndentLine(long pos, int line, int indent); 2198 int blockIndent(int line); 2199 IndentState getIndentState(int line); 2200 bool rangeIsWhitespace(long spos, long epos); 2201 int findStyledWord(const char *text, int style, const char *words); 2202 2203 void checkMarker(int &markerNumber); 2204 void checkIndicator(int &indicatorNumber); 2205 static void allocateId(int &id, unsigned &allocated, int min, int max); 2206 int currentIndent() const; 2207 int indentWidth() const; 2208 bool doFind(); 2209 int simpleFind(); 2210 void foldClick(int lineClick, int bstate); 2211 void foldChanged(int line, int levelNow, int levelPrev); 2212 void foldExpand(int &line, bool doExpand, bool force = false, 2213 int visLevels = 0, int level = -1); 2214 void setFoldMarker(int marknr, int mark = SC_MARK_EMPTY); 2215 void setLexerStyle(int style); 2216 void setStylesFont(const QFont &f, int style); 2217 void setEnabledColors(int style, QColor &fore, QColor &back); 2218 2219 void braceMatch(); 2220 bool findMatchingBrace(long &brace, long &other, BraceMatch mode); 2221 long checkBrace(long pos, int brace_style, bool &colonMode); 2222 void gotoMatchingBrace(bool select); 2223 2224 void startAutoCompletion(AutoCompletionSource acs, bool checkThresh, 2225 bool choose_single); 2226 2227 int adjustedCallTipPosition(int ctshift) const; 2228 bool getSeparator(int &pos) const; 2229 QString getWord(int &pos) const; 2230 char getCharacter(int &pos) const; 2231 bool isStartChar(char ch) const; 2232 2233 bool ensureRW(); 2234 void insertAtPos(const QString &text, int pos); 2235 static int mapModifiers(int modifiers); 2236 2237 QString wordAtPosition(int position) const; 2238 2239 ScintillaBytes styleText(const QList<QsciStyledText> &styled_text, 2240 char **styles, int style_offset = 0); 2241 2242 struct FindState 2243 { 2244 enum Status 2245 { 2246 Finding, 2247 FindingInSelection, 2248 Idle 2249 }; 2250 FindStateFindState2251 FindState() : status(Idle) {} 2252 2253 Status status; 2254 QString expr; 2255 bool wrap; 2256 bool forward; 2257 int flags; 2258 long startpos, startpos_orig; 2259 long endpos, endpos_orig; 2260 bool show; 2261 }; 2262 2263 FindState findState; 2264 2265 unsigned allocatedMarkers; 2266 unsigned allocatedIndicators; 2267 int oldPos; 2268 int ctPos; 2269 bool selText; 2270 FoldStyle fold; 2271 int foldmargin; 2272 bool autoInd; 2273 BraceMatch braceMode; 2274 AutoCompletionSource acSource; 2275 int acThresh; 2276 QStringList wseps; 2277 const char *wchars; 2278 CallTipsPosition call_tips_position; 2279 CallTipsStyle call_tips_style; 2280 int maxCallTips; 2281 QStringList ct_entries; 2282 int ct_cursor; 2283 QList<int> ct_shifts; 2284 AutoCompletionUseSingle use_single; 2285 QPointer<QsciLexer> lex; 2286 QsciCommandSet *stdCmds; 2287 QsciDocument doc; 2288 QColor nl_text_colour; 2289 QColor nl_paper_colour; 2290 QByteArray explicit_fillups; 2291 bool fillups_enabled; 2292 2293 // The following allow QsciListBoxQt to distinguish between an 2294 // auto-completion list and a user list, and to return the full selection 2295 // of an auto-completion list. 2296 friend class QsciListBoxQt; 2297 2298 QString acSelection; 2299 bool isAutoCompletionList() const; 2300 2301 void set_shortcut(QAction *action, QsciCommand::Command cmd_id) const; 2302 2303 QsciScintilla(const QsciScintilla &); 2304 QsciScintilla &operator=(const QsciScintilla &); 2305 }; 2306 2307 #endif 2308