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 ()
 Launches configuration dialog.
void saveConfig () const
 Launches save dialog for settings.
void loadConfig ()
 Launches load dialog for settings.

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 ()
 Settings pointer.

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 26 of file HSyntaxHighlighter.h.


Constructor & Destructor Documentation

HSyntaxHighlighter::HSyntaxHighlighter ( QObject *  parent  ) 

Constructor Loads default configuration into settings.

Construct an object and load defaut settings.

Parameters:
parent Pointers to owners object
parent owner of object

Definition at line 17 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::loadConfig(), and settings.

HSyntaxHighlighter::HSyntaxHighlighter ( QTextDocument *  parent  ) 

Constructor Loads default configuration into settings.

Construct an object and load default settings.

Parameters:
parent Pointers to owners object and initial QTextDocument on which highlighting is applied
parent owner of object and also highlighted Document

Definition at line 26 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::loadConfig(), and settings.

HSyntaxHighlighter::HSyntaxHighlighter ( QTextEdit *  parent  ) 

Constructor Loads default configuration into settings.

Construct an object and load default settings.

Parameters:
parent Pointers to owners object and QTextEdit which holds highlighted QTextDocument
parent owner of object and Editor holding formated document

Definition at line 35 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.

(re)cache the rules for highlighter

Definition at line 90 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::saveConfig(), and settings.


Member Function Documentation

HSyntaxHighlighterSettings* HSyntaxHighlighter::config (  )  [inline]

Settings pointer.

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

Definition at line 86 of file HSyntaxHighlighter.h.

References settings.

void HSyntaxHighlighter::editConfig (  )  [slot]

Launches configuration dialog.

Slot used to launch settings dialog for stored configuration

Definition at line 106 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.

implemented highlight function Highlight current line,

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

Definition at line 45 of file HSyntaxHighlighter.cpp.

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

void HSyntaxHighlighter::loadConfig (  )  [slot]

Launches load dialog for settings.

Slot used to launch Load Settings dialog for stored configuration

Definition at line 131 of file HSyntaxHighlighter.cpp.

References HSyntaxHighlighterSettings::loadConfig(), and settings.

void HSyntaxHighlighter::saveConfig (  )  const [slot]

Launches save dialog for settings.

Slot used to launch Save Settings dialog for stored configuration

Definition at line 120 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 95 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 32 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 39 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 31 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:50:44 2009 for HSyntaxHighlighter by  doxygen 1.5.8