qscilexerbash.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // This defines the interface to the QsciLexerBash 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 QSCILEXERBASH_H
  20. #define QSCILEXERBASH_H
  21. #include <QObject>
  22. #include <Qsci/qsciglobal.h>
  23. #include <Qsci/qscilexer.h>
  24. //! \brief The QsciLexerBash class encapsulates the Scintilla Bash lexer.
  25. class QSCINTILLA_EXPORT QsciLexerBash : public QsciLexer
  26. {
  27. Q_OBJECT
  28. public:
  29. //! This enum defines the meanings of the different styles used by the
  30. //! Bash lexer.
  31. enum {
  32. //! The default.
  33. Default = 0,
  34. //! An error.
  35. Error = 1,
  36. //! A comment.
  37. Comment = 2,
  38. //! A number.
  39. Number = 3,
  40. //! A keyword.
  41. Keyword = 4,
  42. //! A double-quoted string.
  43. DoubleQuotedString = 5,
  44. //! A single-quoted string.
  45. SingleQuotedString = 6,
  46. //! An operator.
  47. Operator = 7,
  48. //! An identifier
  49. Identifier = 8,
  50. //! A scalar.
  51. Scalar = 9,
  52. //! Parameter expansion.
  53. ParameterExpansion = 10,
  54. //! Backticks.
  55. Backticks = 11,
  56. //! A here document delimiter.
  57. HereDocumentDelimiter = 12,
  58. //! A single quoted here document.
  59. SingleQuotedHereDocument = 13
  60. };
  61. //! Construct a QsciLexerBash with parent \a parent. \a parent is
  62. //! typically the QsciScintilla instance.
  63. QsciLexerBash(QObject *parent = 0);
  64. //! Destroys the QsciLexerBash instance.
  65. virtual ~QsciLexerBash();
  66. //! Returns the name of the language.
  67. const char *language() const;
  68. //! Returns the name of the lexer. Some lexers support a number of
  69. //! languages.
  70. const char *lexer() const;
  71. //! \internal Returns the style used for braces for brace matching.
  72. int braceStyle() const;
  73. //! Returns the string of characters that comprise a word.
  74. const char *wordCharacters() const;
  75. //! Returns the foreground colour of the text for style number \a style.
  76. //!
  77. //! \sa defaultPaper()
  78. QColor defaultColor(int style) const;
  79. //! Returns the end-of-line fill for style number \a style.
  80. bool defaultEolFill(int style) const;
  81. //! Returns the font for style number \a style.
  82. QFont defaultFont(int style) const;
  83. //! Returns the background colour of the text for style number \a style.
  84. //!
  85. //! \sa defaultColor()
  86. QColor defaultPaper(int style) const;
  87. //! Returns the set of keywords for the keyword set \a set recognised
  88. //! by the lexer as a space separated string.
  89. const char *keywords(int set) const;
  90. //! Returns the descriptive name for style number \a style. If the
  91. //! style is invalid for this language then an empty QString is returned.
  92. //! This is intended to be used in user preference dialogs.
  93. QString description(int style) const;
  94. //! Causes all properties to be refreshed by emitting the
  95. //! propertyChanged() signal as required.
  96. void refreshProperties();
  97. //! Returns true if multi-line comment blocks can be folded.
  98. //!
  99. //! \sa setFoldComments()
  100. bool foldComments() const;
  101. //! Returns true if trailing blank lines are included in a fold block.
  102. //!
  103. //! \sa setFoldCompact()
  104. bool foldCompact() const;
  105. public slots:
  106. //! If \a fold is true then multi-line comment blocks can be folded.
  107. //! The default is false.
  108. //!
  109. //! \sa foldComments()
  110. virtual void setFoldComments(bool fold);
  111. //! If \a fold is true then trailing blank lines are included in a fold
  112. //! block. The default is true.
  113. //!
  114. //! \sa foldCompact()
  115. virtual void setFoldCompact(bool fold);
  116. protected:
  117. //! The lexer's properties are read from the settings \a qs. \a prefix
  118. //! (which has a trailing '/') should be used as a prefix to the key of
  119. //! each setting. true is returned if there is no error.
  120. //!
  121. bool readProperties(QSettings &qs,const QString &prefix);
  122. //! The lexer's properties are written to the settings \a qs.
  123. //! \a prefix (which has a trailing '/') should be used as a prefix to
  124. //! the key of each setting. true is returned if there is no error.
  125. //!
  126. bool writeProperties(QSettings &qs,const QString &prefix) const;
  127. private:
  128. void setCommentProp();
  129. void setCompactProp();
  130. bool fold_comments;
  131. bool fold_compact;
  132. QsciLexerBash(const QsciLexerBash &);
  133. QsciLexerBash &operator=(const QsciLexerBash &);
  134. };
  135. #endif