qscilexerpov.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. // This defines the interface to the QsciLexerPOV 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 QSCILEXERPOV_H
  20. #define QSCILEXERPOV_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerPOV class encapsulates the Scintilla POV lexer.
  25. class QSCINTILLA_EXPORT QsciLexerPOV : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! POV 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. //! An operator.
  41. Operator = 4,
  42. //! An identifier
  43. Identifier = 5,
  44. //! A string.
  45. String = 6,
  46. //! The end of a line where a string is not closed.
  47. UnclosedString = 7,
  48. //! A directive.
  49. Directive = 8,
  50. //! A bad directive.
  51. BadDirective = 9,
  52. //! Objects, CSG and appearance.
  53. ObjectsCSGAppearance = 10,
  54. //! Types, modifiers and items.
  55. TypesModifiersItems = 11,
  56. //! Predefined identifiers.
  57. PredefinedIdentifiers = 12,
  58. //! Predefined identifiers.
  59. PredefinedFunctions = 13,
  60. //! A keyword defined in keyword set number 6. The class must be
  61. //! sub-classed and re-implement keywords() to make use of this style.
  62. KeywordSet6 = 14,
  63. //! A keyword defined in keyword set number 7. The class must be
  64. //! sub-classed and re-implement keywords() to make use of this style.
  65. KeywordSet7 = 15,
  66. //! A keyword defined in keyword set number 8. The class must be
  67. //! sub-classed and re-implement keywords() to make use of this style.
  68. KeywordSet8 = 16
  69. };
  70. //! Construct a QsciLexerPOV with parent \a parent. \a parent is typically
  71. //! the QsciScintilla instance.
  72. QsciLexerPOV(QObject *parent = 0);
  73. //! Destroys the QsciLexerPOV instance.
  74. virtual ~QsciLexerPOV();
  75. //! Returns the name of the language.
  76. const char *language() const;
  77. //! Returns the name of the lexer. Some lexers support a number of
  78. //! languages.
  79. const char *lexer() const;
  80. //! \internal Returns the style used for braces for brace matching.
  81. int braceStyle() const;
  82. //! Returns the string of characters that comprise a word.
  83. const char *wordCharacters() const;
  84. //! Returns the foreground colour of the text for style number \a style.
  85. //!
  86. //! \sa defaultPaper()
  87. QColor defaultColor(int style) const;
  88. //! Returns the end-of-line fill for style number \a style.
  89. bool defaultEolFill(int style) const;
  90. //! Returns the font for style number \a style.
  91. QFont defaultFont(int style) const;
  92. //! Returns the background colour of the text for style number \a style.
  93. //!
  94. //! \sa defaultColor()
  95. QColor defaultPaper(int style) const;
  96. //! Returns the set of keywords for the keyword set \a set recognised
  97. //! by the lexer as a space separated string.
  98. const char *keywords(int set) const;
  99. //! Returns the descriptive name for style number \a style. If the
  100. //! style is invalid for this language then an empty QString is returned.
  101. //! This is intended to be used in user preference dialogs.
  102. QString description(int style) const;
  103. //! Causes all properties to be refreshed by emitting the propertyChanged()
  104. //! signal as required.
  105. void refreshProperties();
  106. //! Returns true if multi-line comment blocks can be folded.
  107. //!
  108. //! \sa setFoldComments()
  109. bool foldComments() const;
  110. //! Returns true if trailing blank lines are included in a fold block.
  111. //!
  112. //! \sa setFoldCompact()
  113. bool foldCompact() const;
  114. //! Returns true if directives can be folded.
  115. //!
  116. //! \sa setFoldDirectives()
  117. bool foldDirectives() const;
  118. public slots:
  119. //! If \a fold is true then multi-line comment blocks can be folded.
  120. //! The default is false.
  121. //!
  122. //! \sa foldComments()
  123. virtual void setFoldComments(bool fold);
  124. //! If \a fold is true then trailing blank lines are included in a fold
  125. //! block. The default is true.
  126. //!
  127. //! \sa foldCompact()
  128. virtual void setFoldCompact(bool fold);
  129. //! If \a fold is true then directives can be folded. The default is
  130. //! false.
  131. //!
  132. //! \sa foldDirectives()
  133. virtual void setFoldDirectives(bool fold);
  134. protected:
  135. //! The lexer's properties are read from the settings \a qs. \a prefix
  136. //! (which has a trailing '/') should be used as a prefix to the key of
  137. //! each setting. true is returned if there is no error.
  138. //!
  139. bool readProperties(QSettings &qs,const QString &prefix);
  140. //! The lexer's properties are written to the settings \a qs.
  141. //! \a prefix (which has a trailing '/') should be used as a prefix to
  142. //! the key of each setting. true is returned if there is no error.
  143. //!
  144. bool writeProperties(QSettings &qs,const QString &prefix) const;
  145. private:
  146. void setCommentProp();
  147. void setCompactProp();
  148. void setDirectiveProp();
  149. bool fold_comments;
  150. bool fold_compact;
  151. bool fold_directives;
  152. QsciLexerPOV(const QsciLexerPOV &);
  153. QsciLexerPOV &operator=(const QsciLexerPOV &);
  154. };
  155. #endif