|
JX Application Framework
|
#include <JSTStyler.h>
Classes | |
| struct | TokenData |
| union | TokenExtra |
Public Member Functions | |
| JSTStyler () | |
| virtual | ~JSTStyler () |
| void | UpdateStyles (const JStyledText *te, const JString &text, JRunArray< JFont > *styles, JStyledText::TextRange *recalcRange, JStyledText::TextRange *redrawRange, const bool deletion, JArray< TokenData > *tokenStartList) |
| bool | IsActive () const |
| void | SetActive (const bool active) |
Static Public Member Functions | |
| static JArray< TokenData > * | NewTokenStartList () |
Protected Member Functions | |
| virtual void | Scan (const JStyledText::TextIndex &startIndex, std::istream &input, const TokenExtra &initData)=0 |
| virtual TokenExtra | GetFirstTokenExtraData () const |
| virtual void | PreexpandCheckRange (const JString &text, const JRunArray< JFont > &styles, const JCharacterRange &modifiedRange, const bool deletion, JStyledText::TextRange *checkRange) |
| void | ExtendCheckRange (const JIndex newEndCharIndex) |
| const JStyledText * | GetStyledText () const |
| const JFontManager * | GetFontManager () const |
| const JFont & | GetDefaultFont () const |
| const JString & | GetText () const |
| const JRunArray< JFont > & | GetStyles () const |
| JUtf8Character | GetCharacter (const JStyledText::TextIndex &index) const |
| bool | SetStyle (const JCharacterRange &range, const JFontStyle &style) |
| void | SaveTokenStart (const JStyledText::TextIndex &index, const TokenExtra data=TokenExtra()) |
| void | AdjustStyle (const JCharacterRange &range, const JFontStyle &style) |
| void | SetDecimationFactor (const JSize factor) |
This is the base class for an object that can efficiently control the
styles inside a JStyledText. Derive a class from JStyledText and
override AdjustStylesBeforeBroadcast() and pass the arguments directly
to JSTStyler::UpdateStyles().
tokenStartList is used to avoid lexing more of the text than necessary.
Each JStyledText object must own one and must never modify the contents
between calls to UpdateStyles().
Derived classes must override the following function:
Scan
Read tokens from the given input stream and call SetStyle() for
each one. When SetStyle() returns false, stop scanning.
Every character in the input stream must be part of some token,
and the tokens must be passed to SetStyle() in the order that they
occur in the file.
Every time the lexer reaches a point where it could be safely
restarted, call SaveTokenStart(). (This cannot be done for every
token because, for example, '*' can mean either multiplication or
dereferencing in C, so one must start further back in order to
get the context.)
Derived classes can override the following function:
PreexpandCheckRange
Called before Scan() to allow the derived class to expand the
range of characters that need to be checked. The initial range
starts with the first character in the style run containing the
first modified character and ends with the last character in the
style run containing the last modified character. These points
are obviously token boundaries. In some cases, one needs to check
a wider range.
While inside Scan(), one may encounter a token that requires checking
at least a certain distance (e.g. to the end of the line). To handle
this, call ExtendCheckRange() with the index of the last character that
must be checked. This should be done before calling SetStyle() for the
token.
| JSTStyler::JSTStyler | ( | ) |
|
virtual |
|
protected |
Call this to change the style of something that the lexer has already processed.
|
protected |
Extends the end of the check range. It is safe to call this with an index beyond the end of the text.
|
protected |
Only use if you really need only one single character
|
inlineprotected |
|
protectedvirtual |
Derived classes can override this to store additional data.
|
protected |
|
inlineprotected |
|
inlineprotected |
|
inline |
|
static |
Allocates a tokenStartList with a reasonable block size.
|
protectedvirtual |
checkRange is only allowed to expand. The default is to do nothing.
modifiedRange is the range of text that was changed. deletion is true if the modification was that text was deleted.
|
protected |
Automatically decimates the stream of token starts by itsDecimationFactor.
|
protectedpure virtual |
|
inline |
|
inlineprotected |
|
protected |
Returns true if the lexer should keep going.
| void JSTStyler::UpdateStyles | ( | const JStyledText * | st, |
| const JString & | text, | ||
| JRunArray< JFont > * | styles, | ||
| JStyledText::TextRange * | recalcRange, | ||
| JStyledText::TextRange * | redrawRange, | ||
| const bool | deletion, | ||
| JArray< TokenData > * | tokenStartList | ||
| ) |
Ranges are inside [1, text.GetCharacterCount()+1]