qscilexerpo.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // This defines the interface to the QsciLexerPO 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 QSCILEXERPO_H
  20. #define QSCILEXERPO_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerPO class encapsulates the Scintilla PO lexer.
  25. class QSCINTILLA_EXPORT QsciLexerPO : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! PO lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! A comment.
  35. Comment = 1,
  36. //! A message identifier.
  37. MessageId = 2,
  38. //! The text of a message identifier.
  39. MessageIdText = 3,
  40. //! A message string.
  41. MessageString = 4,
  42. //! The text of a message string.
  43. MessageStringText = 5,
  44. //! A message context.
  45. MessageContext = 6,
  46. //! The text of a message context.
  47. MessageContextText = 7,
  48. //! The "fuzzy" flag.
  49. Fuzzy = 8,
  50. //! A programmer comment.
  51. ProgrammerComment = 9,
  52. //! A reference.
  53. Reference = 10,
  54. //! A flag.
  55. Flags = 11,
  56. //! A message identifier text end-of-line.
  57. MessageIdTextEOL = 12,
  58. //! A message string text end-of-line.
  59. MessageStringTextEOL = 13,
  60. //! A message context text end-of-line.
  61. MessageContextTextEOL = 14
  62. };
  63. //! Construct a QsciLexerPO with parent \a parent. \a parent is typically
  64. //! the QsciScintilla instance.
  65. QsciLexerPO(QObject *parent = 0);
  66. //! Destroys the QsciLexerPO instance.
  67. virtual ~QsciLexerPO();
  68. //! Returns the name of the language.
  69. const char *language() const;
  70. //! Returns the name of the lexer. Some lexers support a number of
  71. //! languages.
  72. const char *lexer() const;
  73. //! Returns the foreground colour of the text for style number \a style.
  74. //!
  75. //! \sa defaultPaper()
  76. QColor defaultColor(int style) const;
  77. //! Returns the font for style number \a style.
  78. QFont defaultFont(int style) const;
  79. //! Returns the descriptive name for style number \a style. If the
  80. //! style is invalid for this language then an empty QString is returned.
  81. //! This is intended to be used in user preference dialogs.
  82. QString description(int style) const;
  83. //! Causes all properties to be refreshed by emitting the propertyChanged()
  84. //! signal as required.
  85. void refreshProperties();
  86. //! Returns true if multi-line comment blocks can be folded.
  87. //!
  88. //! \sa setFoldComments()
  89. bool foldComments() const;
  90. //! Returns true if trailing blank lines are included in a fold block.
  91. //!
  92. //! \sa setFoldCompact()
  93. bool foldCompact() const;
  94. public slots:
  95. //! If \a fold is true then multi-line comment blocks can be folded.
  96. //! The default is false.
  97. //!
  98. //! \sa foldComments()
  99. virtual void setFoldComments(bool fold);
  100. //! If \a fold is true then trailing blank lines are included in a fold
  101. //! block. The default is true.
  102. //!
  103. //! \sa foldCompact()
  104. virtual void setFoldCompact(bool fold);
  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. bool fold_comments;
  120. bool fold_compact;
  121. QsciLexerPO(const QsciLexerPO &);
  122. QsciLexerPO &operator=(const QsciLexerPO &);
  123. };
  124. #endif