qscilexerproperties.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // This defines the interface to the QsciLexerProperties 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 QSCILEXERPROPERTIES_H
  20. #define QSCILEXERPROPERTIES_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerProperties class encapsulates the Scintilla
  25. //! Properties lexer.
  26. class QSCINTILLA_EXPORT QsciLexerProperties : public QsciLexer
  27. {
  28. Q_OBJECT
  29. public:
  30. //! This enum defines the meanings of the different styles used by the
  31. //! Properties lexer.
  32. enum {
  33. //! The default.
  34. Default = 0,
  35. //! A comment.
  36. Comment = 1,
  37. //! A section.
  38. Section = 2,
  39. //! An assignment operator.
  40. Assignment = 3,
  41. //! A default value.
  42. DefaultValue = 4,
  43. //! A key.
  44. Key = 5
  45. };
  46. //! Construct a QsciLexerProperties with parent \a parent. \a parent is
  47. //! typically the QsciScintilla instance.
  48. QsciLexerProperties(QObject *parent = 0);
  49. //! Destroys the QsciLexerProperties instance.
  50. virtual ~QsciLexerProperties();
  51. //! Returns the name of the language.
  52. const char *language() const;
  53. //! Returns the name of the lexer. Some lexers support a number of
  54. //! languages.
  55. const char *lexer() const;
  56. //! Returns the string of characters that comprise a word.
  57. const char *wordCharacters() const;
  58. //! Returns the foreground colour of the text for style number \a style.
  59. //!
  60. //! \sa defaultPaper()
  61. QColor defaultColor(int style) const;
  62. //! Returns the end-of-line fill for style number \a style.
  63. bool defaultEolFill(int style) const;
  64. //! Returns the font for style number \a style.
  65. QFont defaultFont(int style) const;
  66. //! Returns the background colour of the text for style number \a style.
  67. //!
  68. //! \sa defaultColor()
  69. QColor defaultPaper(int style) const;
  70. //! Returns the descriptive name for style number \a style. If the style
  71. //! is invalid for this language then an empty QString is returned. This
  72. //! is intended to be used in user preference dialogs.
  73. QString description(int style) const;
  74. //! Causes all properties to be refreshed by emitting the
  75. //! propertyChanged() signal as required.
  76. void refreshProperties();
  77. //! Returns true if trailing blank lines are included in a fold block.
  78. //!
  79. //! \sa setFoldCompact()
  80. bool foldCompact() const {return fold_compact;}
  81. //! If \a enable is true then initial spaces in a line are allowed. The
  82. //! default is true.
  83. //!
  84. //! \sa initialSpaces()
  85. void setInitialSpaces(bool enable);
  86. //! Returns true if initial spaces in a line are allowed.
  87. //!
  88. //! \sa setInitialSpaces()
  89. bool initialSpaces() const {return initial_spaces;}
  90. public slots:
  91. //! If \a fold is true then trailing blank lines are included in a fold
  92. //! block. The default is true.
  93. //!
  94. //! \sa foldCompact()
  95. virtual void setFoldCompact(bool fold);
  96. protected:
  97. //! The lexer's properties are read from the settings \a qs. \a prefix
  98. //! (which has a trailing '/') should be used as a prefix to the key of
  99. //! each setting. true is returned if there is no error.
  100. //!
  101. //! \sa writeProperties()
  102. bool readProperties(QSettings &qs,const QString &prefix);
  103. //! The lexer's properties are written to the settings \a qs.
  104. //! \a prefix (which has a trailing '/') should be used as a prefix to
  105. //! the key of each setting. true is returned if there is no error.
  106. //!
  107. //! \sa readProperties()
  108. bool writeProperties(QSettings &qs,const QString &prefix) const;
  109. private:
  110. void setCompactProp();
  111. void setInitialSpacesProp();
  112. bool fold_compact;
  113. bool initial_spaces;
  114. QsciLexerProperties(const QsciLexerProperties &);
  115. QsciLexerProperties &operator=(const QsciLexerProperties &);
  116. };
  117. #endif