qscilexervhdl.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. // This defines the interface to the QsciLexerVHDL 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 QSCILEXERVHDL_H
  20. #define QSCILEXERVHDL_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerVHDL class encapsulates the Scintilla VHDL lexer.
  25. class QSCINTILLA_EXPORT QsciLexerVHDL : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! VHDL lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! A comment.
  35. Comment = 1,
  36. //! A comment line.
  37. CommentLine = 2,
  38. //! A number.
  39. Number = 3,
  40. //! A string.
  41. String = 4,
  42. //! An operator.
  43. Operator = 5,
  44. //! An identifier
  45. Identifier = 6,
  46. //! The end of a line where a string is not closed.
  47. UnclosedString = 7,
  48. //! A keyword.
  49. Keyword = 8,
  50. //! A standard operator.
  51. StandardOperator = 9,
  52. //! An attribute.
  53. Attribute = 10,
  54. //! A standard function.
  55. StandardFunction = 11,
  56. //! A standard package.
  57. StandardPackage = 12,
  58. //! A standard type.
  59. StandardType = 13,
  60. //! A keyword defined in keyword set number 7. The class must be
  61. //! sub-classed and re-implement keywords() to make use of this style.
  62. KeywordSet7 = 14,
  63. //! A comment block.
  64. CommentBlock = 15,
  65. };
  66. //! Construct a QsciLexerVHDL with parent \a parent. \a parent is
  67. //! typically the QsciScintilla instance.
  68. QsciLexerVHDL(QObject *parent = 0);
  69. //! Destroys the QsciLexerVHDL instance.
  70. virtual ~QsciLexerVHDL();
  71. //! Returns the name of the language.
  72. const char *language() const;
  73. //! Returns the name of the lexer. Some lexers support a number of
  74. //! languages.
  75. const char *lexer() const;
  76. //! \internal Returns the style used for braces for brace matching.
  77. int braceStyle() const;
  78. //! Returns the foreground colour of the text for style number \a style.
  79. //!
  80. //! \sa defaultPaper()
  81. QColor defaultColor(int style) const;
  82. //! Returns the end-of-line fill for style number \a style.
  83. bool defaultEolFill(int style) const;
  84. //! Returns the font for style number \a style.
  85. QFont defaultFont(int style) const;
  86. //! Returns the background colour of the text for style number \a style.
  87. //!
  88. //! \sa defaultColor()
  89. QColor defaultPaper(int style) const;
  90. //! Returns the set of keywords for the keyword set \a set recognised
  91. //! by the lexer as a space separated string.
  92. const char *keywords(int set) const;
  93. //! Returns the descriptive name for style number \a style. If the
  94. //! style is invalid for this language then an empty QString is returned.
  95. //! This is intended to be used in user preference dialogs.
  96. QString description(int style) const;
  97. //! Causes all properties to be refreshed by emitting the propertyChanged()
  98. //! signal as required.
  99. void refreshProperties();
  100. //! Returns true if multi-line comment blocks can be folded.
  101. //!
  102. //! \sa setFoldComments()
  103. bool foldComments() const;
  104. //! Returns true if trailing blank lines are included in a fold block.
  105. //!
  106. //! \sa setFoldCompact()
  107. bool foldCompact() const;
  108. //! Returns true if else blocks can be folded.
  109. //!
  110. //! \sa setFoldAtElse()
  111. bool foldAtElse() const;
  112. //! Returns true if begin blocks can be folded.
  113. //!
  114. //! \sa setFoldAtBegin()
  115. bool foldAtBegin() const;
  116. //! Returns true if blocks can be folded at a parenthesis.
  117. //!
  118. //! \sa setFoldAtParenthesis()
  119. bool foldAtParenthesis() const;
  120. public slots:
  121. //! If \a fold is true then multi-line comment blocks can be folded.
  122. //! The default is true.
  123. //!
  124. //! \sa foldComments()
  125. virtual void setFoldComments(bool fold);
  126. //! If \a fold is true then trailing blank lines are included in a fold
  127. //! block. The default is true.
  128. //!
  129. //! \sa foldCompact()
  130. virtual void setFoldCompact(bool fold);
  131. //! If \a fold is true then else blocks can be folded. The default is
  132. //! true.
  133. //!
  134. //! \sa foldAtElse()
  135. virtual void setFoldAtElse(bool fold);
  136. //! If \a fold is true then begin blocks can be folded. The default is
  137. //! true.
  138. //!
  139. //! \sa foldAtBegin()
  140. virtual void setFoldAtBegin(bool fold);
  141. //! If \a fold is true then blocks can be folded at a parenthesis. The
  142. //! default is true.
  143. //!
  144. //! \sa foldAtParenthesis()
  145. virtual void setFoldAtParenthesis(bool fold);
  146. protected:
  147. //! The lexer's properties are read from the settings \a qs. \a prefix
  148. //! (which has a trailing '/') should be used as a prefix to the key of
  149. //! each setting. true is returned if there is no error.
  150. //!
  151. bool readProperties(QSettings &qs,const QString &prefix);
  152. //! The lexer's properties are written to the settings \a qs.
  153. //! \a prefix (which has a trailing '/') should be used as a prefix to
  154. //! the key of each setting. true is returned if there is no error.
  155. //!
  156. bool writeProperties(QSettings &qs,const QString &prefix) const;
  157. private:
  158. void setCommentProp();
  159. void setCompactProp();
  160. void setAtElseProp();
  161. void setAtBeginProp();
  162. void setAtParenthProp();
  163. bool fold_comments;
  164. bool fold_compact;
  165. bool fold_atelse;
  166. bool fold_atbegin;
  167. bool fold_atparenth;
  168. QsciLexerVHDL(const QsciLexerVHDL &);
  169. QsciLexerVHDL &operator=(const QsciLexerVHDL &);
  170. };
  171. #endif