diff --git a/examples/codeeditor.h b/examples/codeeditor.h index b9d5757..46a9719 100644 --- a/examples/codeeditor.h +++ b/examples/codeeditor.h @@ -1,63 +1,63 @@ /* Copyright (C) 2016 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef CODEEDITOR_H #define CODEEDITOR_H #include #include namespace KSyntaxHighlighting { class SyntaxHighlighter; } class CodeEditorSidebar; class CodeEditor : public QPlainTextEdit { Q_OBJECT public: explicit CodeEditor(QWidget *parent = nullptr); ~CodeEditor(); void openFile(const QString &fileName); protected: - void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + void contextMenuEvent(QContextMenuEvent *event) override; + void resizeEvent(QResizeEvent *event) override; private: friend class CodeEditorSidebar; void setTheme(const KSyntaxHighlighting::Theme &theme); int sidebarWidth() const; void sidebarPaintEvent(QPaintEvent *event); void updateSidebarGeometry(); void updateSidebarArea(const QRect &rect, int dy); void highlightCurrentLine(); QTextBlock blockAtPosition(int y) const; bool isFoldable(const QTextBlock &block) const; bool isFolded(const QTextBlock &block) const; void toggleFold(const QTextBlock &block); KSyntaxHighlighting::Repository m_repository; KSyntaxHighlighting::SyntaxHighlighter *m_highlighter; CodeEditorSidebar *m_sideBar; }; #endif // CODEEDITOR_H diff --git a/src/lib/htmlhighlighter.h b/src/lib/htmlhighlighter.h index b5c531a..a52fdb7 100644 --- a/src/lib/htmlhighlighter.h +++ b/src/lib/htmlhighlighter.h @@ -1,54 +1,54 @@ /* Copyright (C) 2016 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef KSYNTAXHIGHLIGHTING_HTMLHIGHLIGHTER_H #define KSYNTAXHIGHLIGHTING_HTMLHIGHLIGHTER_H #include "ksyntaxhighlighting_export.h" #include "abstracthighlighter.h" #include #include class QFile; class QTextStream; namespace KSyntaxHighlighting { class HtmlHighlighterPrivate; class KSYNTAXHIGHLIGHTING_EXPORT HtmlHighlighter : public AbstractHighlighter { public: HtmlHighlighter(); - ~HtmlHighlighter() Q_DECL_OVERRIDE; + ~HtmlHighlighter() override; void highlightFile(const QString &fileName); void setOutputFile(const QString &fileName); void setOutputFile(FILE *fileHandle); protected: - void applyFormat(int offset, int length, const Format &format) Q_DECL_OVERRIDE; + void applyFormat(int offset, int length, const Format &format) override; private: std::unique_ptr d; }; } #endif // KSYNTAXHIGHLIGHTING_HTMLHIGHLIGHTER_H diff --git a/src/lib/rule_p.h b/src/lib/rule_p.h index 71d26f6..2532e6e 100644 --- a/src/lib/rule_p.h +++ b/src/lib/rule_p.h @@ -1,254 +1,254 @@ /* Copyright (C) 2016 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef KSYNTAXHIGHLIGHTING_RULE_P_H #define KSYNTAXHIGHLIGHTING_RULE_P_H #include "contextswitch_p.h" #include "definition.h" #include "definitionref_p.h" #include "foldingregion.h" #include "keywordlist_p.h" #include "matchresult_p.h" #include #include #include #include class QXmlStreamReader; namespace KSyntaxHighlighting { class Rule { public: Rule(); virtual ~Rule(); typedef std::shared_ptr Ptr; Definition definition() const; void setDefinition(const Definition &def); QString attribute() const; ContextSwitch context() const; bool isLookAhead() const; bool isDynamic() const; bool firstNonSpace() const; int requiredColumn() const; FoldingRegion beginRegion() const; FoldingRegion endRegion() const; bool load(QXmlStreamReader &reader); void resolveContext(); MatchResult match(const QString &text, int offset, const QStringList &captures); static Rule::Ptr create(const QStringRef &name); protected: virtual bool doLoad(QXmlStreamReader &reader); virtual MatchResult doMatch(const QString &text, int offset, const QStringList &captures) = 0; bool isDelimiter(QChar c) const; private: Q_DISABLE_COPY(Rule) DefinitionRef m_def; QString m_attribute; ContextSwitch m_context; QVector m_subRules; int m_column; FoldingRegion m_beginRegion; FoldingRegion m_endRegion; bool m_firstNonSpace; bool m_lookAhead; bool m_dynamic; }; class AnyChar : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; private: QString m_chars; }; class DetectChar : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList &captures) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList &captures) override; private: QChar m_char; int m_captureIndex; }; class Detect2Char : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList &captures) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList &captures) override; private: QChar m_char1; QChar m_char2; }; class DetectIdentifier : public Rule { protected: - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; }; class DetectSpaces : public Rule { protected: - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; }; class Float : public Rule { protected: - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; }; class IncludeRules : public Rule { public: QString contextName() const; QString definitionName() const; bool includeAttribute() const; protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; private: QString m_contextName; QString m_defName; bool m_includeAttribute; }; class Int : public Rule { protected: - MatchResult doMatch(const QString & text, int offset, const QStringList &captures) Q_DECL_OVERRIDE; + MatchResult doMatch(const QString & text, int offset, const QStringList &captures) override; }; class HlCChar : public Rule { protected: - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; }; class HlCHex : public Rule { protected: - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; }; class HlCOct : public Rule { protected: - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; }; class HlCStringChar : public Rule { protected: - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; }; class KeywordListRule : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; private: QString m_listName; KeywordList m_keywordList; bool m_hasCaseSensitivityOverride; Qt::CaseSensitivity m_caseSensitivityOverride; }; class LineContinue : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; private: QChar m_char; }; class RangeDetect : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList&) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList&) override; private: QChar m_begin; QChar m_end; }; class RegExpr : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList &captures) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList &captures) override; private: QString m_pattern; QRegularExpression m_regexp; }; class StringDetect : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList &captures) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList &captures) override; private: QString m_string; Qt::CaseSensitivity m_caseSensitivity; }; class WordDetect : public Rule { protected: - bool doLoad(QXmlStreamReader & reader) Q_DECL_OVERRIDE; - MatchResult doMatch(const QString & text, int offset, const QStringList &captures) Q_DECL_OVERRIDE; + bool doLoad(QXmlStreamReader & reader) override; + MatchResult doMatch(const QString & text, int offset, const QStringList &captures) override; private: QString m_word; Qt::CaseSensitivity m_caseSensitivity; }; } #endif // KSYNTAXHIGHLIGHTING_RULE_P_H diff --git a/src/lib/syntaxhighlighter.h b/src/lib/syntaxhighlighter.h index 4a4a11c..f901255 100644 --- a/src/lib/syntaxhighlighter.h +++ b/src/lib/syntaxhighlighter.h @@ -1,79 +1,79 @@ /* Copyright (C) 2016 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef KSYNTAXHIGHLIGHTING_QSYNTAXHIGHLIGHTER_H #define KSYNTAXHIGHLIGHTING_QSYNTAXHIGHLIGHTER_H #include "ksyntaxhighlighting_export.h" #include "abstracthighlighter.h" #include namespace KSyntaxHighlighting { class SyntaxHighlighterPrivate; /** A QSyntaxHighlighter implementation for use with QTextDocument. * This supports partial re-highlighting during editing and * tracks syntax-based code folding regions. * * @since 5.28 */ class KSYNTAXHIGHLIGHTING_EXPORT SyntaxHighlighter : public QSyntaxHighlighter, public AbstractHighlighter { Q_OBJECT public: explicit SyntaxHighlighter(QObject *parent = nullptr); explicit SyntaxHighlighter(QTextDocument *document); - ~SyntaxHighlighter() Q_DECL_OVERRIDE; + ~SyntaxHighlighter() override; - void setDefinition(const Definition &def) Q_DECL_OVERRIDE; + void setDefinition(const Definition &def) override; /** Returns whether there is a folding region beginning at @p startBlock. * This only considers syntax-based folding regions, * not indention-based ones as e.g. found in Python. * * @see findFoldingRegionEnd */ bool startsFoldingRegion(const QTextBlock &startBlock) const; /** Finds the end of the folding region starting at @p startBlock. * If multiple folding regions begin at @p startBlock, the end of * the last/innermost one is returned. * This returns an invalid block if no folding region end is found, * which typically indicates an unterminated region and thus folding * until the document end. * This method performs a sequential search starting at @p startBlock * for the matching folding region end, which is a potentially expensive * operation. * * @see startsFoldingRegion */ QTextBlock findFoldingRegionEnd(const QTextBlock &startBlock) const; protected: - void highlightBlock(const QString & text) Q_DECL_OVERRIDE; - void applyFormat(int offset, int length, const Format &format) Q_DECL_OVERRIDE; - void applyFolding(int offset, int length, FoldingRegion region) Q_DECL_OVERRIDE; + void highlightBlock(const QString & text) override; + void applyFormat(int offset, int length, const Format &format) override; + void applyFolding(int offset, int length, FoldingRegion region) override; private: Q_DECLARE_PRIVATE_D(AbstractHighlighter::d_ptr, SyntaxHighlighter) }; } #endif // KSYNTAXHIGHLIGHTING_QSYNTAXHIGHLIGHTER_H