cantor/src/lib
#include <defaulthighlighter.h>

Public Slots | |
void | positionChanged (QTextCursor) |
Signals | |
void | rulesChanged () |
Public Member Functions | |
DefaultHighlighter (QObject *parent) | |
~DefaultHighlighter () | |
void | setTextItem (QGraphicsTextItem *item) |
Protected Member Functions | |
template<class Container > | |
void | addFunctions (const Container &functions) |
template<class Container > | |
void | addKeywords (const Container &keywords) |
void | addPair (const QChar &openSymbol, const QChar &closeSymbol) |
void | addRule (const QString &word, const QTextCharFormat &format) |
void | addRule (const QRegExp ®exp, const QTextCharFormat &format) |
template<class Container > | |
void | addRules (const Container &conditions, const QTextCharFormat &format) |
template<class Container > | |
void | addVariables (const Container &variables) |
QTextCharFormat | commentFormat () const |
QTextCharFormat | errorFormat () const |
QTextCharFormat | functionFormat () const |
virtual void | highlightBlock (const QString &text) |
void | highlightPairs (const QString &text) |
void | highlightRegExps (const QString &text) |
void | highlightWords (const QString &text) |
QTextCharFormat | keywordFormat () const |
QTextCharFormat | matchingPairFormat () const |
QTextCharFormat | mismatchingPairFormat () const |
virtual QString | nonSeparatingCharacters () const |
QTextCharFormat | numberFormat () const |
QTextCharFormat | objectFormat () const |
QTextCharFormat | operatorFormat () const |
void | removeRule (const QString &word) |
void | removeRule (const QRegExp ®exp) |
template<class Container > | |
void | removeRules (const Container &conditions) |
bool | skipHighlighting (const QString &text) |
QTextCharFormat | stringFormat () const |
QTextCharFormat | variableFormat () const |
Detailed Description
The DefaultHighlighter is an implementation QSyntaxHighlighter.
It covers most common cases of syntax highlighting for Cantor's command entries.
When creating a custom highlighter, for example for a new backend, you should use the provided functions addPairs(), addRule() and/or addRules().
If you need more specific functionality, subclass highlightBlock(). Usually it's a good idea to also call DefaultHighlighter's implementation from it.
Definition at line 47 of file defaulthighlighter.h.
Constructor & Destructor Documentation
DefaultHighlighter::DefaultHighlighter | ( | QObject * | parent | ) |
Definition at line 82 of file defaulthighlighter.cpp.
DefaultHighlighter::~DefaultHighlighter | ( | ) |
Definition at line 98 of file defaulthighlighter.cpp.
Member Function Documentation
|
protected |
Convenience method, equivalent to.
Definition at line 195 of file defaulthighlighter.h.
|
protected |
Convenience method, equivalent to.
Definition at line 201 of file defaulthighlighter.h.
|
protected |
Call this to add a pair of symbols for highlighting.
The default implementation of the class already adds (), {} and [], so no need to add those. For example, if you wanted to highlight angle-brackets, you would use:
- Parameters
-
openSymbol the opening symbol of the pair closeSymbol the closing symbol of the pair
- See also
- highlightPairs
Definition at line 137 of file defaulthighlighter.cpp.
|
protected |
Highlights all instances of the word
in the text with the specified format
.
- Parameters
-
word the word to highlight format the format to be used for displaying the word
Definition at line 380 of file defaulthighlighter.cpp.
|
protected |
Highlights all parts of the text matched by the regular expression regexp
in the text with the specified format
.
- Parameters
-
regexp the regular expression used to look for matches format the format used to display the matching parts of the text
Definition at line 386 of file defaulthighlighter.cpp.
|
protected |
Convenience method, highlights all items in conditions
with the specified format
.
- Parameters
-
conditions any Qt container of QRegExp or QString.
Definition at line 184 of file defaulthighlighter.h.
|
protected |
Convenience method, equivalent to.
Definition at line 207 of file defaulthighlighter.h.
|
protected |
Definition at line 293 of file defaulthighlighter.cpp.
|
protected |
Definition at line 288 of file defaulthighlighter.cpp.
|
protected |
Definition at line 258 of file defaulthighlighter.cpp.
|
protectedvirtual |
This method is called by Cantor's KTextEdit and is where all the highlighting must take place.
The default implementation calls highlightPairs(), highlightWords() and highlightRegExps().
Definition at line 123 of file defaulthighlighter.cpp.
|
protected |
Highlight pairs added with addPair()
- See also
- addPair
Definition at line 144 of file defaulthighlighter.cpp.
|
protected |
Highlights all matches from regular expressions added with addRule()
Definition at line 245 of file defaulthighlighter.cpp.
|
protected |
Highlights words added with addRule()
Definition at line 189 of file defaulthighlighter.cpp.
|
protected |
Definition at line 273 of file defaulthighlighter.cpp.
|
protected |
Definition at line 303 of file defaulthighlighter.cpp.
|
protected |
Definition at line 308 of file defaulthighlighter.cpp.
|
protectedvirtual |
Returns a string that contains a regular expression that matches for characters thar are allowed inside words for this backend.
For example, maxima or scilab allow % at the beginning of variable names
Definition at line 410 of file defaulthighlighter.cpp.
|
protected |
Definition at line 278 of file defaulthighlighter.cpp.
|
protected |
Definition at line 268 of file defaulthighlighter.cpp.
|
protected |
Definition at line 283 of file defaulthighlighter.cpp.
|
slot |
Called when the cursor moved.
Rehighlights accordingly.
Definition at line 350 of file defaulthighlighter.cpp.
|
protected |
Removes any rules previously added for the word word
.
Definition at line 395 of file defaulthighlighter.cpp.
|
protected |
Removes any rules previously added for the regular expression regexp
.
Definition at line 402 of file defaulthighlighter.cpp.
|
protected |
Convenience method, removes all rules with conditions from conditions
.
- See also
- removeRule, addRules
Definition at line 213 of file defaulthighlighter.h.
|
signal |
void DefaultHighlighter::setTextItem | ( | QGraphicsTextItem * | item | ) |
Change the item beeing highlighted.
Definition at line 103 of file defaulthighlighter.cpp.
|
protected |
Definition at line 118 of file defaulthighlighter.cpp.
|
protected |
Definition at line 298 of file defaulthighlighter.cpp.
|
protected |
Definition at line 263 of file defaulthighlighter.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.