qscilexertcl.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // This defines the interface to the QsciLexerTCL class.
  2. //
  3. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  4. //
  5. // This file is part of QScintilla.
  6. //
  7. // This file may be used under the terms of the GNU General Public License
  8. // version 3.0 as published by the Free Software Foundation and appearing in
  9. // the file LICENSE included in the packaging of this file. Please review the
  10. // following information to ensure the GNU General Public License version 3.0
  11. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  12. //
  13. // If you do not wish to use this file under the terms of the GPL version 3.0
  14. // then you may purchase a commercial license. For more information contact
  15. // info@riverbankcomputing.com.
  16. //
  17. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  18. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #ifndef QSCILEXERTCL_H
  20. #define QSCILEXERTCL_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerTCL class encapsulates the Scintilla TCL lexer.
  25. class QSCINTILLA_EXPORT QsciLexerTCL : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the TCL
  30. //! lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! A comment.
  35. Comment = 1,
  36. //! A comment line.
  37. CommentLine = 2,
  38. //! A number.
  39. Number = 3,
  40. //! A quoted keyword.
  41. QuotedKeyword = 4,
  42. //! A quoted string.
  43. QuotedString = 5,
  44. //! An operator.
  45. Operator = 6,
  46. //! An identifier
  47. Identifier = 7,
  48. //! A substitution.
  49. Substitution = 8,
  50. //! A substitution starting with a brace.
  51. SubstitutionBrace = 9,
  52. //! A modifier.
  53. Modifier = 10,
  54. //! Expand keyword (defined in keyword set number 5).
  55. ExpandKeyword = 11,
  56. //! A TCL keyword (defined in keyword set number 1).
  57. TCLKeyword = 12,
  58. //! A Tk keyword (defined in keyword set number 2).
  59. TkKeyword = 13,
  60. //! An iTCL keyword (defined in keyword set number 3).
  61. ITCLKeyword = 14,
  62. //! A Tk command (defined in keyword set number 4).
  63. TkCommand = 15,
  64. //! A keyword defined in keyword set number 6. The class must be
  65. //! sub-classed and re-implement keywords() to make use of this style.
  66. KeywordSet6 = 16,
  67. //! A keyword defined in keyword set number 7. The class must be
  68. //! sub-classed and re-implement keywords() to make use of this style.
  69. KeywordSet7 = 17,
  70. //! A keyword defined in keyword set number 8. The class must be
  71. //! sub-classed and re-implement keywords() to make use of this style.
  72. KeywordSet8 = 18,
  73. //! A keyword defined in keyword set number 9. The class must be
  74. //! sub-classed and re-implement keywords() to make use of this style.
  75. KeywordSet9 = 19,
  76. //! A comment box.
  77. CommentBox = 20,
  78. //! A comment block.
  79. CommentBlock = 21
  80. };
  81. //! Construct a QsciLexerTCL with parent \a parent. \a parent is
  82. //! typically the QsciScintilla instance.
  83. QsciLexerTCL(QObject *parent = 0);
  84. //! Destroys the QsciLexerTCL instance.
  85. virtual ~QsciLexerTCL();
  86. //! Returns the name of the language.
  87. const char *language() const;
  88. //! Returns the name of the lexer. Some lexers support a number of
  89. //! languages.
  90. const char *lexer() const;
  91. //! \internal Returns the style used for braces for brace matching.
  92. int braceStyle() const;
  93. //! Returns the foreground colour of the text for style number \a style.
  94. //!
  95. //! \sa defaultPaper()
  96. QColor defaultColor(int style) const;
  97. //! Returns the end-of-line fill for style number \a style.
  98. bool defaultEolFill(int style) const;
  99. //! Returns the font for style number \a style.
  100. QFont defaultFont(int style) const;
  101. //! Returns the background colour of the text for style number \a style.
  102. //!
  103. //! \sa defaultColor()
  104. QColor defaultPaper(int style) const;
  105. //! Returns the set of keywords for the keyword set \a set recognised
  106. //! by the lexer as a space separated string.
  107. const char *keywords(int set) const;
  108. //! Returns the descriptive name for style number \a style. If the style
  109. //! is invalid for this language then an empty QString is returned. This
  110. //! is intended to be used in user preference dialogs.
  111. QString description(int style) const;
  112. //! Causes all properties to be refreshed by emitting the
  113. //! propertyChanged() signal as required.
  114. void refreshProperties();
  115. //! If \a fold is true then multi-line comment blocks can be folded. The
  116. //! default is false.
  117. //!
  118. //! \sa foldComments()
  119. void setFoldComments(bool fold);
  120. //! Returns true if multi-line comment blocks can be folded.
  121. //!
  122. //! \sa setFoldComments()
  123. bool foldComments() const {return fold_comments;}
  124. protected:
  125. //! The lexer's properties are read from the settings \a qs. \a prefix
  126. //! (which has a trailing '/') should be used as a prefix to the key of
  127. //! each setting. true is returned if there is no error.
  128. //!
  129. bool readProperties(QSettings &qs,const QString &prefix);
  130. //! The lexer's properties are written to the settings \a qs.
  131. //! \a prefix (which has a trailing '/') should be used as a prefix to
  132. //! the key of each setting. true is returned if there is no error.
  133. //!
  134. bool writeProperties(QSettings &qs,const QString &prefix) const;
  135. private:
  136. void setCommentProp();
  137. bool fold_comments;
  138. QsciLexerTCL(const QsciLexerTCL &);
  139. QsciLexerTCL &operator=(const QsciLexerTCL &);
  140. };
  141. #endif