qscilexercmake.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // This defines the interface to the QsciLexerCMake 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 QSCILEXERCMAKE_H
  20. #define QSCILEXERCMAKE_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerCMake class encapsulates the Scintilla CMake lexer.
  25. class QSCINTILLA_EXPORT QsciLexerCMake : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! CMake lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! A comment.
  35. Comment = 1,
  36. //! A string.
  37. String = 2,
  38. //! A left quoted string.
  39. StringLeftQuote = 3,
  40. //! A right quoted string.
  41. StringRightQuote = 4,
  42. //! A function. (Defined by keyword set number 1.)
  43. Function = 5,
  44. //! A variable. (Defined by keyword set number 2.)
  45. Variable = 6,
  46. //! A label.
  47. Label = 7,
  48. //! A keyword defined in keyword set number 3. The class must be
  49. //! sub-classed and re-implement keywords() to make use of this style.
  50. KeywordSet3 = 8,
  51. //! A WHILE block.
  52. BlockWhile = 9,
  53. //! A FOREACH block.
  54. BlockForeach = 10,
  55. //! An IF block.
  56. BlockIf = 11,
  57. //! A MACRO block.
  58. BlockMacro = 12,
  59. //! A variable within a string.
  60. StringVariable = 13,
  61. //! A number.
  62. Number = 14
  63. };
  64. //! Construct a QsciLexerCMake with parent \a parent. \a parent is
  65. //! typically the QsciScintilla instance.
  66. QsciLexerCMake(QObject *parent = 0);
  67. //! Destroys the QsciLexerCMake instance.
  68. virtual ~QsciLexerCMake();
  69. //! Returns the name of the language.
  70. const char *language() const;
  71. //! Returns the name of the lexer. Some lexers support a number of
  72. //! languages.
  73. const char *lexer() const;
  74. //! Returns the foreground colour of the text for style number \a style.
  75. //!
  76. //! \sa defaultPaper()
  77. QColor defaultColor(int style) const;
  78. //! Returns the font for style number \a style.
  79. QFont defaultFont(int style) const;
  80. //! Returns the background colour of the text for style number \a style.
  81. //!
  82. //! \sa defaultColor()
  83. QColor defaultPaper(int style) const;
  84. //! Returns the set of keywords for the keyword set \a set recognised
  85. //! by the lexer as a space separated string.
  86. const char *keywords(int set) const;
  87. //! Returns the descriptive name for style number \a style. If the
  88. //! style is invalid for this language then an empty QString is returned.
  89. //! This is intended to be used in user preference dialogs.
  90. QString description(int style) const;
  91. //! Causes all properties to be refreshed by emitting the propertyChanged()
  92. //! signal as required.
  93. void refreshProperties();
  94. //! Returns true if ELSE blocks can be folded.
  95. //!
  96. //! \sa setFoldAtElse()
  97. bool foldAtElse() const;
  98. public slots:
  99. //! If \a fold is true then ELSE blocks can be folded. The default is
  100. //! false.
  101. //!
  102. //! \sa foldAtElse()
  103. virtual void setFoldAtElse(bool fold);
  104. protected:
  105. //! The lexer's properties are read from the settings \a qs. \a prefix
  106. //! (which has a trailing '/') should be used as a prefix to the key of
  107. //! each setting. true is returned if there is no error.
  108. //!
  109. bool readProperties(QSettings &qs,const QString &prefix);
  110. //! The lexer's properties are written to the settings \a qs.
  111. //! \a prefix (which has a trailing '/') should be used as a prefix to
  112. //! the key of each setting. true is returned if there is no error.
  113. //!
  114. bool writeProperties(QSettings &qs,const QString &prefix) const;
  115. private:
  116. void setAtElseProp();
  117. bool fold_atelse;
  118. QsciLexerCMake(const QsciLexerCMake &);
  119. QsciLexerCMake &operator=(const QsciLexerCMake &);
  120. };
  121. #endif