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 (QTextEdit *textEdit, QObject *p=0) | |
Creates a pqPythonSyntaxHighlighter on the given QTextEdit NOTE: the optional tab key capture is enabled by the constructor. More... | |
~pqPythonSyntaxHighlighter () override | |
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... | |
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 54 of file pqPythonSyntaxHighlighter.h.
typedef QObject pqPythonSyntaxHighlighter::Superclass |
Definition at line 58 of file pqPythonSyntaxHighlighter.h.
|
explicit |
Creates a pqPythonSyntaxHighlighter on the given QTextEdit NOTE: the optional tab key capture is enabled by the constructor.
|
override |
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.
|
overrideprotected |
This event filter is applied to the TextEdit to translate presses of the Tab key into 4 spaces being inserted.