qscilexertex.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // This defines the interface to the QsciLexerTeX 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 QSCILEXERTEX_H
  20. #define QSCILEXERTEX_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerTeX class encapsulates the Scintilla TeX lexer.
  25. class QSCINTILLA_EXPORT QsciLexerTeX : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! TeX lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! A special.
  35. Special = 1,
  36. //! A group.
  37. Group = 2,
  38. //! A symbol.
  39. Symbol = 3,
  40. //! A command.
  41. Command = 4,
  42. //! Text.
  43. Text = 5
  44. };
  45. //! Construct a QsciLexerTeX with parent \a parent. \a parent is typically
  46. //! the QsciScintilla instance.
  47. QsciLexerTeX(QObject *parent = 0);
  48. //! Destroys the QsciLexerTeX instance.
  49. virtual ~QsciLexerTeX();
  50. //! Returns the name of the language.
  51. const char *language() const;
  52. //! Returns the name of the lexer. Some lexers support a number of
  53. //! languages.
  54. const char *lexer() const;
  55. //! Returns the string of characters that comprise a word.
  56. const char *wordCharacters() const;
  57. //! Returns the foreground colour of the text for style number \a style.
  58. QColor defaultColor(int style) const;
  59. //! Returns the set of keywords for the keyword set \a set recognised
  60. //! by the lexer as a space separated string.
  61. const char *keywords(int set) const;
  62. //! Returns the descriptive name for style number \a style. If the
  63. //! style is invalid for this language then an empty QString is returned.
  64. //! This is intended to be used in user preference dialogs.
  65. QString description(int style) const;
  66. //! Causes all properties to be refreshed by emitting the
  67. //! propertyChanged() signal as required.
  68. void refreshProperties();
  69. //! If \a fold is true then multi-line comment blocks can be folded. The
  70. //! default is false.
  71. //!
  72. //! \sa foldComments()
  73. void setFoldComments(bool fold);
  74. //! Returns true if multi-line comment blocks can be folded.
  75. //!
  76. //! \sa setFoldComments()
  77. bool foldComments() const {return fold_comments;}
  78. //! If \a fold is true then trailing blank lines are included in a fold
  79. //! block. The default is true.
  80. //!
  81. //! \sa foldCompact()
  82. void setFoldCompact(bool fold);
  83. //! Returns true if trailing blank lines are included in a fold block.
  84. //!
  85. //! \sa setFoldCompact()
  86. bool foldCompact() const {return fold_compact;}
  87. //! If \a enable is true then comments are processed as TeX source
  88. //! otherwise they are ignored. The default is false.
  89. //!
  90. //! \sa processComments()
  91. void setProcessComments(bool enable);
  92. //! Returns true if comments are processed as TeX source.
  93. //!
  94. //! \sa setProcessComments()
  95. bool processComments() const {return process_comments;}
  96. //! If \a enable is true then \\if<unknown> processed is processed as a
  97. //! command. The default is true.
  98. //!
  99. //! \sa processIf()
  100. void setProcessIf(bool enable);
  101. //! Returns true if \\if<unknown> is processed as a command.
  102. //!
  103. //! \sa setProcessIf()
  104. bool processIf() const {return process_if;}
  105. protected:
  106. //! The lexer's properties are read from the settings \a qs. \a prefix
  107. //! (which has a trailing '/') should be used as a prefix to the key of
  108. //! each setting. true is returned if there is no error.
  109. //!
  110. bool readProperties(QSettings &qs, const QString &prefix);
  111. //! The lexer's properties are written to the settings \a qs.
  112. //! \a prefix (which has a trailing '/') should be used as a prefix to
  113. //! the key of each setting. true is returned if there is no error.
  114. //!
  115. bool writeProperties(QSettings &qs, const QString &prefix) const;
  116. private:
  117. void setCommentProp();
  118. void setCompactProp();
  119. void setProcessCommentsProp();
  120. void setAutoIfProp();
  121. bool fold_comments;
  122. bool fold_compact;
  123. bool process_comments;
  124. bool process_if;
  125. QsciLexerTeX(const QsciLexerTeX &);
  126. QsciLexerTeX &operator=(const QsciLexerTeX &);
  127. };
  128. #endif