KSyntaxHighlighting

ansihighlighter.h
1/*
2 SPDX-FileCopyrightText: 2020 Jonathan Poelen <jonathan.poelen@gmail.com>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef KSYNTAXHIGHLIGHTING_ANSIHIGHLIGHTER_H
8#define KSYNTAXHIGHLIGHTING_ANSIHIGHLIGHTER_H
9
10#include "abstracthighlighter.h"
11#include "ksyntaxhighlighting_export.h"
12#include "theme.h"
13
14#include <QFlags>
15#include <QString>
16
17QT_BEGIN_NAMESPACE
18class QIODevice;
19QT_END_NAMESPACE
20
21namespace KSyntaxHighlighting
22{
23class AnsiHighlighterPrivate;
24
25// Exported for a bundled helper program
26class KSYNTAXHIGHLIGHTING_EXPORT AnsiHighlighter final : public AbstractHighlighter
27{
28public:
29 enum class AnsiFormat {
30 TrueColor,
31 XTerm256Color,
32 };
33
34 enum class Option {
35 NoOptions,
36 UseEditorBackground = 1 << 0,
37 Unbuffered = 1 << 1,
38
39 // Options that displays a useful visual aid for syntax creation
40 TraceFormat = 1 << 2,
41 TraceRegion = 1 << 3,
42 TraceContext = 1 << 4,
43 TraceStackSize = 1 << 5,
44 TraceAll = TraceFormat | TraceRegion | TraceContext | TraceStackSize,
45 };
46 Q_DECLARE_FLAGS(Options, Option)
47
48 AnsiHighlighter();
49 ~AnsiHighlighter() override;
50
51 void highlightFile(const QString &fileName, AnsiFormat format = AnsiFormat::TrueColor, Options options = Option::UseEditorBackground);
52 void highlightData(QIODevice *device, AnsiFormat format = AnsiFormat::TrueColor, Options options = Option::UseEditorBackground);
53
54 void setOutputFile(const QString &fileName);
55 void setOutputFile(FILE *fileHandle);
56
57 void setBackgroundRole(Theme::EditorColorRole bgRole);
58
59protected:
60 void applyFormat(int offset, int length, const Format &format) override;
61
62private:
63 Q_DECLARE_PRIVATE(AnsiHighlighter)
64};
65}
66
67Q_DECLARE_OPERATORS_FOR_FLAGS(KSyntaxHighlighting::AnsiHighlighter::Options)
68
69#endif // KSYNTAXHIGHLIGHTING_ANSIHIGHLIGHTER_H
Syntax highlighting engine for Kate syntax definitions.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.