|
Source-highlight Library
|
The main class performing the highlighting of a single line. More...
#include <sourcehighlighter.h>


Public Member Functions | |
| SourceHighlighter (HighlightStatePtr mainState) | |
| void | highlightParagraph (const std::string ¶graph) |
| Highlights a paragraph (a line actually) | |
| HighlightStatePtr | getCurrentState () const |
| void | setCurrentState (HighlightStatePtr state) |
| HighlightStateStackPtr | getStateStack () |
| void | setStateStack (HighlightStateStackPtr state) |
| void | clearStateStack () |
| Clears the statck of states. | |
| HighlightStatePtr | getMainState () const |
| const FormatterManager * | getFormatterManager () const |
| void | setFormatterManager (const FormatterManager *_formatterManager) |
| bool | getOptimize () const |
| void | setOptimize (bool b=true) |
| void | setFormatterParams (FormatterParams *p) |
| bool | isSuspended () const |
| void | setSuspended (bool b=true) |
| void | addListener (HighlightEventListener *listener) |
| void | removeListener (HighlightEventListener *listener) |
| bool | hasListeners () const |
| void | notify (const HighlightEvent &event) |
| Notifies all listeners of a specific event. | |
Private Member Functions | |
| void | enterState (HighlightStatePtr state) |
| Enters a new state (using the stack) | |
| void | exitState (int level) |
| Exits level states (-1 means exit all states) | |
| void | exitAll () |
| Exits all states in the stack (and thus go back to the initial main state) | |
| HighlightStatePtr | getNextState (const HighlightToken &token) |
| Computes the (possible) next state for the given rule (if required, also performs reference replacement) | |
| void | format (const std::string &elem, const std::string &s) |
| Formats the given string as the specified element. | |
| void | flush () |
| Makes sure to flush the possible buffer of the current element (e.g., during optimizations) | |
Private Attributes | |
| HighlightStatePtr | mainHighlightState |
| the main (and initial) highlight state | |
| HighlightStatePtr | currentHighlightState |
| the current highlight state | |
| HighlightStateStackPtr | stateStack |
| the stack for the highlight states | |
| const FormatterManager * | formatterManager |
| the formatter manager, used to format element strings | |
| bool | optimize |
| Whether to optimize output (e.g., adjacent text parts belonging to the same element will be buffered and generated as a single text part) | |
| bool | suspended |
| Whether formatting is currently suspended. | |
| FormatterParams * | formatterParams |
| Additional parameters for the formatters. | |
| std::string | currentElement |
| The current element being formatted (used for optmization and buffering) | |
| std::ostringstream | currentElementBuffer |
| The buffer for the text for the current element. | |
| std::list< HighlightEventListener * > | listeners |
| the list of listeners | |
The main class performing the highlighting of a single line.
It relies on a HighlightState (and its HighlightRule objects).
It provides the method highlightParagraph() to highlight a single line.
The current highlighting state can be retrieved with getCurrentState().
The highlighting state is not reset after highlighting a line, thus, the same object can be used to highlight, for instance, an entire file, by calling highlightParagraph on each line.
An example of use of this class is in infoformatter-main.cpp
| srchilite::SourceHighlighter::SourceHighlighter | ( | HighlightStatePtr | mainState | ) |
| mainState | the main and initial state for highlighting |
|
private |
Enters a new state (using the stack)
| state |
|
private |
Exits level states (-1 means exit all states)
| level |
|
private |
Formats the given string as the specified element.
| elem | |
| s |
|
private |
Computes the (possible) next state for the given rule (if required, also performs reference replacement)
| token |
| void srchilite::SourceHighlighter::highlightParagraph | ( | const std::string & | paragraph | ) |
Highlights a paragraph (a line actually)
| paragraph |
|
inlineinherited |
Notifies all listeners of a specific event.
| event | the event |
|
private |
Whether formatting is currently suspended.
Note that matching for regular expressions is not suspended: only the actual output of formatted code is suspended.