Ok, most of the Highlighting happens in SynEdit (only IFDEF lowlighting involves codetools).
The coloring is done by 2 major concepts:
1) the Highlighter
2) "Markup" classes
The begin/end (highlight the other if either one is touched by the text-cursor/caret) pairs are a combination. The are done by "
TSynEditMarkupWordGroup". This however relies on the Highlighter.
The highlighter marks candidates with "sfaMarkup". That and the fold-level (IIRC).
HL does have FoldConfig, which configures the elements that are considered (if the HL supports it at all)
So you create an instance (and assign the HL to it), and add it (afaik it takes ownership, so no need for freeing it later)
SynEdit.MarkupManager.AddMarkUp()
In the IDE that is probably done in ide/SourceSynEditor.pp. (that is were most of the setup of synedit happens / some is done in ide/SourceEditor.pp.