diff options
| author | hjk <hjk@qt.io> | 2023-12-21 17:31:38 +0100 |
|---|---|---|
| committer | hjk <hjk@qt.io> | 2024-01-12 06:53:40 +0000 |
| commit | 052ea6d23185943f12cccbf70df0ea52fc0171ba (patch) | |
| tree | 8011517a3e5e16c34ce14d3c82861ad76e1e3bed /src/plugins/python/pythonhighlighter.cpp | |
| parent | 460b1641e0f950f9ba163100763b0fbdc9fb707a (diff) | |
Python: Move highlighter and indenter class definitions to .cpp
Change-Id: Ib71d520977034ca66bd84c9188ffed5fe74e1ba0
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/python/pythonhighlighter.cpp')
| -rw-r--r-- | src/plugins/python/pythonhighlighter.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/plugins/python/pythonhighlighter.cpp b/src/plugins/python/pythonhighlighter.cpp index cc3b468f46f..14933eabaf7 100644 --- a/src/plugins/python/pythonhighlighter.cpp +++ b/src/plugins/python/pythonhighlighter.cpp @@ -17,10 +17,10 @@ #include <texteditor/textdocument.h> #include <texteditor/textdocumentlayout.h> #include <texteditor/texteditorconstants.h> + #include <utils/qtcassert.h> -namespace Python { -namespace Internal { +namespace Python::Internal { /** * @class PythonEditor::Internal::PythonHighlighter @@ -67,10 +67,22 @@ static TextEditor::TextStyle styleForFormat(int format) return C_TEXT; } -PythonHighlighter::PythonHighlighter() +class PythonHighlighter : public TextEditor::SyntaxHighlighter { - setTextFormatCategories(Format_FormatsAmount, styleForFormat); -} +public: + PythonHighlighter() + { + setTextFormatCategories(Format_FormatsAmount, styleForFormat); + } + +private: + void highlightBlock(const QString &text) override; + int highlightLine(const QString &text, int initialState); + void highlightImport(Internal::Scanner &scanner); + + int m_lastIndent = 0; + bool withinLicenseHeader = false; +}; /** * @brief PythonHighlighter::highlightBlock highlights single line of Python code @@ -187,5 +199,9 @@ void PythonHighlighter::highlightImport(Scanner &scanner) } } -} // namespace Internal -} // namespace Python +TextEditor::SyntaxHighlighter *createPythonHighlighter() +{ + return new PythonHighlighter; +} + +} // namespace Python::Internal |
