blob: f58d7bc435def3ba6215db8b11fca85a5bb191b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include "syntaxhighlighter.h"
#include <utils/fileutils.h>
#include <KSyntaxHighlighting/AbstractHighlighter>
#include <KSyntaxHighlighting/Definition>
namespace TextEditor {
class TextDocument;
class Highlighter : public SyntaxHighlighter, public KSyntaxHighlighting::AbstractHighlighter
{
Q_OBJECT
Q_INTERFACES(KSyntaxHighlighting::AbstractHighlighter)
public:
using Definition = KSyntaxHighlighting::Definition;
using Definitions = QList<Definition>;
Highlighter();
static Definition definitionForName(const QString &name);
static Definitions definitionsForDocument(const TextDocument *document);
static Definitions definitionsForMimeType(const QString &mimeType);
static Definitions definitionsForFileName(const Utils::FilePath &fileName);
static void rememberDefinitionForDocument(const Definition &definition,
const TextDocument *document);
static void clearDefinitionForDocumentCache();
static void addCustomHighlighterPath(const Utils::FilePath &path);
static void downloadDefinitions(std::function<void()> callback = nullptr);
static void reload();
static void handleShutdown();
protected:
void highlightBlock(const QString &text) override;
void applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) override;
void applyFolding(int offset, int length, KSyntaxHighlighting::FoldingRegion region) override;
};
} // namespace TextEditor
|