The syntax highlighting memo
Using the memo
TAdvMemo provides syntax highlighting for your Pascal or Basic scripts. To start using the memo component, drop the memo component on the form together with either an AdvPascalMemoStyler or an AdvBasicMemoStyler component. Assign the AdvPascalMemoStyler or the AdvBasicMemoStyler to the TAdvMemo.SyntaxStyles property. Upon assigning, the text in the memo will be rendered with the syntax highlighting chosen. You can also programmatically switch the syntax highlighting by assigning at runtime a memo styler components:
AvdMemo1.SyntaxStyles := AdvPascalMemoStyler;
To change the colors of the syntax highlighting, the various properties of the language elements are kept in the TAdvPascalMemoStyler or TAdvBasicMemoStyler. Text and background colors and font can be set for comments, numbers in the MemoStyler properties or for keywords, symbols or values between brackets in the AllStyles properties.
TAdvPascalMemoStyler or TAdvBasicMemoStyler have predefined keywords for the Pascal language or Basic language. If colors need to be changed for custom introduced keywords in the scripter, this can be easily done by adding a TElementStyle in the AllStyles property. Set the styletype to stKeyword and add the keywords to the Keywords stringlist.
TAdvMemo has a gutter that displays the line numbers of the source code. In addition it can also display executable code, breakpoints and active source code line. This is done automatically in the TatScriptDebugDlg component that uses the TAdvMemo for displaying the source code. It can be done separately through following public properties:
TAdvMemo.ActiveLine: Integer;
Sets the active source code line. This line will be displayed in active line colors.
TAdvMemo.BreakPoints[RowIndex]: Boolean;
When true, the line in source code has a breakpoint. Only executable lines can have breakpoints. It is through the scripter engine debug interfaces that you can retrieve whether a line is executable or not. A breakpoint is displayed as a red line with white font.
TAdvMemo.Executable[RowIndex]: Boolean;
When true, a marker is displayed in the gutter that the line is executable.
Using the memo with scripter is as easy as assigning the AdvMemo lines to the scripter SourceCode property and execute the code:
atPascalScripter.SourceCode.Assign(AdvMemo.Lines);
atPascalScripter.Execute;