SynEdit Internals

This is the current revision of SynEdit Internals, edited by Martin at .

/* Changes in 4.99 */

TLazEditLineItems (Internal storage)

This class is not part of the SynEdit user interface. It is internally used to organise storage. The class is primarily used by SynEdit's TextBuffer and Highlighter, to store the data for each string and associated data.

TLazEditLineItems needs to be sub-classed. This can be done with the provided generic classes, based on LazListClasses.

If data needs initializing, or rec-count handling (managed types) then this can be done using TLazListAspectMemInit.... For example:

  TMyStorage = class(
    specialize TGenLazEditLineItemsFixedShiftList<
      AnsiString,  
      specialize TLazListAspectMemInitManagedRefCnt<AnsiString>  
    >
  )

TLazEditChildLineItemsList (dependent children-list)

Some classes (like highlighters) need to store their own data for each LineItem it the SynEdit's TextBuffer. For this they add their storage list to the TLazEditChildLineItemsList provided by the TextBuffer (property Range).

The list will forward calls of the parent to each child:

The parent can be implemented using the generic TGenLazEditParentLineItems

Example (TextBuffer / Highlighter)

SynEdits TextBuffer uses such a list to store for each line: - The string for each line - The "object" (as given by user-code via SynEdit.Lines.Object[i]) - Flags (line modified)

It provides a

    property Ranges[Index: Pointer]: TLazEditLineItems read GetRange write PutRange;

through which other code can add their own child-lists. "Index" must be a unique ID. Callers can e.g. use "Pointer(self)".

Such child-lists are registered by the Highlighter to keep per line state. (This is where the name "Ranges" was originally introduced: https://wiki.freepascal.org/SynEdit_Highlighter#Step_2:_Using_Ranges ). The can also be used by other code. E.g. SynEdit keeps a list for managing tab (#9) info per line.

Changes in 4.99

For a list of changes please see SynEdit_Changes