qscilexercoffeescript.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. // This defines the interface to the QsciLexerCoffeeScript 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 QSCILEXERCOFFEESCRIPT_H
  20. #define QSCILEXERCOFFEESCRIPT_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerCoffeeScript class encapsulates the Scintilla
  25. //! CoffeeScript lexer.
  26. class QSCINTILLA_EXPORT QsciLexerCoffeeScript : public QsciLexer
  27. {
  28. Q_OBJECT
  29. public:
  30. //! This enum defines the meanings of the different styles used by the
  31. //! C++ lexer.
  32. enum {
  33. //! The default.
  34. Default = 0,
  35. //! A C-style comment.
  36. Comment = 1,
  37. //! A C++-style comment line.
  38. CommentLine = 2,
  39. //! A JavaDoc/Doxygen C-style comment.
  40. CommentDoc = 3,
  41. //! A number.
  42. Number = 4,
  43. //! A keyword.
  44. Keyword = 5,
  45. //! A double-quoted string.
  46. DoubleQuotedString = 6,
  47. //! A single-quoted string.
  48. SingleQuotedString = 7,
  49. //! An IDL UUID.
  50. UUID = 8,
  51. //! A pre-processor block.
  52. PreProcessor = 9,
  53. //! An operator.
  54. Operator = 10,
  55. //! An identifier
  56. Identifier = 11,
  57. //! The end of a line where a string is not closed.
  58. UnclosedString = 12,
  59. //! A C# verbatim string.
  60. VerbatimString = 13,
  61. //! A regular expression.
  62. Regex = 14,
  63. //! A JavaDoc/Doxygen C++-style comment line.
  64. CommentLineDoc = 15,
  65. //! A keyword defined in keyword set number 2. The class must be
  66. //! sub-classed and re-implement keywords() to make use of this style.
  67. KeywordSet2 = 16,
  68. //! A JavaDoc/Doxygen keyword.
  69. CommentDocKeyword = 17,
  70. //! A JavaDoc/Doxygen keyword error defined in keyword set number 3.
  71. //! The class must be sub-classed and re-implement keywords() to make
  72. //! use of this style.
  73. CommentDocKeywordError = 18,
  74. //! A global class defined in keyword set number 4. The class must be
  75. //! sub-classed and re-implement keywords() to make use of this style.
  76. GlobalClass = 19,
  77. //! A block comment.
  78. CommentBlock = 22,
  79. //! A block regular expression.
  80. BlockRegex = 23,
  81. //! A block regular expression comment.
  82. BlockRegexComment = 24,
  83. //! An instance property.
  84. InstanceProperty = 25,
  85. };
  86. //! Construct a QsciLexerCoffeeScript with parent \a parent. \a parent is
  87. //! typically the QsciScintilla instance.
  88. QsciLexerCoffeeScript(QObject *parent = 0);
  89. //! Destroys the QsciLexerCoffeeScript instance.
  90. virtual ~QsciLexerCoffeeScript();
  91. //! Returns the name of the language.
  92. const char *language() const;
  93. //! Returns the name of the lexer. Some lexers support a number of
  94. //! languages.
  95. const char *lexer() const;
  96. //! \internal Returns the character sequences that can separate
  97. //! auto-completion words.
  98. QStringList autoCompletionWordSeparators() const;
  99. //! \internal Returns a space separated list of words or characters in
  100. //! a particular style that define the end of a block for
  101. //! auto-indentation. The styles is returned via \a style.
  102. const char *blockEnd(int *style = 0) const;
  103. //! \internal Returns a space separated list of words or characters in
  104. //! a particular style that define the start of a block for
  105. //! auto-indentation. The styles is returned via \a style.
  106. const char *blockStart(int *style = 0) const;
  107. //! \internal Returns a space separated list of keywords in a
  108. //! particular style that define the start of a block for
  109. //! auto-indentation. The styles is returned via \a style.
  110. const char *blockStartKeyword(int *style = 0) const;
  111. //! \internal Returns the style used for braces for brace matching.
  112. int braceStyle() const;
  113. //! Returns the string of characters that comprise a word.
  114. const char *wordCharacters() const;
  115. //! Returns the foreground colour of the text for style number \a style.
  116. //!
  117. //! \sa defaultPaper()
  118. QColor defaultColor(int style) const;
  119. //! Returns the end-of-line fill for style number \a style.
  120. bool defaultEolFill(int style) const;
  121. //! Returns the font for style number \a style.
  122. QFont defaultFont(int style) const;
  123. //! Returns the background colour of the text for style number \a style.
  124. //!
  125. //! \sa defaultColor()
  126. QColor defaultPaper(int style) const;
  127. //! Returns the set of keywords for the keyword set \a set recognised
  128. //! by the lexer as a space separated string. Set 1 is normally used for
  129. //! primary keywords and identifiers. Set 2 is normally used for secondary
  130. //! keywords and identifiers. Set 3 is normally used for documentation
  131. //! comment keywords. Set 4 is normally used for global classes and
  132. //! typedefs.
  133. const char *keywords(int set) const;
  134. //! Returns the descriptive name for style number \a style. If the
  135. //! style is invalid for this language then an empty QString is returned.
  136. //! This is intended to be used in user preference dialogs.
  137. QString description(int style) const;
  138. //! Causes all properties to be refreshed by emitting the
  139. //! propertyChanged() signal as required.
  140. void refreshProperties();
  141. //! Returns true if '$' characters are allowed in identifier names.
  142. //!
  143. //! \sa setDollarsAllowed()
  144. bool dollarsAllowed() const {return dollars;}
  145. //! If \a allowed is true then '$' characters are allowed in identifier
  146. //! names. The default is true.
  147. //!
  148. //! \sa dollarsAllowed()
  149. void setDollarsAllowed(bool allowed);
  150. //! Returns true if multi-line comment blocks can be folded.
  151. //!
  152. //! \sa setFoldComments()
  153. bool foldComments() const {return fold_comments;}
  154. //! If \a fold is true then multi-line comment blocks can be folded.
  155. //! The default is false.
  156. //!
  157. //! \sa foldComments()
  158. void setFoldComments(bool fold);
  159. //! Returns true if trailing blank lines are included in a fold block.
  160. //!
  161. //! \sa setFoldCompact()
  162. bool foldCompact() const {return fold_compact;}
  163. //! If \a fold is true then trailing blank lines are included in a fold
  164. //! block. The default is true.
  165. //!
  166. //! \sa foldCompact()
  167. void setFoldCompact(bool fold);
  168. //! Returns true if preprocessor lines (after the preprocessor
  169. //! directive) are styled.
  170. //!
  171. //! \sa setStylePreprocessor()
  172. bool stylePreprocessor() const {return style_preproc;}
  173. //! If \a style is true then preprocessor lines (after the preprocessor
  174. //! directive) are styled. The default is false.
  175. //!
  176. //! \sa stylePreprocessor()
  177. void setStylePreprocessor(bool style);
  178. protected:
  179. //! The lexer's properties are read from the settings \a qs. \a prefix
  180. //! (which has a trailing '/') should be used as a prefix to the key of
  181. //! each setting. true is returned if there is no error.
  182. //!
  183. //! \sa writeProperties()
  184. bool readProperties(QSettings &qs,const QString &prefix);
  185. //! The lexer's properties are written to the settings \a qs.
  186. //! \a prefix (which has a trailing '/') should be used as a prefix to
  187. //! the key of each setting. true is returned if there is no error.
  188. //!
  189. //! \sa readProperties()
  190. bool writeProperties(QSettings &qs,const QString &prefix) const;
  191. private:
  192. void setCommentProp();
  193. void setCompactProp();
  194. void setStylePreprocProp();
  195. void setDollarsProp();
  196. bool fold_comments;
  197. bool fold_compact;
  198. bool style_preproc;
  199. bool dollars;
  200. QsciLexerCoffeeScript(const QsciLexerCoffeeScript &);
  201. QsciLexerCoffeeScript &operator=(const QsciLexerCoffeeScript &);
  202. };
  203. #endif