Public Types | Public Member Functions | Protected Member Functions | List of all members
pqPythonSyntaxHighlighter Class Reference

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...
 

Detailed Description

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.

Member Typedef Documentation

◆ Superclass

Definition at line 58 of file pqPythonSyntaxHighlighter.h.

Constructor & Destructor Documentation

◆ pqPythonSyntaxHighlighter()

pqPythonSyntaxHighlighter::pqPythonSyntaxHighlighter ( QTextEdit *  textEdit,
QObject *  p = 0 
)
explicit

Creates a pqPythonSyntaxHighlighter on the given QTextEdit NOTE: the optional tab key capture is enabled by the constructor.

◆ ~pqPythonSyntaxHighlighter()

pqPythonSyntaxHighlighter::~pqPythonSyntaxHighlighter ( )
override

Member Function Documentation

◆ isReplacingTabs()

bool pqPythonSyntaxHighlighter::isReplacingTabs ( ) const

Returns true if the tab key is being intercepted to insert spaces in the text edit.

◆ setReplaceTabs()

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.

◆ eventFilter()

bool pqPythonSyntaxHighlighter::eventFilter ( QObject *  ,
QEvent *   
)
overrideprotected

This event filter is applied to the TextEdit to translate presses of the Tab key into 4 spaces being inserted.


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