qscilexerruby.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // This defines the interface to the QsciLexerRuby 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 QSCILEXERRUBY_H
  20. #define QSCILEXERRUBY_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerRuby class encapsulates the Scintilla Ruby lexer.
  25. class QSCINTILLA_EXPORT QsciLexerRuby : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! Ruby lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! An error.
  35. Error = 1,
  36. //! A comment.
  37. Comment = 2,
  38. //! A POD.
  39. POD = 3,
  40. //! A number.
  41. Number = 4,
  42. //! A keyword.
  43. Keyword = 5,
  44. //! A double-quoted string.
  45. DoubleQuotedString = 6,
  46. //! A single-quoted string.
  47. SingleQuotedString = 7,
  48. //! The name of a class.
  49. ClassName = 8,
  50. //! The name of a function or method.
  51. FunctionMethodName = 9,
  52. //! An operator.
  53. Operator = 10,
  54. //! An identifier
  55. Identifier = 11,
  56. //! A regular expression.
  57. Regex = 12,
  58. //! A global.
  59. Global = 13,
  60. //! A symbol.
  61. Symbol = 14,
  62. //! The name of a module.
  63. ModuleName = 15,
  64. //! An instance variable.
  65. InstanceVariable = 16,
  66. //! A class variable.
  67. ClassVariable = 17,
  68. //! Backticks.
  69. Backticks = 18,
  70. //! A data section.
  71. DataSection = 19,
  72. //! A here document delimiter.
  73. HereDocumentDelimiter = 20,
  74. //! A here document.
  75. HereDocument = 21,
  76. //! A %q string.
  77. PercentStringq = 24,
  78. //! A %Q string.
  79. PercentStringQ = 25,
  80. //! A %x string.
  81. PercentStringx = 26,
  82. //! A %r string.
  83. PercentStringr = 27,
  84. //! A %w string.
  85. PercentStringw = 28,
  86. //! A demoted keyword.
  87. DemotedKeyword = 29,
  88. //! stdin.
  89. Stdin = 30,
  90. //! stdout.
  91. Stdout = 31,
  92. //! stderr.
  93. Stderr = 40
  94. };
  95. //! Construct a QsciLexerRuby with parent \a parent. \a parent is
  96. //! typically the QsciScintilla instance.
  97. QsciLexerRuby(QObject *parent = 0);
  98. //! Destroys the QsciLexerRuby instance.
  99. virtual ~QsciLexerRuby();
  100. //! Returns the name of the language.
  101. const char *language() const;
  102. //! Returns the name of the lexer. Some lexers support a number of
  103. //! languages.
  104. const char *lexer() const;
  105. //! \internal Returns a space separated list of words or characters in
  106. //! a particular style that define the end of a block for
  107. //! auto-indentation. The style is returned via \a style.
  108. const char *blockEnd(int *style = 0) const;
  109. //! \internal Returns a space separated list of words or characters in
  110. //! a particular style that define the start of a block for
  111. //! auto-indentation. The styles is returned via \a style.
  112. const char *blockStart(int *style = 0) const;
  113. //! \internal Returns a space separated list of keywords in a
  114. //! particular style that define the start of a block for
  115. //! auto-indentation. The style is returned via \a style.
  116. const char *blockStartKeyword(int *style = 0) const;
  117. //! \internal Returns the style used for braces for brace matching.
  118. int braceStyle() const;
  119. //! Returns the foreground colour of the text for style number \a style.
  120. //!
  121. //! \sa defaultpaper()
  122. QColor defaultColor(int style) const;
  123. //! Returns the end-of-line fill for style number \a style.
  124. bool defaultEolFill(int style) const;
  125. //! Returns the font for style number \a style.
  126. QFont defaultFont(int style) const;
  127. //! Returns the background colour of the text for style number \a style.
  128. //!
  129. //! \sa defaultColor()
  130. QColor defaultPaper(int style) const;
  131. //! Returns the set of keywords for the keyword set \a set recognised
  132. //! by the lexer as a space separated string.
  133. const char *keywords(int set) const;
  134. //! Returns the descriptive name for style number \a style. If the style
  135. //! is invalid for this language then an empty QString is returned. This
  136. //! 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. //! If \a fold is true then multi-line comment blocks can be folded.
  142. //! The default is false.
  143. //!
  144. //! \sa foldComments()
  145. void setFoldComments(bool fold);
  146. //! Returns true if multi-line comment blocks can be folded.
  147. //!
  148. //! \sa setFoldComments()
  149. bool foldComments() const {return fold_comments;}
  150. //! If \a fold is true then trailing blank lines are included in a fold
  151. //! block. The default is true.
  152. //!
  153. //! \sa foldCompact()
  154. void setFoldCompact(bool fold);
  155. //! Returns true if trailing blank lines are included in a fold block.
  156. //!
  157. //! \sa setFoldCompact()
  158. bool foldCompact() const {return fold_compact;}
  159. protected:
  160. //! The lexer's properties are read from the settings \a qs. \a prefix
  161. //! (which has a trailing '/') should be used as a prefix to the key of
  162. //! each setting. true is returned if there is no error.
  163. //!
  164. bool readProperties(QSettings &qs, const QString &prefix);
  165. //! The lexer's properties are written to the settings \a qs.
  166. //! \a prefix (which has a trailing '/') should be used as a prefix to
  167. //! the key of each setting. true is returned if there is no error.
  168. //!
  169. bool writeProperties(QSettings &qs, const QString &prefix) const;
  170. private:
  171. void setCommentProp();
  172. void setCompactProp();
  173. bool fold_comments;
  174. bool fold_compact;
  175. QsciLexerRuby(const QsciLexerRuby &);
  176. QsciLexerRuby &operator=(const QsciLexerRuby &);
  177. };
  178. #endif