aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/glsleditor/glslindenter.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-12-21 15:59:18 +0100
committerhjk <hjk@qt.io>2024-01-09 12:41:06 +0000
commitcca5f07d35dbd7454b57409dea11126f02b1a66f (patch)
treec786745f2da6f795331c5e9e7ab2457ae055d78a /src/plugins/glsleditor/glslindenter.cpp
parent32e6f731192fa27aaaebef3e99afc16546222931 (diff)
GlslEditor: Move some class definitions to .cpp
Also, de-Q_OBJECT-ify GlslHighlighter and a bit of code cosmetics. Change-Id: I17469acc950fc77055f68918b1362f01e8a8c8a3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/glsleditor/glslindenter.cpp')
-rw-r--r--src/plugins/glsleditor/glslindenter.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/plugins/glsleditor/glslindenter.cpp b/src/plugins/glsleditor/glslindenter.cpp
index 7a8dcbbb28..8a14112327 100644
--- a/src/plugins/glsleditor/glslindenter.cpp
+++ b/src/plugins/glsleditor/glslindenter.cpp
@@ -8,18 +8,37 @@
#include <cppeditor/cppcodestylepreferences.h>
#include <texteditor/tabsettings.h>
-#include <QChar>
#include <QTextDocument>
#include <QTextBlock>
#include <QTextCursor>
-namespace GlslEditor {
-namespace Internal {
+namespace GlslEditor::Internal {
-GlslIndenter::GlslIndenter(QTextDocument *doc)
- : TextEditor::TextIndenter(doc)
-{}
-GlslIndenter::~GlslIndenter() = default;
+class GlslIndenter final : public TextEditor::TextIndenter
+{
+public:
+ explicit GlslIndenter(QTextDocument *doc)
+ : TextEditor::TextIndenter(doc)
+ {}
+
+ bool isElectricCharacter(const QChar &ch) const final;
+ void indentBlock(const QTextBlock &block,
+ const QChar &typedChar,
+ const TextEditor::TabSettings &tabSettings,
+ int cursorPositionInEditor = -1) final;
+
+ void indent(const QTextCursor &cursor,
+ const QChar &typedChar,
+ const TextEditor::TabSettings &tabSettings,
+ int cursorPositionInEditor = -1) final;
+
+ int indentFor(const QTextBlock &block,
+ const TextEditor::TabSettings &tabSettings,
+ int cursorPositionInEditor = -1) final;
+ TextEditor::IndentationForBlock indentationForBlocks(const QVector<QTextBlock> &blocks,
+ const TextEditor::TabSettings &tabSettings,
+ int cursorPositionInEditor = -1) final;
+};
bool GlslIndenter::isElectricCharacter(const QChar &ch) const
{
@@ -120,5 +139,9 @@ TextEditor::IndentationForBlock GlslIndenter::indentationForBlocks(
return ret;
}
-} // namespace Internal
-} // namespace GlslEditor
+TextEditor::TextIndenter *createGlslIndenter(QTextDocument *doc)
+{
+ return new GlslIndenter(doc);
+}
+
+} // GlslEditor::Internal