Source-highlight Library
Public Member Functions | Private Member Functions | Private Attributes | List of all members
srchilite::SourceHighlighter Class Reference

The main class performing the highlighting of a single line. More...

#include <sourcehighlighter.h>

Inheritance diagram for srchilite::SourceHighlighter:
Inheritance graph
[legend]
Collaboration diagram for srchilite::SourceHighlighter:
Collaboration graph
[legend]

Public Member Functions

 
void  highlightParagraph (const std::string &paragraph)
  Highlights a paragraph (a line actually) More...
 
HighlightStatePtr  getCurrentState () const
 
void  setCurrentState (HighlightStatePtr state)
 
HighlightStateStackPtr  getStateStack ()
 
void  setStateStack (HighlightStateStackPtr state)
 
void  clearStateStack ()
  Clears the statck of states.
 
HighlightStatePtr  getMainState () const
 
const FormatterManagergetFormatterManager () 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. More...
 

Private Member Functions

  Enters a new state (using the stack) More...
 
void  exitState (int level)
  Exits level states (-1 means exit all states) More...
 
void  exitAll ()
  Exits all states in the stack (and thus go back to the initial main state)
 
  Computes the (possible) next state for the given rule (if required, also performs reference replacement) More...
 
void  format (const std::string &elem, const std::string &s)
  Formats the given string as the specified element. More...
 
void  flush ()
  Makes sure to flush the possible buffer of the current element (e.g., during optimizations)
 

Private Attributes

  the main (and initial) highlight state
 
  the current highlight state
 
HighlightStateStackPtr  stateStack
  the stack for the highlight states
 
  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. More...
 
  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.
 

Detailed Description

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

Constructor & Destructor Documentation

srchilite::SourceHighlighter::SourceHighlighter ( HighlightStatePtr  mainState )
Parameters
mainState the main and initial state for highlighting

Member Function Documentation

void srchilite::SourceHighlighter::enterState ( HighlightStatePtr  state )
private

Enters a new state (using the stack)

Parameters
state
void srchilite::SourceHighlighter::exitState ( int  level )
private

Exits level states (-1 means exit all states)

Parameters
level
void srchilite::SourceHighlighter::format ( const std::string &  elem,
const std::string &  s 
)
private

Formats the given string as the specified element.

Parameters
elem
s
HighlightStatePtr srchilite::SourceHighlighter::getNextState ( const HighlightTokentoken )
private

Computes the (possible) next state for the given rule (if required, also performs reference replacement)

Parameters
token
void srchilite::SourceHighlighter::highlightParagraph ( const std::string &  paragraph )

Highlights a paragraph (a line actually)

Parameters
paragraph
inlineinherited

Notifies all listeners of a specific event.

Parameters
event the event

Member Data Documentation

bool srchilite::SourceHighlighter::suspended
private

Whether formatting is currently suspended.

Note that matching for regular expressions is not suspended: only the actual output of formatted code is suspended.


The documentation for this class was generated from the following files:
  • /home/bettini/work/source-highlight/src-highlite/lib/srchilite/sourcehighlighter.h
  • /home/bettini/work/source-highlight/src-highlite/lib/srchilite/sourcehighlighter.cpp

AltStyle によって変換されたページ (->オリジナル) /