Base class for syntax highlighting. More...
#include <SyntaxHighlighter.h>
Public Member Functions | |
| void | addRule (QString regexp, QColor color, int weight=QFont::Normal, bool italic=false, QColor backgroundColor=Qt::transparent) |
| add a new rule (can be done on the fly) | |
| bool | removeRule (QString regexp) |
| remove an existing rule (can be done on the fly) | |
| SyntaxHighlighter (QTextDocument *parent=nullptr) | |
| constructor | |
Base class for syntax highlighting.
Defines rules for transformation to facilitate new language highlighting.
In the inherited class' constructor, just add rules, and that's it!
You can now highlight any text edit:
| SyntaxHighlighter::SyntaxHighlighter | ( | QTextDocument * | parent = nullptr | ) |
constructor
| parent | (optional) if not given during instantiation, use setDocument(..) afterward |
Referenced by CMakeSyntaxHighlighter::CMakeSyntaxHighlighter(), CppSyntaxHighlighter::CppSyntaxHighlighter(), ExtensionGeneratorLogSyntaxHighlighter::ExtensionGeneratorLogSyntaxHighlighter(), JsonSyntaxHighlighter::JsonSyntaxHighlighter(), and camitk::LogSyntaxHighlighter::LogSyntaxHighlighter().
| void SyntaxHighlighter::addRule | ( | QString | regexp, |
| QColor | color, | ||
| int | weight = QFont::Normal, | ||
| bool | italic = false, | ||
| QColor | backgroundColor = Qt::transparent ) |
add a new rule (can be done on the fly)
| regexp | to match |
| color | text color |
| weight | QFont::Normal for normal (default) or QFont::Bold for bold |
| italic | false by default |
| backgroundColor | transparent by default |
Referenced by CMakeSyntaxHighlighter::CMakeSyntaxHighlighter(), CppSyntaxHighlighter::CppSyntaxHighlighter(), ExtensionGeneratorLogSyntaxHighlighter::ExtensionGeneratorLogSyntaxHighlighter(), JsonSyntaxHighlighter::JsonSyntaxHighlighter(), camitk::LogSyntaxHighlighter::LogSyntaxHighlighter(), and camitk::LogSyntaxHighlighter::setHighlight().
| bool SyntaxHighlighter::removeRule | ( | QString | regexp | ) |
remove an existing rule (can be done on the fly)
Referenced by camitk::LogSyntaxHighlighter::unsetHighlight().