qscilexerpascal.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. // This defines the interface to the QsciLexerPascal 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 QSCILEXERPASCAL_H
  20. #define QSCILEXERPASCAL_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerPascal class encapsulates the Scintilla Pascal lexer.
  25. class QSCINTILLA_EXPORT QsciLexerPascal : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! C++ lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! An identifier
  35. Identifier = 1,
  36. //! A '{ ... }' style comment.
  37. Comment = 2,
  38. //! A '(* ... *)' style comment.
  39. CommentParenthesis = 3,
  40. //! A comment line.
  41. CommentLine = 4,
  42. //! A '{$ ... }' style pre-processor block.
  43. PreProcessor = 5,
  44. //! A '(*$ ... *)' style pre-processor block.
  45. PreProcessorParenthesis = 6,
  46. //! A number.
  47. Number = 7,
  48. //! A hexadecimal number.
  49. HexNumber = 8,
  50. //! A keyword.
  51. Keyword = 9,
  52. //! A single-quoted string.
  53. SingleQuotedString = 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. //! Inline Asm.
  61. Asm = 14
  62. };
  63. //! Construct a QsciLexerPascal with parent \a parent. \a parent is
  64. //! typically the QsciScintilla instance.
  65. QsciLexerPascal(QObject *parent = 0);
  66. //! Destroys the QsciLexerPascal instance.
  67. virtual ~QsciLexerPascal();
  68. //! Returns the name of the language.
  69. const char *language() const;
  70. //! Returns the name of the lexer. Some lexers support a number of
  71. //! languages.
  72. const char *lexer() const;
  73. //! \internal Returns the character sequences that can separate
  74. //! auto-completion words.
  75. QStringList autoCompletionWordSeparators() const;
  76. //! \internal Returns a space separated list of words or characters in
  77. //! a particular style that define the end of a block for
  78. //! auto-indentation. The styles is returned via \a style.
  79. const char *blockEnd(int *style = 0) const;
  80. //! \internal Returns a space separated list of words or characters in
  81. //! a particular style that define the start of a block for
  82. //! auto-indentation. The styles is returned via \a style.
  83. const char *blockStart(int *style = 0) const;
  84. //! \internal Returns a space separated list of keywords in a
  85. //! particular style that define the start of a block for
  86. //! auto-indentation. The styles is returned via \a style.
  87. const char *blockStartKeyword(int *style = 0) const;
  88. //! \internal Returns the style used for braces for brace matching.
  89. int braceStyle() const;
  90. //! Returns the foreground colour of the text for style number \a style.
  91. //!
  92. //! \sa defaultPaper()
  93. QColor defaultColor(int style) const;
  94. //! Returns the end-of-line fill for style number \a style.
  95. bool defaultEolFill(int style) const;
  96. //! Returns the font for style number \a style.
  97. QFont defaultFont(int style) const;
  98. //! Returns the background colour of the text for style number \a style.
  99. //!
  100. //! \sa defaultColor()
  101. QColor defaultPaper(int style) const;
  102. //! Returns the set of keywords for the keyword set \a set recognised
  103. //! by the lexer as a space separated string.
  104. const char *keywords(int set) const;
  105. //! Returns the descriptive name for style number \a style. If the
  106. //! style is invalid for this language then an empty QString is returned.
  107. //! This is intended to be used in user preference dialogs.
  108. QString description(int style) const;
  109. //! Causes all properties to be refreshed by emitting the
  110. //! propertyChanged() signal as required.
  111. void refreshProperties();
  112. //! Returns true if multi-line comment blocks can be folded.
  113. //!
  114. //! \sa setFoldComments()
  115. bool foldComments() const;
  116. //! Returns true if trailing blank lines are included in a fold block.
  117. //!
  118. //! \sa setFoldCompact()
  119. bool foldCompact() const;
  120. //! Returns true if preprocessor blocks can be folded.
  121. //!
  122. //! \sa setFoldPreprocessor()
  123. bool foldPreprocessor() const;
  124. //! If \a enabled is true then some keywords will only be highlighted in an
  125. //! appropriate context (similar to how the Delphi IDE works). The default
  126. //! is true.
  127. //!
  128. //! \sa smartHighlighting()
  129. void setSmartHighlighting(bool enabled);
  130. //! Returns true if some keywords will only be highlighted in an
  131. //! appropriate context (similar to how the Delphi IDE works).
  132. //!
  133. //! \sa setSmartHighlighting()
  134. bool smartHighlighting() const;
  135. public slots:
  136. //! If \a fold is true then multi-line comment blocks can be folded.
  137. //! The default is false.
  138. //!
  139. //! \sa foldComments()
  140. virtual void setFoldComments(bool fold);
  141. //! If \a fold is true then trailing blank lines are included in a fold
  142. //! block. The default is true.
  143. //!
  144. //! \sa foldCompact()
  145. virtual void setFoldCompact(bool fold);
  146. //! If \a fold is true then preprocessor blocks can be folded. The
  147. //! default is true.
  148. //!
  149. //! \sa foldPreprocessor()
  150. virtual void setFoldPreprocessor(bool fold);
  151. protected:
  152. //! The lexer's properties are read from the settings \a qs. \a prefix
  153. //! (which has a trailing '/') should be used as a prefix to the key of
  154. //! each setting. true is returned if there is no error.
  155. //!
  156. //! \sa writeProperties()
  157. bool readProperties(QSettings &qs,const QString &prefix);
  158. //! The lexer's properties are written to the settings \a qs.
  159. //! \a prefix (which has a trailing '/') should be used as a prefix to
  160. //! the key of each setting. true is returned if there is no error.
  161. //!
  162. //! \sa readProperties()
  163. bool writeProperties(QSettings &qs,const QString &prefix) const;
  164. private:
  165. void setCommentProp();
  166. void setCompactProp();
  167. void setPreprocProp();
  168. void setSmartHighlightProp();
  169. bool fold_comments;
  170. bool fold_compact;
  171. bool fold_preproc;
  172. bool smart_highlight;
  173. QsciLexerPascal(const QsciLexerPascal &);
  174. QsciLexerPascal &operator=(const QsciLexerPascal &);
  175. };
  176. #endif