• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

cantor/src/lib

  • Cantor
  • DefaultHighlighter
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | List of all members
Cantor::DefaultHighlighter Class Reference

#include <defaulthighlighter.h>

Inheritance diagram for Cantor::DefaultHighlighter:
Inheritance graph
[legend]

Public Slots

void positionChanged (const QTextCursor &)
 

Signals

void rulesChanged ()
 

Public Member Functions

 DefaultHighlighter (QObject *parent)
 
 DefaultHighlighter (QObject *parent, Session *session)
 
virtual ~DefaultHighlighter () override
 
void setTextItem (QGraphicsTextItem *item)
 
- Public Member Functions inherited from QSyntaxHighlighter
 QSyntaxHighlighter (QObject *parent)
 
 QSyntaxHighlighter (QTextDocument *parent)
 
 QSyntaxHighlighter (QTextEdit *parent)
 
virtual  ~QSyntaxHighlighter ()
 
QTextDocument * document () const
 
void rehighlight ()
 
void rehighlightBlock (const QTextBlock &block)
 
void setDocument (QTextDocument *doc)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Protected Slots

void addFunctions (const QStringList &functions)
 
void addVariables (const QStringList &variables)
 
void removeRule (const QString &word)
 
void removeRules (const QStringList &conditions)
 

Protected Member Functions

void addKeywords (const QStringList &keywords)
 
void addPair (QChar openSymbol, QChar closeSymbol)
 
void addRule (const QString &word, const QTextCharFormat &format)
 
void addRule (const QRegExp &regexp, const QTextCharFormat &format)
 
void addRules (const QStringList &conditions, const QTextCharFormat &format)
 
QTextCharFormat commentFormat () const
 
QTextCharFormat errorFormat () const
 
QTextCharFormat functionFormat () const
 
void highlightBlock (const QString &text) override
 
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 QRegExp &regexp)
 
bool skipHighlighting (const QString &text)
 
QTextCharFormat stringFormat () const
 
QTextCharFormat variableFormat () const
 
- Protected Member Functions inherited from QSyntaxHighlighter
QTextBlock currentBlock () const
 
int currentBlockState () const
 
QTextBlockUserData * currentBlockUserData () const
 
QTextCharFormat format (int position) const
 
virtual void highlightBlock (const QString &text)=0
 
int previousBlockState () const
 
void setCurrentBlockState (int newState)
 
void setCurrentBlockUserData (QTextBlockUserData *data)
 
void setFormat (int start, int count, const QFont &font)
 
void setFormat (int start, int count, const QTextCharFormat &format)
 
void setFormat (int start, int count, const QColor &color)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

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.

Author
Alexander Rieder

Definition at line 48 of file defaulthighlighter.h.

Constructor & Destructor Documentation

DefaultHighlighter::DefaultHighlighter ( QObject *  parent)
explicit

Definition at line 86 of file defaulthighlighter.cpp.

DefaultHighlighter::DefaultHighlighter ( QObject *  parent,
Session *  session 
)
explicit

Definition at line 104 of file defaulthighlighter.cpp.

DefaultHighlighter::~DefaultHighlighter ( )
overridevirtual

Definition at line 123 of file defaulthighlighter.cpp.

Member Function Documentation

void DefaultHighlighter::addFunctions ( const QStringList &  functions)
protectedslot

Convenience method, equivalent to.

addRules(functions, functionFormat())

Definition at line 449 of file defaulthighlighter.cpp.

void DefaultHighlighter::addKeywords ( const QStringList &  keywords)
protected

Convenience method, equivalent to.

addRules(keywords, keywordFormat())

Definition at line 454 of file defaulthighlighter.cpp.

void DefaultHighlighter::addPair ( QChar  openSymbol,
QChar  closeSymbol 
)
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:

addPair('<', '>');
Parameters
openSymbolthe opening symbol of the pair
closeSymbolthe closing symbol of the pair
See also
highlightPairs

Definition at line 162 of file defaulthighlighter.cpp.

void DefaultHighlighter::addRule ( const QString &  word,
const QTextCharFormat &  format 
)
protected

Highlights all instances of the word in the text with the specified format.

