#include <GNUSyntaxHighlighter.h>
Inherited by srchiliteqt::Qt3SyntaxHighlighter, and srchiliteqt::Qt4SyntaxHighlighter.
Public Member Functions | |
const QString & | getLangFile () const |
srchilite::HighlightStatePtr | getHighlightState (const QString &file) |
Given a language definition file name, returns the corresponding highlight state. | |
void | initHighlighter (const QString &file) |
Given a language definition file name, initializes the Source-highlight's highlighter. | |
const QString | getLangDefFileFromFileName (const QString &filename) |
Returns the the lang def file name by using the file name for detecting the syntax of the file (e.g., foo.cpp brings to cpp.lang, ChangeLog brings to changelog.lang). | |
srchilite::SourceHighlighter * | getHighlighter () const |
const TextFormatterMap & | getTextFormatterMap (TextFormatterFactory &formatterFactory, const QString &styleFile="default.style") |
Given a TextFormatterFactory, it uses to build the TextFormatterMap, by reading a specified source-highlight style file. | |
srchilite::FormatterManager * | getFormatterManager () const |
void | highlightLine (const QString &line, HighlightStateData *&stateData) |
Highlights the passed line. | |
srchilite::LangDefManager * | getLangDefManager () const |
srchilite::LangMap * | getLangMap () const |
const QString & | getForegroundColor () const |
const QString & | getBackgroundColor () const |
void | setForegroundColor (const QString &f) |
void | setBackgroundColor (const QString &b) |
bool | isReadOnly () const |
void | setReadOnly (bool r) |
Specifies that we highlight readonly contents. | |
bool | isDefaultToMonosapce () const |
void | setDefaultToMonosapce (bool d) |
Whether the highlighter should use monospace font by default if nothing is specified about the font family. | |
Protected Attributes | |
srchilite::FormatterManager * | formatterManager |
This will be used by subclasses to generate the right table of formatters. | |
Private Attributes | |
QString | langFile |
the lang file used by this highlighter | |
srchilite::SourceHighlighter * | sourceHighlighter |
the GNU Source-highlighter used for the actual highlighting | |
srchilite::FormatterParams | formatterParams |
this is crucial to get the starting position of the string to highlight within the whole line | |
QString | foregroundColor |
the color string for foreground | |
QString | backgroundColor |
the color string for background | |
bool | readOnly |
whether we highlight read only contents | |
bool | defaultToMonospace |
whether to default font to monospace (default true) |
You must use one of the concrete classes, depending on the version of Qt that you're using, e.g., Qt4SyntaxHighlighter or Qt3SyntaxHighlighter.
const QString& srchiliteqt::GNUSyntaxHighlighter::getBackgroundColor | ( | ) | const [inline] |
const QString& srchiliteqt::GNUSyntaxHighlighter::getForegroundColor | ( | ) | const [inline] |
srchilite::FormatterManager* srchiliteqt::GNUSyntaxHighlighter::getFormatterManager | ( | ) | const [inline] |
srchilite::SourceHighlighter* srchiliteqt::GNUSyntaxHighlighter::getHighlighter | ( | ) | const [inline] |
srchilite::HighlightStatePtr srchiliteqt::GNUSyntaxHighlighter::getHighlightState | ( | const QString & | file | ) |
Given a language definition file name, returns the corresponding highlight state.
This method is mainly for testing purposes.
file |
srchilite::ParserException |
const QString srchiliteqt::GNUSyntaxHighlighter::getLangDefFileFromFileName | ( | const QString & | filename | ) |
Returns the the lang def file name by using the file name for detecting the syntax of the file (e.g., foo.cpp brings to cpp.lang, ChangeLog brings to changelog.lang).
filename |
srchilite::LangDefManager * srchiliteqt::GNUSyntaxHighlighter::getLangDefManager | ( | ) | const |
srchilite::LangMap * srchiliteqt::GNUSyntaxHighlighter::getLangMap | ( | ) | const |
const TextFormatterMap & srchiliteqt::GNUSyntaxHighlighter::getTextFormatterMap | ( | TextFormatterFactory & | formatterFactory, | |
const QString & | styleFile = "default.style" | |||
) |
Given a TextFormatterFactory, it uses to build the TextFormatterMap, by reading a specified source-highlight style file.
If the TextFormatterFactory already contains some formatters, then simpy returns its TextFormatterMap, without rebuilding it.
formatterFactory | the formatter factory to create formatters | |
styleFile | the style file name (can be a .style file or a .css file - in this case it must be a css file that source-highlight is able to handle) |
ParserException | in case of parsing error of the style file |
void srchiliteqt::GNUSyntaxHighlighter::highlightLine | ( | const QString & | line, | |
HighlightStateData *& | stateData | |||
) |
Highlights the passed line.
This method assumes that all the fields are already initialized (e.g., the FormatterManager).
The passed HighlightStateData is used to configure the SourceHighlighter with info like the current highlighting state and the state stack. If it is null, we simply ignore it.
This method can modify the bassed pointer and even make it NULL (after deleting it).
line | ||
stateData | the highlight state data to use |
void srchiliteqt::GNUSyntaxHighlighter::initHighlighter | ( | const QString & | file | ) |
Given a language definition file name, initializes the Source-highlight's highlighter.
file | the lang file of Source-highlight |
srchilite::ParserException |
bool srchiliteqt::GNUSyntaxHighlighter::isReadOnly | ( | ) | const [inline] |
void srchiliteqt::GNUSyntaxHighlighter::setDefaultToMonosapce | ( | bool | d | ) | [inline] |
Whether the highlighter should use monospace font by default if nothing is specified about the font family.
d |
void srchiliteqt::GNUSyntaxHighlighter::setReadOnly | ( | bool | r | ) | [inline] |
Specifies that we highlight readonly contents.
This optimizes the highlighting: being readonly, we must not keep track of the state of the previous line, and this saves time and memory.
r |