This class is a helper object to attach to a QTextEdit to add Python syntax highlighting to the text that is displayed. More...
#include <pqPythonSyntaxHighlighter.h>
Inherits QObject.
Public Types | |
typedef QObject | Superclass |
Public Member Functions | |
pqPythonSyntaxHighlighter (QObject *p, QTextEdit &textEdit) | |
Creates a pqPythonSyntaxHighlighter on the given QTextEdit. More... | |
~pqPythonSyntaxHighlighter () override=default | |
bool | isReplacingTabs () const |
Returns true if the tab key is being intercepted to insert spaces in the text edit. More... | |
void | setReplaceTabs (bool replaceTabs) |
Used to enable/disable tab key capture Passing true will cause the tab key to insert 4 spaces in the QTextEdit. More... | |
QString | Highlight (const QString &src) const |
Returns the highlighted input text. More... | |
void | ConnectHighligter () const |
Connects the highlighter to text. More... | |
Protected Member Functions | |
bool | eventFilter (QObject *, QEvent *) override |
This event filter is applied to the TextEdit to translate presses of the Tab key into 4 spaces being inserted. More... | |
This class is a helper object to attach to a QTextEdit to add Python syntax highlighting to the text that is displayed.
The pygments python module is used to generate syntax highlighting. Since mixing tabs and spaces is an error for python's indentation, tabs are highlighted in red.
The QTextEdit is set up so that it uses a fixed-width font and tabs are the width of 4 spaces by the constructor.
This will also optionally capture presses of the tab key that would go to the QTextEdit and insert 4 spaces instead of the tab. This option is enabled by default.
Definition at line 37 of file pqPythonSyntaxHighlighter.h.
typedef QObject pqPythonSyntaxHighlighter::Superclass |
Definition at line 41 of file pqPythonSyntaxHighlighter.h.
|
explicit |
Creates a pqPythonSyntaxHighlighter on the given QTextEdit.
The highlighter is not directly connected to the QTextEdit object (see ConnectHighligter). NOTE: the optional tab key capture is enabled by the constructor
|
overridedefault |
bool pqPythonSyntaxHighlighter::isReplacingTabs | ( | ) | const |
Returns true if the tab key is being intercepted to insert spaces in the text edit.
void pqPythonSyntaxHighlighter::setReplaceTabs | ( | bool | replaceTabs | ) |
Used to enable/disable tab key capture Passing true will cause the tab key to insert 4 spaces in the QTextEdit.
QString pqPythonSyntaxHighlighter::Highlight | ( | const QString & | src | ) | const |
Returns the highlighted input text.
void pqPythonSyntaxHighlighter::ConnectHighligter | ( | ) | const |
Connects the highlighter to text.
This is not automatically called by the constructor as we might want to defer the connection to another widget.
|
overrideprotected |
This event filter is applied to the TextEdit to translate presses of the Tab key into 4 spaces being inserted.