qscilexerlua.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. // This defines the interface to the QsciLexerLua 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 QSCILEXERLUA_H
  20. #define QSCILEXERLUA_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerLua class encapsulates the Scintilla Lua
  25. //! lexer.
  26. class QSCINTILLA_EXPORT QsciLexerLua : public QsciLexer
  27. {
  28. Q_OBJECT
  29. public:
  30. //! This enum defines the meanings of the different styles used by the
  31. //! Lua lexer.
  32. enum {
  33. //! The default.
  34. Default = 0,
  35. //! A block comment.
  36. Comment = 1,
  37. //! A line comment.
  38. LineComment = 2,
  39. //! A number.
  40. Number = 4,
  41. //! A keyword.
  42. Keyword = 5,
  43. //! A string.
  44. String = 6,
  45. //! A character.
  46. Character = 7,
  47. //! A literal string.
  48. LiteralString = 8,
  49. //! Preprocessor
  50. Preprocessor = 9,
  51. //! An operator.
  52. Operator = 10,
  53. //! An identifier
  54. Identifier = 11,
  55. //! The end of a line where a string is not closed.
  56. UnclosedString = 12,
  57. //! Basic functions.
  58. BasicFunctions = 13,
  59. //! String, table and maths functions.
  60. StringTableMathsFunctions = 14,
  61. //! Coroutines, I/O and system facilities.
  62. CoroutinesIOSystemFacilities = 15,
  63. //! A keyword defined in keyword set number 5. The class must be
  64. //! sub-classed and re-implement keywords() to make use of this style.
  65. KeywordSet5 = 16,
  66. //! A keyword defined in keyword set number 6. The class must be
  67. //! sub-classed and re-implement keywords() to make use of this style.
  68. KeywordSet6 = 17,
  69. //! A keyword defined in keyword set number 7. The class must be
  70. //! sub-classed and re-implement keywords() to make use of this style.
  71. KeywordSet7 = 18,
  72. //! A keyword defined in keyword set number 8. The class must be
  73. //! sub-classed and re-implement keywords() to make use of this style.
  74. KeywordSet8 = 19,
  75. //! A label.
  76. Label = 20
  77. };
  78. //! Construct a QsciLexerLua with parent \a parent. \a parent is typically
  79. //! the QsciScintilla instance.
  80. QsciLexerLua(QObject *parent = 0);
  81. //! Destroys the QsciLexerLua instance.
  82. virtual ~QsciLexerLua();
  83. //! Returns the name of the language.
  84. const char *language() const;
  85. //! Returns the name of the lexer. Some lexers support a number of
  86. //! languages.
  87. const char *lexer() const;
  88. //! \internal Returns the character sequences that can separate
  89. //! auto-completion words.
  90. QStringList autoCompletionWordSeparators() const;
  91. //! \internal Returns a space separated list of words or characters in
  92. //! a particular style that define the start of a block for
  93. //! auto-indentation. The styles is returned via \a style.
  94. const char *blockStart(int *style = 0) const;
  95. //! \internal Returns the style used for braces for brace matching.
  96. int braceStyle() const;
  97. //! Returns the foreground colour of the text for style number \a style.
  98. //!
  99. //! \sa defaultPaper()
  100. QColor defaultColor(int style) const;
  101. //! Returns the end-of-line fill for style number \a style.
  102. bool defaultEolFill(int style) const;
  103. //! Returns the font for style number \a style.
  104. QFont defaultFont(int style) const;
  105. //! Returns the background colour of the text for style number \a style.
  106. //!
  107. //! \sa defaultColor()
  108. QColor defaultPaper(int style) const;
  109. //! Returns the set of keywords for the keyword set \a set recognised
  110. //! by the lexer as a space separated string.
  111. const char *keywords(int set) const;
  112. //! Returns the descriptive name for style number \a style. If the
  113. //! style is invalid for this language then an empty QString is returned.
  114. //! This is intended to be used in user preference dialogs.
  115. QString description(int style) const;
  116. //! Causes all properties to be refreshed by emitting the
  117. //! propertyChanged() signal as required.
  118. void refreshProperties();
  119. //! Returns true if trailing blank lines are included in a fold block.
  120. //!
  121. //! \sa setFoldCompact()
  122. bool foldCompact() const;
  123. public slots:
  124. //! If \a fold is true then trailing blank lines are included in a fold
  125. //! block. The default is true.
  126. //!
  127. //! \sa foldCompact()
  128. virtual void setFoldCompact(bool fold);
  129. protected:
  130. //! The lexer's properties are read from the settings \a qs. \a prefix
  131. //! (which has a trailing '/') should be used as a prefix to the key of
  132. //! each setting. true is returned if there is no error.
  133. //!
  134. bool readProperties(QSettings &qs,const QString &prefix);
  135. //! The lexer's properties are written to the settings \a qs.
  136. //! \a prefix (which has a trailing '/') should be used as a prefix to
  137. //! the key of each setting. true is returned if there is no error.
  138. //!
  139. bool writeProperties(QSettings &qs,const QString &prefix) const;
  140. private:
  141. void setCompactProp();
  142. bool fold_compact;
  143. QsciLexerLua(const QsciLexerLua &);
  144. QsciLexerLua &operator=(const QsciLexerLua &);
  145. };
  146. #endif