qscilexeravs.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // This defines the interface to the QsciLexerAVS 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 QSCILEXERAVS_H
  20. #define QSCILEXERAVS_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerAVS class encapsulates the Scintilla AVS lexer.
  25. class QSCINTILLA_EXPORT QsciLexerAVS : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! AVS lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! A block comment.
  35. BlockComment = 1,
  36. //! A nested block comment.
  37. NestedBlockComment = 2,
  38. //! A line comment.
  39. LineComment = 3,
  40. //! A number.
  41. Number = 4,
  42. //! An operator.
  43. Operator = 5,
  44. //! An identifier
  45. Identifier = 6,
  46. //! A string.
  47. String = 7,
  48. //! A triple quoted string.
  49. TripleString = 8,
  50. //! A keyword (as defined by keyword set number 1)..
  51. Keyword = 9,
  52. //! A filter (as defined by keyword set number 2).
  53. Filter = 10,
  54. //! A plugin (as defined by keyword set number 3).
  55. Plugin = 11,
  56. //! A function (as defined by keyword set number 4).
  57. Function = 12,
  58. //! A clip property (as defined by keyword set number 5).
  59. ClipProperty = 13,
  60. //! A keyword defined in keyword set number 6. The class must be
  61. //! sub-classed and re-implement keywords() to make use of this style.
  62. KeywordSet6 = 14
  63. };
  64. //! Construct a QsciLexerAVS with parent \a parent. \a parent is typically
  65. //! the QsciScintilla instance.
  66. QsciLexerAVS(QObject *parent = 0);
  67. //! Destroys the QsciLexerAVS instance.
  68. virtual ~QsciLexerAVS();
  69. //! Returns the name of the language.
  70. const char *language() const;
  71. //! Returns the name of the lexer. Some lexers support a number of
  72. //! languages.
  73. const char *lexer() const;
  74. //! \internal Returns the style used for braces for brace matching.
  75. int braceStyle() const;
  76. //! Returns the string of characters that comprise a word.
  77. const char *wordCharacters() const;
  78. //! Returns the foreground colour of the text for style number \a style.
  79. //!
  80. //! \sa defaultPaper()
  81. QColor defaultColor(int style) const;
  82. //! Returns the font for style number \a style.
  83. QFont defaultFont(int style) const;
  84. //! Returns the set of keywords for the keyword set \a set recognised
  85. //! by the lexer as a space separated string.
  86. const char *keywords(int set) const;
  87. //! Returns the descriptive name for style number \a style. If the
  88. //! style is invalid for this language then an empty QString is returned.
  89. //! This is intended to be used in user preference dialogs.
  90. QString description(int style) const;
  91. //! Causes all properties to be refreshed by emitting the propertyChanged()
  92. //! signal as required.
  93. void refreshProperties();
  94. //! Returns true if multi-line comment blocks can be folded.
  95. //!
  96. //! \sa setFoldComments()
  97. bool foldComments() const;
  98. //! Returns true if trailing blank lines are included in a fold block.
  99. //!
  100. //! \sa setFoldCompact()
  101. bool foldCompact() const;
  102. public slots:
  103. //! If \a fold is true then multi-line comment blocks can be folded.
  104. //! The default is false.
  105. //!
  106. //! \sa foldComments()
  107. virtual void setFoldComments(bool fold);
  108. //! If \a fold is true then trailing blank lines are included in a fold
  109. //! block. The default is true.
  110. //!
  111. //! \sa foldCompact()
  112. virtual void setFoldCompact(bool fold);
  113. protected:
  114. //! The lexer's properties are read from the settings \a qs. \a prefix
  115. //! (which has a trailing '/') should be used as a prefix to the key of
  116. //! each setting. true is returned if there is no error.
  117. //!
  118. bool readProperties(QSettings &qs,const QString &prefix);
  119. //! The lexer's properties are written to the settings \a qs.
  120. //! \a prefix (which has a trailing '/') should be used as a prefix to
  121. //! the key of each setting. true is returned if there is no error.
  122. //!
  123. bool writeProperties(QSettings &qs,const QString &prefix) const;
  124. private:
  125. void setCommentProp();
  126. void setCompactProp();
  127. bool fold_comments;
  128. bool fold_compact;
  129. QsciLexerAVS(const QsciLexerAVS &);
  130. QsciLexerAVS &operator=(const QsciLexerAVS &);
  131. };
  132. #endif