Colorizer Class

# Colorizer Class Reference

[Action.h Index] [Action.h Hierarchy]

This class is used by KSyntaxMultiLineEdit to perform the syntax highlighting More...

`#include <Colorizer.h>`

## Public Members

- Colorizer (const char* filename)
- ~Colorizer ()
- void init (bool createNormalState)
- bool load (const QString& filename)
- bool save (const QString& filename)
- int match (const QString& string, int startAt, int &len, int& innerState, int& state)
- SyntaxState& getStateInfo (unsigned int s)
- void setStateInfo (const SyntaxState& ss, unsigned int s)
- int stateArraySize ()

## Protected Members

- StateList StateArray
- unsigned int StateArraySize
- int KeywordCheckIx
- int KeywordStateIx
- void insertState (const QString& s)
- void insertRule (const QString& s)
- void insertKeyword (const QString& k)
- void readSetting (const QString& s)
- inline bool testForKeyword (const QString& test)

## Detailed Description

This class is used by KSyntaxMultiLineEdit to perform the syntax highlighting.

## Colorizer(const char* filename)

Constructs a Colorizer; loads a rule file with a given filename.

Parameters:

  filename | full name of rule file to load. this parameter canbe null or empty indicating that no rule file is to be loaded. Such a Colorizer can be used for displaying text as well.

## ~Colorizer()

Destructs the Colorizer.

## void init(bool createNormalState)

Does a minimum of required initialization to make a Colorizer work. This includes the creation of a normal state (index 0) in the StateArray.

Parameters:

  createNormalState. | this indicates wether the normal state is to be generated or not!

## bool load(const QString& filename)

loads info for this Colorizer from a file names filename.

Parameters:

  filename | name of file to load settings from.

## bool save(const QString& filename)

saves Colorizer info to a file named filename; existing file will be overwritten. Currently this function is not implemented. @result returns true, in case of success, false as failure indication. Currently always false is returned.

Parameters:

  filename | name of file to receive the contents of this.

## int match(const QString& string, int startAt, int &len, int& innerState, int& state)

This method can be called to get a new part of text to be colored. string is the string to be searched; the search will start at startAt. The method returns a non-negative number that indicates the starting index of a found text part; in this case the parameters len, info and state will return the length of the portion of text, the state for the matched text and the state that follows after the matched text. On entry, state can contain a valid SyntaxState index so that only SyntaxUnits with the specified validPrevState will have chance to match. if there is no match, state will not be altered.

## SyntaxState& getStateInfo(unsigned int s)

Used to retrieve the state information for the specified state @ st. This method must not be called with an invalid s. It returns a reference to the desired state information.

| Kdoc