Text Editor Highlighting
Last published: January 8, 2009 by 'thawker1'
Defines 3 Classes
Extends 12 Classes
This HighlightingTextEditorController was extracted from RBCodeHighlighting package so that it can be reused for other types of highlighting, e.g. spell-checking.
The controller supports multiple highlighters, each will get a chance to do its highlighting on the editor text. The highlighters should be written so that they do their best to not trash any other highlighting that's already present in the text. The order in which the highlighters will be invoked is unspecified.
A highlighter can be anything that can respond to the #highlight: callback, e.g. the app-model that hosts the highlighting controller. However to simplify cleanup it might be easier to subclass the provided Highlighter class. Your pre-unload action can then simply collect all instances of your highlighter and send preUnload to each. E.g. the Spellchecker-ToolsIntegration package adds SpellingHighlighter. To highlight spelling mistakes simply attach a highlighter as follows:
SpellingHighlighter on: aHighlightingController.
The post-load method then simply collects all instances of the spelling highlighter.
SpellingHighlighter allInstances do: [ :h | h disable ]