-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathllamasyntaxhighlighter.h
More file actions
49 lines (37 loc) · 1.27 KB
/
llamasyntaxhighlighter.h
File metadata and controls
49 lines (37 loc) · 1.27 KB
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
48
49
#pragma once
#include <QString>
#include <QTextCharFormat>
#include <QVector>
#include <abstracthighlighter.h>
#include <state.h>
#include <texteditor/colorscheme.h>
namespace LlamaCpp {
struct MarkdownParserContext;
class SyntaxHighlighter : public KSyntaxHighlighting::AbstractHighlighter
{
public:
SyntaxHighlighter();
void setDefinition(const KSyntaxHighlighting::Definition &def) override;
// Processes a chunk of text that might contain multiple lines
void processChunk(const QString &chunk, MarkdownParserContext *ctx);
// Flushes any leftover text (the last line of a block)
void finish(MarkdownParserContext *ctx);
protected:
void applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) override;
private:
void processLine(const QString &line, MarkdownParserContext *ctx);
KSyntaxHighlighting::Definition m_definition;
TextEditor::ColorScheme m_colorScheme;
KSyntaxHighlighting::State m_state;
QString m_leftover; // Stores partial lines between chunks
struct RecordedFormat
{
int offset;
int length;
QTextCharFormat charFmt;
};
QVector<RecordedFormat> m_recordedFormats;
QTextCharFormat m_defaultFmt;
QTextBlockFormat m_defaultBlockFmt;
};
} // namespace LlamaCpp