Parameters
wordthe word to highlight
formatthe format to be used for displaying the word

Definition at line 405 of file defaulthighlighter.cpp.

void DefaultHighlighter::addRule ( const QRegExp &  regexp,
const QTextCharFormat &  format 
)
protected

Highlights all parts of the text matched by the regular expression regexp in the text with the specified format.

Parameters
regexpthe regular expression used to look for matches
formatthe format used to display the matching parts of the text

Definition at line 412 of file defaulthighlighter.cpp.

void DefaultHighlighter::addRules ( const QStringList &  conditions,
const QTextCharFormat &  format 
)
protected

Convenience method, highlights all items in conditions with the specified format.

QStringList greenWords;
greenWords << "tree" << "forest" << "grass";
addRules(greenWords, greenWordFormat);
Parameters
conditionsany Qt container of QRegExp or QString.
formatthe format used to display the matching parts of the text

Definition at line 436 of file defaulthighlighter.cpp.

void DefaultHighlighter::addVariables ( const QStringList &  variables)
protectedslot

Convenience method, equivalent to.

addRules(variables, variableFormat())

Definition at line 459 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::commentFormat ( ) const
protected

Definition at line 318 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::errorFormat ( ) const
protected

Definition at line 313 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::functionFormat ( ) const
protected

Definition at line 283 of file defaulthighlighter.cpp.

void DefaultHighlighter::highlightBlock ( const QString &  text)
overrideprotected

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 148 of file defaulthighlighter.cpp.

void DefaultHighlighter::highlightPairs ( const QString &  text)
protected

Highlight pairs added with addPair()

See also
addPair

Definition at line 169 of file defaulthighlighter.cpp.

void DefaultHighlighter::highlightRegExps ( const QString &  text)
protected

Highlights all matches from regular expressions added with addRule()

See also
addRule, addRules

Definition at line 270 of file defaulthighlighter.cpp.

void DefaultHighlighter::highlightWords ( const QString &  text)
protected

Highlights words added with addRule()

See also
addRule, addRules

Definition at line 214 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::keywordFormat ( ) const
protected

Definition at line 298 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::matchingPairFormat ( ) const
protected

Definition at line 328 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::mismatchingPairFormat ( ) const
protected

Definition at line 333 of file defaulthighlighter.cpp.

QString DefaultHighlighter::nonSeparatingCharacters ( ) const
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 477 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::numberFormat ( ) const
protected

Definition at line 303 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::objectFormat ( ) const
protected

Definition at line 293 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::operatorFormat ( ) const
protected

Definition at line 308 of file defaulthighlighter.cpp.

void DefaultHighlighter::positionChanged ( const QTextCursor &  cursor)
slot

Called when the cursor moved.

Rehighlights accordingly.

Definition at line 375 of file defaulthighlighter.cpp.

void DefaultHighlighter::removeRule ( const QString &  word)
protectedslot

Removes any rules previously added for the word word.

Definition at line 421 of file defaulthighlighter.cpp.

void DefaultHighlighter::removeRule ( const QRegExp &  regexp)
protected

Removes any rules previously added for the regular expression regexp.

Definition at line 428 of file defaulthighlighter.cpp.

void DefaultHighlighter::removeRules ( const QStringList &  conditions)
protectedslot

Convenience method, removes all rules with conditions from conditions.

See also
removeRule, addRules

Definition at line 464 of file defaulthighlighter.cpp.

void Cantor::DefaultHighlighter::rulesChanged ( )
signal
void DefaultHighlighter::setTextItem ( QGraphicsTextItem *  item)

Change the item being highlighted.

Definition at line 128 of file defaulthighlighter.cpp.

bool DefaultHighlighter::skipHighlighting ( const QString &  text)
protected

Definition at line 143 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::stringFormat ( ) const
protected

Definition at line 323 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::variableFormat ( ) const
protected

Definition at line 288 of file defaulthighlighter.cpp.


The documentation for this class was generated from the following files:
  • defaulthighlighter.h
  • defaulthighlighter.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Mon Dec 9 2019 01:10:46 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

cantor/src/lib

Skip menu "cantor/src/lib"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  •   KmPlot
  • libkeduvocdocument
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   src
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal