TWPCustomSyntax

<< Click to Display Table of Contents >>

Navigation:  Programming > Syntax Highlighting >

TWPCustomSyntax

This class, which is implemented in unit WPSyntaxHighlight implements a basics for a syntax highlighter.

 

To apply syntax highlighting simply assign a TWPCustomSyntax instance to the property TWPRichText.CustomSyntax. The instance will be automatically freed by the editor.

 

Example:

 

     uses WPSyntaxHighlight;

 

    HTMLText.CustomSyntax := TWPXMLSyntax.Create(nil);

 

 

TWPCustomSyntax implements this interface:

 

Initialize - receives a reference to the "Memo" object in a TWPRichText

   procedure Init(Engine: TWPRTFEngineBasis); override;

 

Called for each paragraph at the start

   procedure StartPar(par: TParagraph); override;

 

Called for each character. It has to update the variable FMode according to the syntax

   procedure NextChar(par: TParagraph; CPos: Integer); override;

 

Called at the end of each paragraph

   procedure EndPar(par: TParagraph); override;

 

Called before the complete text is processed

   procedure PreProcess(RTFData: TWPRTFDataBlock); override;

 

Called after the complete text was processed

   procedure PostProcess(RTFData: TWPRTFDataBlock); override;

 

Used to calculate the CharAttr index used at a certain position of a paragraph.

   function CalcAttr(attr: Cardinal; par: TParagraph): Cardinal; override;

 

Reference to the RTFDataProps object

   property RTFProps: TWPRTFProps read FRTFProps;