qscilexerpostscript.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. // This defines the interface to the QsciLexerPostScript 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 QSCILEXERPOSTSCRIPT_H
  20. #define QSCILEXERPOSTSCRIPT_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerPostScript class encapsulates the Scintilla PostScript
  25. //! lexer.
  26. class QSCINTILLA_EXPORT QsciLexerPostScript : public QsciLexer
  27. {
  28. Q_OBJECT
  29. public:
  30. //! This enum defines the meanings of the different styles used by the
  31. //! PostScript lexer.
  32. enum {
  33. //! The default.
  34. Default = 0,
  35. //! A comment.
  36. Comment = 1,
  37. //! A DSC comment.
  38. DSCComment = 2,
  39. //! A DSC comment value.
  40. DSCCommentValue = 3,
  41. //! A number.
  42. Number = 4,
  43. //! A name.
  44. Name = 5,
  45. //! A keyword.
  46. Keyword = 6,
  47. //! A literal.
  48. Literal = 7,
  49. //! An immediately evaluated literal.
  50. ImmediateEvalLiteral = 8,
  51. //! Array parenthesis.
  52. ArrayParenthesis = 9,
  53. //! Dictionary parenthesis.
  54. DictionaryParenthesis = 10,
  55. //! Procedure parenthesis.
  56. ProcedureParenthesis = 11,
  57. //! Text.
  58. Text = 12,
  59. //! A hexadecimal string.
  60. HexString = 13,
  61. //! A base85 string.
  62. Base85String = 14,
  63. //! A bad string character.
  64. BadStringCharacter = 15
  65. };
  66. //! Construct a QsciLexerPostScript with parent \a parent. \a parent is
  67. //! typically the QsciScintilla instance.
  68. QsciLexerPostScript(QObject *parent = 0);
  69. //! Destroys the QsciLexerPostScript instance.
  70. virtual ~QsciLexerPostScript();
  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 font for style number \a style.
  83. QFont defaultFont(int style) const;
  84. //! Returns the background colour of the text for style number \a style.
  85. //!
  86. //! \sa defaultColor()
  87. QColor defaultPaper(int style) const;
  88. //! Returns the set of keywords for the keyword set \a set recognised
  89. //! by the lexer as a space separated string. Set 5 can be used to provide
  90. //! additional user defined keywords.
  91. const char *keywords(int set) const;
  92. //! Returns the descriptive name for style number \a style. If the
  93. //! style is invalid for this language then an empty QString is returned.
  94. //! This is intended to be used in user preference dialogs.
  95. QString description(int style) const;
  96. //! Causes all properties to be refreshed by emitting the propertyChanged()
  97. //! signal as required.
  98. void refreshProperties();
  99. //! Returns true if tokens should be marked.
  100. //!
  101. //! \sa setTokenize()
  102. bool tokenize() const;
  103. //! Returns the PostScript level.
  104. //!
  105. //! \sa setLevel()
  106. int level() const;
  107. //! Returns true if trailing blank lines are included in a fold block.
  108. //!
  109. //! \sa setFoldCompact()
  110. bool foldCompact() const;
  111. //! Returns true if else blocks can be folded.
  112. //!
  113. //! \sa setFoldAtElse()
  114. bool foldAtElse() const;
  115. public slots:
  116. //! If \a tokenize is true then tokens are marked. The default is false.
  117. //!
  118. //! \sa tokenize()
  119. virtual void setTokenize(bool tokenize);
  120. //! The PostScript level is set to \a level. The default is 3.
  121. //!
  122. //! \sa level()
  123. virtual void setLevel(int level);
  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 else blocks can be folded. The default is
  130. //! false.
  131. //!
  132. //! \sa foldAtElse()
  133. virtual void setFoldAtElse(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 setTokenizeProp();
  147. void setLevelProp();
  148. void setCompactProp();
  149. void setAtElseProp();
  150. bool ps_tokenize;
  151. int ps_level;
  152. bool fold_compact;
  153. bool fold_atelse;
  154. QsciLexerPostScript(const QsciLexerPostScript &);
  155. QsciLexerPostScript &operator=(const QsciLexerPostScript &);
  156. };
  157. #endif