forked from qt-creator/qt-creator
SyntaxHighlighter: Move highlighter creating to TextDocument
Added setSyntaxHighlighterCreator function to TextDocument which allows the creation of highlighters inside TextDocument. Change-Id: I454f800c878c48a154dad5abd68b7a4f9ceb378a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -3690,16 +3690,19 @@ void TextEditorWidgetPrivate::removeSyntaxInfoBar()
|
||||
void TextEditorWidgetPrivate::configureGenericHighlighter(
|
||||
const KSyntaxHighlighting::Definition &definition)
|
||||
{
|
||||
auto highlighter = new Highlighter();
|
||||
m_document->setSyntaxHighlighter(highlighter);
|
||||
|
||||
if (definition.isValid()) {
|
||||
highlighter->setDefinition(definition);
|
||||
setupFromDefinition(definition);
|
||||
} else {
|
||||
q->setCodeFoldingSupported(false);
|
||||
}
|
||||
|
||||
m_document->setSyntaxHighlighterCreator([definition] {
|
||||
auto highlighter = new Highlighter();
|
||||
if (definition.isValid())
|
||||
highlighter->setDefinition(definition);
|
||||
return highlighter;
|
||||
});
|
||||
|
||||
m_document->setFontSettings(TextEditorSettings::fontSettings());
|
||||
}
|
||||
|
||||
@@ -6222,8 +6225,7 @@ void TextEditorWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
if (self && self->openLink(symbolLink, inNextSplit))
|
||||
self->d->clearLink();
|
||||
}, true, inNextSplit);
|
||||
} else if (button == Qt::MiddleButton
|
||||
&& !isReadOnly()
|
||||
} else if (button == Qt::MiddleButton && !isReadOnly()
|
||||
&& QGuiApplication::clipboard()->supportsSelection()) {
|
||||
if (!(e->modifiers() & Qt::AltModifier))
|
||||
doSetTextCursor(cursorForPosition(e->pos()));
|
||||
@@ -6302,12 +6304,10 @@ void TextEditorWidget::keyReleaseEvent(QKeyEvent *e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Control) {
|
||||
d->clearLink();
|
||||
} else if (e->key() == Qt::Key_Shift
|
||||
&& d->m_behaviorSettings.m_constrainHoverTooltips
|
||||
&& ToolTip::isVisible()) {
|
||||
} else if (e->key() == Qt::Key_Shift && d->m_behaviorSettings.m_constrainHoverTooltips
|
||||
&& ToolTip::isVisible()) {
|
||||
ToolTip::hide();
|
||||
} else if (e->key() == Qt::Key_Alt
|
||||
&& d->m_maybeFakeTooltipEvent) {
|
||||
} else if (e->key() == Qt::Key_Alt && d->m_maybeFakeTooltipEvent) {
|
||||
d->m_maybeFakeTooltipEvent = false;
|
||||
d->processTooltipRequest(textCursor());
|
||||
}
|
||||
@@ -6912,7 +6912,9 @@ void TextEditorWidget::findTypeAt(const QTextCursor &cursor,
|
||||
bool TextEditorWidget::openLink(const Utils::Link &link, bool inNextSplit)
|
||||
{
|
||||
#ifdef WITH_TESTS
|
||||
struct Signaller { ~Signaller() { emit EditorManager::instance()->linkOpened(); } } s;
|
||||
struct Signaller {
|
||||
~Signaller() { emit EditorManager::instance()->linkOpened(); }
|
||||
} s;
|
||||
#endif
|
||||
|
||||
if (!link.hasValidTarget())
|
||||
@@ -9442,7 +9444,7 @@ void TextEditorFactory::setEditorCreator(const EditorCreator &creator)
|
||||
doc->setIndenter(d->m_indenterCreator(doc->document()));
|
||||
|
||||
if (d->m_syntaxHighlighterCreator)
|
||||
doc->setSyntaxHighlighter(d->m_syntaxHighlighterCreator());
|
||||
doc->setSyntaxHighlighterCreator(d->m_syntaxHighlighterCreator);
|
||||
|
||||
doc->setCompletionAssistProvider(d->m_completionAssistProvider ? d->m_completionAssistProvider
|
||||
: &basicSnippetProvider);
|
||||
|
||||
Reference in New Issue
Block a user