HSyntaxHighlighter Class Reference

Syntax highlighter This class implements simple Syntax Highlighter, based on rules using QRegExp form matching parts of code to highlight, and QTextCharFormat for code formating. It developed on basis of Qt's QSyntaxHighlighter, which provide foundations for all Syntax Highlighting classes It store all of it settings in settings. More...

#include <HSyntaxHighlighter.h>

Inheritance diagram for HSyntaxHighlighter:

QSyntaxHighlighter

List of all members.

Public Slots

void editConfig ()
void saveConfig () const
void loadConfig ()

Public Member Functions

 HSyntaxHighlighter (QObject *parent)
 Constructor Loads default configuration into settings.
 HSyntaxHighlighter (QTextDocument *parent)
 Constructor Loads default configuration into settings.
 HSyntaxHighlighter (QTextEdit *parent)
 Constructor Loads default configuration into settings.
void highlightBlock (const QString &text)
 Highlighting function After document content is changed this function is call for all lines, from the current changed line to the end of document. Any line is separate block, so storing current state is needed for multiple line code blocks for example longer comments. Implementing this virtual QSyntaxHighlighter Method is needed to make it works.
 ~HSyntaxHighlighter ()
 Destructor Since class store all data on stack, destructor only saves default AKA last used settings to file.
HSyntaxHighlighterSettingsconfig ()

Private Member Functions

void updateRules ()

Private Attributes

QVector< slFormatingRulesRules
 Single line rules used to highlight (cached from settings).
QVector< mlFormatingRulemRules
 Multiple line rules used to highlight (cached from settings).
HSyntaxHighlighterSettings settings


Detailed Description

Syntax highlighter This class implements simple Syntax Highlighter, based on rules using QRegExp form matching parts of code to highlight, and QTextCharFormat for code formating. It developed on basis of Qt's QSyntaxHighlighter, which provide foundations for all Syntax Highlighting classes It store all of it settings in settings.

Definition at line 25 of file HSyntaxHighlighter.h.


Constructor & Destructor Documentation

HSyntaxHighlighter::HSyntaxHighlighter ( QObject *  parent  ) 

Constructor Loads default configuration into settings.

Parameters:
parent Pointers to owners object

Definition at line 13 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::loadConfig(), and settings.

HSyntaxHighlighter::HSyntaxHighlighter ( QTextDocument *  parent  ) 

Constructor Loads default configuration into settings.

Parameters:
parent Pointers to owners object and initial QTextDocument on which highlighting is applied

Definition at line 17 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::loadConfig(), and settings.

HSyntaxHighlighter::HSyntaxHighlighter ( QTextEdit *  parent  ) 

Constructor Loads default configuration into settings.

Parameters:
parent Pointers to owners object and QTextEdit which holds highlighted QTextDocument

Definition at line 21 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::loadConfig(), and settings.

HSyntaxHighlighter::~HSyntaxHighlighter (  ) 

Destructor Since class store all data on stack, destructor only saves default AKA last used settings to file.

Definition at line 68 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::saveConfig(), and settings.


Member Function Documentation

HSyntaxHighlighterSettings* HSyntaxHighlighter::config (  )  [inline]

Function for accessing settings

Returns:
Pointer to be used for calling method to modify settings API.

Definition at line 85 of file HSyntaxHighlighter.h.

References settings.

void HSyntaxHighlighter::editConfig (  )  [slot]

Slot used to launch settings dialog for stored configuration

Definition at line 81 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterDialog::getSettings(), HSyntaxHighlighterDialog::setSettings(), and settings.

void HSyntaxHighlighter::highlightBlock ( const QString &  text  ) 

Highlighting function After document content is changed this function is call for all lines, from the current changed line to the end of document. Any line is separate block, so storing current state is needed for multiple line code blocks for example longer comments. Implementing this virtual QSyntaxHighlighter Method is needed to make it works.

Parameters:
text Text of a single line, that is send to this Highlighter.

Definition at line 26 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::changed(), slFormatingRule::exp, slFormatingRule::format, mRules, settings, sRules, and updateRules().

void HSyntaxHighlighter::loadConfig (  )  [slot]

Slot used to launch Load Settings dialog for stored configuration

Definition at line 98 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::loadConfig(), and settings.

void HSyntaxHighlighter::saveConfig (  )  const [slot]

Slot used to launch Save Settings dialog for stored configuration

Definition at line 91 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::saveConfig(), and settings.

void HSyntaxHighlighter::updateRules (  )  [private]

Method for (re)caching rules, must me called after settings are modified.

Definition at line 73 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::cached(), HSyntaxHighlighterSettings::getMultiLinesRules(), HSyntaxHighlighterSettings::getSingleLineRules(), mRules, settings, and sRules.

Referenced by highlightBlock().


Member Data Documentation

Multiple line rules used to highlight (cached from settings).

Definition at line 31 of file HSyntaxHighlighter.h.

Referenced by highlightBlock(), and updateRules().

Variable storing all HSyntaxHighlighter settings, used to generate sRules and mRules, easily accessible via config() method.

Definition at line 38 of file HSyntaxHighlighter.h.

Referenced by config(), editConfig(), highlightBlock(), HSyntaxHighlighter(), loadConfig(), saveConfig(), updateRules(), and ~HSyntaxHighlighter().

Single line rules used to highlight (cached from settings).

Definition at line 30 of file HSyntaxHighlighter.h.

Referenced by highlightBlock(), and updateRules().


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

Generated on Fri Jan 9 00:51:00 2009 for HSyntaxHighlighter by  doxygen 1.5.8