Skip to content

SentenceHighlighter

class nmeasim::app::SentenceHighlighter · Applications

Colours the console like a protocol analyser, using sentence_spans and the colours of the current theme; it re-colours everything when the theme changes.

Inherits QSyntaxHighlighter

Declared in src/app/widgets/sentence_highlighter.hpp (line 86)

Each block of the document is one console line. ConsoleWidget creates one for its view.

Summary

Public member functions

Name Description
SentenceHighlighter() Attaches a highlighter to a document and takes the colours of the current theme.

Protected member functions

Name Description
highlightBlock() Colours one console line with the formats of its spans.

Private member functions

Name Description
update_formats() Sets the foreground of every format from the colours of the current theme, and bold for the formatter.

Private data members

Name Description
tag_ Format of SentenceRole::Tag spans.
talker_ Format of SentenceRole::Talker spans.
formatter_ Format of SentenceRole::Formatter spans, in bold.
separator_ Format of SentenceRole::Separator spans.
checksum_ Format of SentenceRole::Checksum spans.
json_ Format of SentenceRole::Json spans.

Public member functions

SentenceHighlighter()

explicit SentenceHighlighter(QTextDocument* document)

Attaches a highlighter to a document and takes the colours of the current theme.

On every theme::Theme::changed it takes the new colours and re-colours the whole document, which costs one sentence_spans call per line.

Parameters

Name Type Description
document QTextDocument* Document to colour; it becomes the Qt parent and owner of the highlighter.

Declared in src/app/widgets/sentence_highlighter.hpp:97 · defined in src/app/widgets/sentence_highlighter.cpp:80

Protected member functions

highlightBlock()

void highlightBlock(const QString& text) override

Colours one console line with the formats of its spans.

Called by Qt for every block that is added or changed. Characters outside every span keep the normal text format.

Parameters

Name Type Description
text const QString& Text of the block, one console line.

Declared in src/app/widgets/sentence_highlighter.hpp:106 · defined in src/app/widgets/sentence_highlighter.cpp:99

Private member functions

update_formats()

void update_formats()

Sets the foreground of every format from the colours of the current theme, and bold for the formatter.

Declared in src/app/widgets/sentence_highlighter.hpp:111 · defined in src/app/widgets/sentence_highlighter.cpp:88

Private data members

tag_

QTextCharFormat tag_

Format of SentenceRole::Tag spans.

Declared in src/app/widgets/sentence_highlighter.hpp:114

talker_

QTextCharFormat talker_

Format of SentenceRole::Talker spans.

Declared in src/app/widgets/sentence_highlighter.hpp:116

formatter_

QTextCharFormat formatter_

Format of SentenceRole::Formatter spans, in bold.

Declared in src/app/widgets/sentence_highlighter.hpp:118

separator_

QTextCharFormat separator_

Format of SentenceRole::Separator spans.

Declared in src/app/widgets/sentence_highlighter.hpp:120

checksum_

QTextCharFormat checksum_

Format of SentenceRole::Checksum spans.

Declared in src/app/widgets/sentence_highlighter.hpp:122

json_

QTextCharFormat json_

Format of SentenceRole::Json spans.

Declared in src/app/widgets/sentence_highlighter.hpp:124