KSyntaxHighlighting

ansihighlighter.h
1 /*
2  SPDX-FileCopyrightText: 2020 Jonathan Poelen <[email protected]>
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 
13 #include <QFlags>
14 #include <QIODevice>
15 #include <QString>
16 
17 #include <memory>
18 
19 namespace KSyntaxHighlighting
20 {
21 class AnsiHighlighterPrivate;
22 
23 // Exported for a bundled helper program
24 class KSYNTAXHIGHLIGHTING_EXPORT AnsiHighlighter final : public AbstractHighlighter
25 {
26 public:
27  enum class AnsiFormat {
28  TrueColor,
29  XTerm256Color,
30  };
31 
32  enum class TraceOption {
33  NoOptions,
34  Format = 1 << 0,
35  Region = 1 << 1,
36  Context = 1 << 2,
37  StackSize = 1 << 3,
38  };
39  Q_DECLARE_FLAGS(TraceOptions, TraceOption)
40 
41  AnsiHighlighter();
42  ~AnsiHighlighter() override;
43 
44  void highlightFile(const QString &fileName,
45  AnsiFormat format = AnsiFormat::TrueColor,
46  bool useEditorBackground = true,
47  TraceOptions traceOptions = TraceOptions());
48  void
49  highlightData(QIODevice *device, AnsiFormat format = AnsiFormat::TrueColor, bool useEditorBackground = true, TraceOptions traceOptions = TraceOptions());
50 
51  void setOutputFile(const QString &fileName);
52  void setOutputFile(FILE *fileHandle);
53 
54 protected:
55  void applyFormat(int offset, int length, const Format &format) override;
56 
57 private:
58  std::unique_ptr<AnsiHighlighterPrivate> d;
59 };
60 }
61 
62 Q_DECLARE_OPERATORS_FOR_FLAGS(KSyntaxHighlighting::AnsiHighlighter::TraceOptions)
63 
64 #endif // KSYNTAXHIGHLIGHTING_ANSIHIGHLIGHTER_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:09:17 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.