• 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 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 (QTextCursor)
 

Signals

void rulesChanged ()
 

Public Member Functions

 DefaultHighlighter (QObject *parent)
 
 ~DefaultHighlighter ()
 
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 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 &regexp, 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 &regexp)
 
template<class Container >
void removeRules (const Container &conditions)
 
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 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

template<class Container >
void Cantor::DefaultHighlighter::addFunctions ( const Container &  functions)
protected

Convenience method, equivalent to.

addRules(functions, functionFormat())

Definition at line 195 of file defaulthighlighter.h.

template<class Container >
void Cantor::DefaultHighlighter::addKeywords ( const Container &  keywords)
protected

Convenience method, equivalent to.

addRules(keywords, keywordFormat())

Definition at line 201 of file defaulthighlighter.h.

void DefaultHighlighter::addPair ( const QChar &  openSymbol,
const 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 137 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 380 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 386 of file defaulthighlighter.cpp.

template<class Container >
void Cantor::DefaultHighlighter::addRules ( const Container &  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.

Definition at line 184 of file defaulthighlighter.h.

template<class Container >
void Cantor::DefaultHighlighter::addVariables ( const Container &  variables)
protected

Convenience method, equivalent to.

addRules(variables, variableFormat())

Definition at line 207 of file defaulthighlighter.h.

QTextCharFormat DefaultHighlighter::commentFormat ( ) const
protected

Definition at line 293 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::errorFormat ( ) const
protected

Definition at line 288 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::functionFormat ( ) const
protected

Definition at line 258 of file defaulthighlighter.cpp.

void DefaultHighlighter::highlightBlock ( const QString &  text)
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.

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

Highlight pairs added with addPair()

See also
addPair

Definition at line 144 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 245 of file defaulthighlighter.cpp.

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

Highlights words added with addRule()

See also
addRule, addRules

Definition at line 189 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::keywordFormat ( ) const
protected

Definition at line 273 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::matchingPairFormat ( ) const
protected

Definition at line 303 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::mismatchingPairFormat ( ) const
protected

Definition at line 308 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 410 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::numberFormat ( ) const
protected

Definition at line 278 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::objectFormat ( ) const
protected

Definition at line 268 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::operatorFormat ( ) const
protected

Definition at line 283 of file defaulthighlighter.cpp.

void DefaultHighlighter::positionChanged ( QTextCursor  cursor)
slot

Called when the cursor moved.

Rehighlights accordingly.

Definition at line 350 of file defaulthighlighter.cpp.

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

Removes any rules previously added for the word word.

Definition at line 395 of file defaulthighlighter.cpp.

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

Removes any rules previously added for the regular expression regexp.

Definition at line 402 of file defaulthighlighter.cpp.

template<class Container >
void Cantor::DefaultHighlighter::removeRules ( const Container &  conditions)
protected

Convenience method, removes all rules with conditions from conditions.

See also
removeRule, addRules

Definition at line 213 of file defaulthighlighter.h.

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

Change the item beeing highlighted.

Definition at line 103 of file defaulthighlighter.cpp.

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

Definition at line 118 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::stringFormat ( ) const
protected

Definition at line 298 of file defaulthighlighter.cpp.

QTextCharFormat DefaultHighlighter::variableFormat ( ) const
protected

Definition at line 263 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-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:16:33 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
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   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