Led 3.0 Class Library Documentation

Module SyntaxColoring


Classes and Global Functions Index

Module Description:

The basic idea is that we will be - to some extent - mimicking the implementation of StandardStyledTextImager. Recall that the class StyledTextImager is what provides the basic infrastructure for displaying styled text. It introduces the special marker class StyledTextImager::StyleMarker - which we can subclass todo our own kind of special display of text. And StandardStyledTextImager simply leverages off this generic implementation, and maintains a database of non-overlapping StyleMarkers according to the usual editing, and style application conventions most standard text editing packages support (eg. apply style to region of text etc).

Where we will diverge, is that we won't generate our style markers from external function calls or UI commands. Instead, we will programmaticly generate the style markers ourselves based on a simple lexical analysis of the text (SyntaxAnalyzer).


Class: SimpleSyntaxColoringMarkerOwner [public]

Base Classes: SyntaxColoringMarkerOwner
Description:

A simple but effective brute-force coloring algorithm. This simply colors the entire document. And when any part of the document changes - this simply recolors the document. This runs very quickly. But for large documents, where you may never scroll to view large subsets of the document (or where you need to be able to open quickly) - this may not be your best choice.

See also WindowedSyntaxColoringMarkerOwner.


Class: SyntaxAnalyzer [public]

Description:

This abstract class is the basic for defining the rules for hooking in arbitrary syntactical analyses into the syntax coloring code.

See the TrivialRGBSyntaxAnalyzer class as a trivial example, and the TableDrivenKeywordSyntaxAnalyzer as a more useful starting point for various syntax coloring strategies.


Class: SyntaxColoringMarkerOwner [public]

Description:

An abstract class for controling the basic syntax coloring functionality. Try one of the subclasses, like SimpleSyntaxColoringMarkerOwner or @WindowedSyntaxColoringMarkerOwner'.

This class is usually used by instantiating a concrete subclass in your TextImager::HookGainedNewTextStore override, and then destroyed in your TextImager::HookLosingTextStore override. You must also override TextImager::TabletChangedMetrics to SyntaxColoringMarkerOwner::RecheckAll.


Class: SyntaxColoringMarkerOwner::ColoredStyleMarker [public]

Base Classes: SimpleStyleMarkerByFontSpec
Description:

This is used internally by the syntax coloring code, and is exposed only in case you want to write your own Syntax Analyzer code. This simply takes a Led_Color object and uses that to color the given text.


Class: SyntaxColoringMarkerOwner::FontChangeStyleMarker [public]

Base Classes: TrivialFontSpecStyleMarker
Description:

This is used internally by the syntax coloring code, and is exposed only in case you want to write your own Syntax Analyzer code. This simply takes a Led_FontSpecification object and applies that to the given text.


Class: TableDrivenKeywordSyntaxAnalyzer [public]

Base Classes: SyntaxAnalyzer
Description:

A simple table-driven SyntaxAnalyzer, which looks up keywords from (constructor argument) tables. The elements of the argument table can be in any order - but no initial substring of a later string can come before an earlier one. You can specify an arbitrary compare function for matching keywords - but the two most obtious are Led_tStrnCmp and Led_tStrniCmp.

This class also has two pre-built static tables for two common syntax coloring cases you may want to use, or start from: kCPlusPlusKeywords and kVisualBasicKeywords.


Class: TrivialRGBSyntaxAnalyzer [public]

Base Classes: SyntaxAnalyzer
Description:

A simple example SyntaxAnalyzer, which demonstrates the little you need todo to hook in your own syntax analysis rules.


Class: WindowedSyntaxColoringMarkerOwner [public]

Base Classes: SyntaxColoringMarkerOwner
Description:

This SyntaxColoringMarkerOwner tries to be clever about what areas to syntax analyze. It only analyzes the current window. This makes for very fast opening of large documents (independent of actual file size). But it can make typing and scrolling somewhat slower. This really doesn't matter as long as its faster than some particular user-measurable threshold. I think on a 400Mz or faster Pentium machine - this will always be fast enuf to be a better choice than SimpleSyntaxColoringMarkerOwner. But you can easily try both, and see for yourself.

In addition to settup according to the docs in SyntaxColoringMarkerOwner - you must also override TextInteractor::UpdateScrollBars to call WindowedSyntaxColoringMarkerOwner::RecheckScrolling.

See also SimpleSyntaxColoringMarkerOwner.


Return to Led Page Return to Led ClassLib Documentation Index Return to Led Reference Manual Index
Last Updated 2001-10-20