TextEditor: Add selecting highlighter by name

Change-Id: I5c706dd151173bf08c5fbd4dacbf6e5d6416b87b
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-10-17 09:23:25 +02:00
parent f2934f8497
commit d8a75d48a3
3 changed files with 12 additions and 1 deletions

View File

@@ -13,7 +13,8 @@
namespace TextEditor { namespace TextEditor {
class TextDocument; class TextDocument;
class Highlighter : public SyntaxHighlighter, public KSyntaxHighlighting::AbstractHighlighter class TEXTEDITOR_EXPORT Highlighter : public SyntaxHighlighter,
public KSyntaxHighlighting::AbstractHighlighter
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(KSyntaxHighlighting::AbstractHighlighter) Q_INTERFACES(KSyntaxHighlighting::AbstractHighlighter)

View File

@@ -9068,6 +9068,12 @@ void TextEditorWidget::configureGenericHighlighter(const Utils::MimeType &mimeTy
d->removeSyntaxInfoBar(); d->removeSyntaxInfoBar();
} }
void TextEditorWidget::configureGenericHighlighter(const Highlighter::Definition &definition)
{
d->configureGenericHighlighter(definition);
d->removeSyntaxInfoBar();
}
int TextEditorWidget::blockNumberForVisibleRow(int row) const int TextEditorWidget::blockNumberForVisibleRow(int row) const
{ {
QTextBlock block = blockForVisibleRow(row); QTextBlock block = blockForVisibleRow(row);

View File

@@ -6,6 +6,7 @@
#include "texteditor_global.h" #include "texteditor_global.h"
#include "codeassist/assistenums.h" #include "codeassist/assistenums.h"
#include "highlighter.h"
#include "indenter.h" #include "indenter.h"
#include "refactoroverlay.h" #include "refactoroverlay.h"
#include "snippets/snippetparser.h" #include "snippets/snippetparser.h"
@@ -453,6 +454,9 @@ public:
/// Overwrite the current highlighter with a new generic highlighter based on the given mimetype /// Overwrite the current highlighter with a new generic highlighter based on the given mimetype
void configureGenericHighlighter(const Utils::MimeType &mimeType); void configureGenericHighlighter(const Utils::MimeType &mimeType);
/// Overwrite the current highlighter with a new generic highlighter based on the given definition
void configureGenericHighlighter(const Highlighter::Definition &definition);
Q_INVOKABLE void inSnippetMode(bool *active); // Used by FakeVim. Q_INVOKABLE void inSnippetMode(bool *active); // Used by FakeVim.
/*! Returns the document line number for the visible \a row. /*! Returns the document line number for the visible \a row.