qscilexerd.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. // This defines the interface to the QsciLexerD 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 QSCILEXERD_H
  20. #define QSCILEXERD_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerD class encapsulates the Scintilla D lexer.
  25. class QSCINTILLA_EXPORT QsciLexerD : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the D
  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 JavaDoc and Doxygen comment.
  39. CommentDoc = 3,
  40. //! A nested comment.
  41. CommentNested = 4,
  42. //! A number.
  43. Number = 5,
  44. //! A keyword.
  45. Keyword = 6,
  46. //! A secondary keyword.
  47. KeywordSecondary = 7,
  48. //! A doc keyword
  49. KeywordDoc = 8,
  50. //! Typedefs and aliases
  51. Typedefs = 9,
  52. //! A string.
  53. String = 10,
  54. //! The end of a line where a string is not closed.
  55. UnclosedString = 11,
  56. //! A character
  57. Character = 12,
  58. //! An operator.
  59. Operator = 13,
  60. //! An identifier
  61. Identifier = 14,
  62. //! A JavaDoc and Doxygen line.
  63. CommentLineDoc = 15,
  64. //! A JavaDoc and Doxygen keyword.
  65. CommentDocKeyword = 16,
  66. //! A JavaDoc and Doxygen keyword error.
  67. CommentDocKeywordError = 17,
  68. //! A backquoted string.
  69. BackquoteString = 18,
  70. //! A raw, hexadecimal or delimited string.
  71. RawString = 19,
  72. //! A keyword defined in keyword set number 5. The class must be
  73. //! sub-classed and re-implement keywords() to make use of this style.
  74. KeywordSet5 = 20,
  75. //! A keyword defined in keyword set number 6. The class must be
  76. //! sub-classed and re-implement keywords() to make use of this style.
  77. KeywordSet6 = 21,
  78. //! A keyword defined in keyword set number 7. The class must be
  79. //! sub-classed and re-implement keywords() to make use of this style.
  80. KeywordSet7 = 22,
  81. };
  82. //! Construct a QsciLexerD with parent \a parent. \a parent is typically
  83. //! the QsciScintilla instance.
  84. QsciLexerD(QObject *parent = 0);
  85. //! Destroys the QsciLexerD instance.
  86. virtual ~QsciLexerD();
  87. //! Returns the name of the language.
  88. const char *language() const;
  89. //! Returns the name of the lexer. Some lexers support a number of
  90. //! languages.
  91. const char *lexer() const;
  92. //! \internal Returns the character sequences that can separate
  93. //! auto-completion words.
  94. QStringList autoCompletionWordSeparators() const;
  95. //! \internal Returns a space separated list of words or characters in a
  96. //! particular style that define the end of a block for auto-indentation.
  97. //! The styles is returned via \a style.
  98. const char *blockEnd(int *style = 0) const;
  99. //! \internal Returns a space separated list of words or characters in a
  100. //! particular style that define the start of a block for auto-indentation.
  101. //! The styles is returned via \a style.
  102. const char *blockStart(int *style = 0) const;
  103. //! \internal Returns a space separated list of keywords in a particular
  104. //! style that define the start of a block for auto-indentation. The
  105. //! styles is returned via \a style.
  106. const char *blockStartKeyword(int *style = 0) const;
  107. //! \internal Returns the style used for braces for brace matching.
  108. int braceStyle() const;
  109. //! Returns the string of characters that comprise a word.
  110. const char *wordCharacters() const;
  111. //! Returns the foreground colour of the text for style number \a style.
  112. //!
  113. //! \sa defaultPaper()
  114. QColor defaultColor(int style) const;
  115. //! Returns the end-of-line fill for style number \a style.
  116. bool defaultEolFill(int style) const;
  117. //! Returns the font for style number \a style.
  118. QFont defaultFont(int style) const;
  119. //! Returns the background colour of the text for style number \a style.
  120. //!
  121. //! \sa defaultColor()
  122. QColor defaultPaper(int style) const;
  123. //! Returns the set of keywords for the keyword set \a set recognised by
  124. //! the lexer as a space separated string.
  125. const char *keywords(int set) const;
  126. //! Returns the descriptive name for style number \a style. If the style
  127. //! is invalid for this language then an empty QString is returned. This
  128. //! is intended to be used in user preference dialogs.
  129. QString description(int style) const;
  130. //! Causes all properties to be refreshed by emitting the propertyChanged()
  131. //! signal as required.
  132. void refreshProperties();
  133. //! Returns true if "} else {" lines can be folded.
  134. //!
  135. //! \sa setFoldAtElse()
  136. bool foldAtElse() const;
  137. //! Returns true if multi-line comment blocks can be folded.
  138. //!
  139. //! \sa setFoldComments()
  140. bool foldComments() const;
  141. //! Returns true if trailing blank lines are included in a fold block.
  142. //!
  143. //! \sa setFoldCompact()
  144. bool foldCompact() const;
  145. public slots:
  146. //! If \a fold is true then "} else {" lines can be folded. The default is
  147. //! false.
  148. //!
  149. //! \sa foldAtElse()
  150. virtual void setFoldAtElse(bool fold);
  151. //! If \a fold is true then multi-line comment blocks can be folded. The
  152. //! default is false.
  153. //!
  154. //! \sa foldComments()
  155. virtual void setFoldComments(bool fold);
  156. //! If \a fold is true then trailing blank lines are included in a fold
  157. //! block. The default is true.
  158. //!
  159. //! \sa foldCompact()
  160. virtual void setFoldCompact(bool fold);
  161. protected:
  162. //! The lexer's properties are read from the settings \a qs. \a prefix
  163. //! (which has a trailing '/') should be used as a prefix to the key of
  164. //! each setting. true is returned if there is no error.
  165. //!
  166. //! \sa writeProperties()
  167. bool readProperties(QSettings &qs,const QString &prefix);
  168. //! The lexer's properties are written to the settings \a qs. \a prefix
  169. //! (which has a trailing '/') should be used as a prefix to the key of
  170. //! each setting. true is returned if there is no error.
  171. //!
  172. //! \sa readProperties()
  173. bool writeProperties(QSettings &qs,const QString &prefix) const;
  174. private:
  175. void setAtElseProp();
  176. void setCommentProp();
  177. void setCompactProp();
  178. bool fold_atelse;
  179. bool fold_comments;
  180. bool fold_compact;
  181. QsciLexerD(const QsciLexerD &);
  182. QsciLexerD &operator=(const QsciLexerD &);
  183. };
  184. #endif