SILICON
Loading...
Searching...
No Matches
CodeSyntaxHighlighter Class Referencefinal

#include <codeSyntaxHighlighter.hpp>

Inheritance diagram for CodeSyntaxHighlighter:
Collaboration diagram for CodeSyntaxHighlighter:

Classes

struct  CompiledKeywordGroup
struct  CompiledContainedRule
struct  CompiledMatchRule
struct  CompiledRegionRule
struct  RegionEnd

Public Member Functions

 CodeSyntaxHighlighter (QTextDocument *document)
void setSyntax (const CodeSyntax *syntax)
void setPalette (const QPalette &palette)

Protected Member Functions

void highlightBlock (const QString &text) override

Private Member Functions

const QTextCharFormat & format (CodeSyntaxStyle style) const
void applyContainedRules (const QString &text, qsizetype start, qsizetype end, const std::vector< CompiledContainedRule > &rules)

Static Private Member Functions

static RegionEnd findRegionEnd (const QString &text, qsizetype from, const CompiledRegionRule &region)

Private Attributes

const CodeSyntax * syntax = nullptr
std::vector< CompiledKeywordGroup > keywordGroups
std::vector< CompiledMatchRule > matchRules
std::vector< CompiledRegionRule > regionRules
std::array< QTextCharFormat, STYLE_COUNT > formats

Static Private Attributes

static constexpr std::size_t STYLE_COUNT = 13

Detailed Description

Applies a UI syntax description to a QTextDocument.

Definition at line 35 of file codeSyntaxHighlighter.hpp.

Constructor & Destructor Documentation

◆ CodeSyntaxHighlighter()

CodeSyntaxHighlighter ( QTextDocument * document)
explicit

Definition at line 53 of file codeSyntaxHighlighter.cpp.

Member Function Documentation

◆ applyContainedRules()

void applyContainedRules ( const QString & text,
qsizetype start,
qsizetype end,
const std::vector< CompiledContainedRule > & rules )
private

Definition at line 181 of file codeSyntaxHighlighter.cpp.

◆ findRegionEnd()

CodeSyntaxHighlighter::RegionEnd findRegionEnd ( const QString & text,
qsizetype from,
const CompiledRegionRule & region )
staticnodiscardprivate

Definition at line 159 of file codeSyntaxHighlighter.cpp.

◆ format()

const QTextCharFormat & format ( CodeSyntaxStyle style) const
nodiscardprivate

Definition at line 153 of file codeSyntaxHighlighter.cpp.

◆ highlightBlock()

void highlightBlock ( const QString & text)
overrideprotected

Definition at line 198 of file codeSyntaxHighlighter.cpp.

◆ setPalette()

void setPalette ( const QPalette & palette)

Definition at line 118 of file codeSyntaxHighlighter.cpp.

◆ setSyntax()

void setSyntax ( const CodeSyntax * syntax)

Definition at line 58 of file codeSyntaxHighlighter.cpp.

Member Data Documentation

◆ formats

std::array<QTextCharFormat, STYLE_COUNT> formats
private

Definition at line 88 of file codeSyntaxHighlighter.hpp.

◆ keywordGroups

std::vector<CompiledKeywordGroup> keywordGroups
private

Definition at line 85 of file codeSyntaxHighlighter.hpp.

◆ matchRules

std::vector<CompiledMatchRule> matchRules
private

Definition at line 86 of file codeSyntaxHighlighter.hpp.

◆ regionRules

std::vector<CompiledRegionRule> regionRules
private

Definition at line 87 of file codeSyntaxHighlighter.hpp.

◆ STYLE_COUNT

std::size_t STYLE_COUNT = 13
staticconstexprprivate

Definition at line 76 of file codeSyntaxHighlighter.hpp.

◆ syntax

const CodeSyntax* syntax = nullptr
private

Definition at line 84 of file codeSyntaxHighlighter.hpp.


The documentation for this class was generated from the following files: