EControl Syntax Editor SDK
TCustomSyntaxMemo Class

TCustomSyntaxMemo is editor control with syntax highlighting.

TCustomSyntaxMemo = class(TCustomControl, IUnknown, IecTextClient, IecSyntClient, IDropTarget, IDropSource);


TCustomSyntaxMemo is intended for editing or viewing text with syntactical highlighting. Use SyntaxAnalyzer property to link TCustomSyntaxMemo to the syntactical analyzer, which contains rules and styles for syntax highlighting of the Text. Use SyntObj property to access to all results of the syntactical analysis. If this property not assigned, TCustomSyntaxMemo will be like simple text editor, but with gutter, line numeration, unlimited text length, unlimited caret position, bookmarks, block selection and other extensions. 


TCustomSyntaxMemo has two regions: gutter and editor region. 



Special marks (gutter objects), bookmarks, line numbers, collapsing buttons are displayed on the gutter. 

Most of gutter's properties accessible through Gutter property of the TCustomSyntaxMemo. To access gutter objects use Gutter.Objects collection. To access bookmarks use BookmarkObj collection. To access line numeration's properties use LineNumbers property of the TCustomSyntaxMemo. To define line state display use TCustomSyntaxMemo.LineStateDisplay Property


You may divide gutter on several bands use Getter.Bands collection. Each element of the gutter (objects, bookmarks, line numbers, line state) may be associated with the particular band to simplify their placing. To do this use: TCustomGutterObject.Band, LineNumbers.Band and LineStateDisplay.Band properties. 


Editor region 

Editor region contains text area, scroll bars, right margin, line separators, block staples, markers. 

You may use any font for all elements of the syntax memo. Text formatting and line separators have two origins: 

1. Results of syntactical analysis that are contained in SyntObj. Text display properties are customizable within TSyntAnalyzer

2. User ranges (UserRanges and UserStyles properties of the syntax memo). 

3. Custom formatting using OnLineHighLight, OnGetStyleEntry, OnGetLineStyle events. 

4. Custom formatting by user when syntax memo is linked to TecEmbeddedObjects text source using SelAttributes property. 


Use Font and Color properties of the TCustomSyntaxMemo to specifies default style. Use ScrollBars property to control scroll bars. Use ShowRightMargin, RightMargin, RightMarginColor to control right margin. Use StapleOffset, StaplePen to specify display properties of the block staples. 


Use NonPrinted property to control visualization of the non-printed characters (Tab, Space, LF) and hidden text. 


Text modification 

It is recommended to use methods of the TCustomSyntaxMemo to put changes in the text. Use DeleteText, InsertText, MoveText, ReplaceText methods to edit text. Using of these methods allows to undone changes, that is with Undo


Text selection 

Use SelectMode property to read/write mode of the text selection. To control currently selected block use SelStart, SelLength or SelRect. To access selected text use SelText property. 



Use stack-based markers and bookmarks to simplify text navigation. 


Drag & Drop 

Syntax memo allows handling of both VCL and OLE drag & drop technics. 


Sync Edit 

Synchronized editing allows synchronously editing of equaled words within particular range. When synchronized editing range is created all identical words in this range are marked. When editing one word all other identical words are changed synchronously. There may be several ranges with enabled synchronized editing. Word lists in these ranges are independent on each other. 

Use SyncEditing property to define properties of sync editing engine. Use OnCanSyncEdit to control sync editing ranges creation.

The methods of the IecSyntClient class are listed here. 
IecTextClient Interface
The methods of the IecTextClient class are listed here. 
TCustomSyntaxMemo Class
The methods of the TCustomSyntaxMemo class are listed here. 
The properties of the TCustomSyntaxMemo class are listed here. 
The events of the TCustomSyntaxMemo class are listed here. 
read only 
TCustomSyntaxMemo Class
TCustomSyntaxMemo Class 
Occurs when the specified Line has been painted. 
Occurs on each step of animation shape drawing if animation type is atCustom. 
Occurs before the specified Line is painted. 
Occurs when adding new range with synchronous editing. 
Occurs when the caret position changes. 
Occurs when the text for the syntax memo changes. 
Occurs after checking some character whether it is a word character. 
Occurs before bookmark deleting. 
Occurs after specified part of the text has been painted to the Canvas
Occurs before executing command. 
Occurs when text is fully analyzed and all analysis results are created. 
Occurs before processing gutter objects for the specified line. 
Occurs before line number painting. 
Occurs before line processing. 
Event occurs after calculation line. It may be used to adjust line height and word breaks. 
Occurs when mouse down to determine selection mode. 
Occurs before rendering right margin. 
Occurs in GetStyleList to select custom styles. 
Occurs before deleting portion of text. 
Occurs before hint window for the specified token is displayed. 
Occurs before drawing block staple. 
Occurs when the user presses a mouse button with the mouse pointer over a gutter. 
Occurs before inserting text. 
Occurs when state or search string of incremental search changes. 
Occurs after user has inserted single character. 
Occurs before deleting text. 
Occurs when line highlighting attributes are requested. 
Occurs before inserting new text in editor. 
Occurs when the mouse pointer moves over the control. 
Occurs when the mouse pointer moves off from over the control. 
Occurs when collapsed ranges were changed. 
Occurs when starting dragging text using OLE drag&drop engine. 
Indicates whether or not a drop can be accepted and the drop's effect if accepted. 
Occurs while moving right margin. 
Provides target feedback to the user and communicates the drop's effect to the OnOleDrop event so the effect of the drop can be communicated through the OnOleDrop event back to the source. 
Incorporates the source data into the target window, removes target feedback, and releases the data object. 
Occurs before checking whether command can be executed. 
Enables a source application to give visual feedback to its end user during a drag-and-drop operation by providing the DoDragDrop function with an enumeration value specifying the visual effect. 
Occurs when scrolling position is changed. 
Occurs when selection is changed. 
Occurs to initialize new bookmark created when you assign to the Bookmarks property. 
Occurs immediately after the text changes. 
Occurs when zoom is changed. 
Occurs when Modified property changes its value. 
IecSyntClient Methods 
Called when syntax analysis is finished. 
Called when styles of syntax analyzer is changed. 
IecTextClient Interface
IecTextClient Interface 
Called after text have been changed. 
TCustomSyntaxMemo Class
TCustomSyntaxMemo Class 
Adds client of the syntax memo events. 
Recalculates scroll bars ranges and positions. 
Aligns parts of the specified lines by columns. 
Aligns parts of the selected lines by columns. 
Aligns tokens in specified lines. 
Aligns tokens in selected lines. 
Called when editor requires text up to position APos to be analyzed. 
Starts animation at the caret position. 
Starts OLE text dragging. 
Suspends screen repainting. 
Returns bookmark index for the specified line. 
Calculates count of logical lines. 
Calculates margins of text area. 
Returns True if selection exists and selected text can be deleted. 
Returns True if the text range can be deleted. 
Returns True if the text can be inserted at the specified position. 
Return true if selected lines can be moved at specified direction (parameter MoveUp). 
Indicates whether the edit control contains undone changes that can be repeated. 
Returns True if the selection (selected lines) can be sorted. 
Determines whether specified caret position is in text. 
Called when caret position is changed. 
Converts (X, Y) position of the caret to zero-based text position. 
Converts (cX, cY) position (like CaretPos) to position with respect to the top-left corner of the char in editor client coordinates. 
Called when the text for the syntax memo is changed. 
Changes case of the specified text range. 
Deletes all text from the edit control. 
Removes all bookmarks. 
Removes all service objects. 
Clears redo records from undo buffer. 
Removes the selected text from the edit control. 
Clears the undo buffer so that no changes to the text can be backed out. 
Returns client reference if client is of type AClass. 
Collapses lines of the specified text range. 
Collapses nearest text range that contains given line. 
Collapses specified text range. 
Collapses specified user range. 
Jumps to the position of the last marker. 
Replaces Tab characters by the Spaces using TabList
Copies the selected text in the edit control to the Clipboard. 
Creates and initializes a TCustomSyntaxMemo instance. 
Creates marker at specified position. 
Initializes a window-creation parameter record passed in the Params parameter. 
Creates standard popup menu. 
Creates user range for the current selection and initialize some of it's properties. 
Creates a Windows control corresponding to the edit control. 
Returns height of the Canvas font in pixels. 
Returns current user range. 
Copies the selected text to the Clipboard and then deletes the selection. 
Default line height, which is equal sum of default text height (in current zoom) plus line spacings. 
Returns default character size. 
Deletes given number of characters from the caret position. 
Destroys an instance of TCustomSyntaxMemo. 
Performs automatic formatting of the text. 
Called before deleting portion of text. This method may be overridden in derived classes to control delete operations. 
Called before inserting text. This method may be overridden in derived classes to control inserting operations. 
Called while dragging text margin. 
Called after inserting single character in text. 
Called when scroll position is changed. Calls OnScroll event. 
Shows hint. 
Paints marker. 
Paints block staple one line portion. 
Drops marker at the specified caret position. 
Duplicates specified line. 
Re-enables screen repainting. 
Executes specified command. 
Executes standard edit actions. 
Replaces all Tab characters with the Spaces. 
Saves editor's text to file in HTML format. 
Saves editor's text to file in RTF format. 
Called when syntax analysis is finished. 
Returns index of first non-space character in the string S. 
Returns display style at the given text position. 
Called when styles of syntax analyzer is changed. 
Collapses text ranges and user ranges. 
Expands all collapsed ranges. 
Returns cursor when mouse is at specified position. 
Returns list of gutter objects at the specified line. 
Returns indent string. 
Calculates line layout, properties and word breaks. 
Returns line number string. This string is displayed as line number on the gutter. 
Called when mouse down to determine selection mode. 
Returns lines range with selection. 
Adds styled regions at specified position into List. 
Returns hint text for the specified token. 
Moves caret to the given bookmark, if this bookmark is assigned. 
Called on MouseDown when mouse cursor is over gutter. 
Returns gutter object at specified position. 
Return True if there is any selection. 
Shows current hint. 
Puts editor in incremental search mode. 
Terminates incremental search. 
Indents lines from sl line to el line on the Count positions. 
Inserts new line and indents caret position. This method performs auto-closing of opened text ranges. 
Inserts text at the caret position. 
Inserts multi-line text block to the specified (caret) position. 
Deletes portion of the text. 
Inserts text. 
Sets caret position. 
Sets linear selected block without caret moving. 
Invalidates only gutter. 
Invalidates specified lines. If UpdateHeights is true resets line information to recalculate heights. 
Invalidates lines occupied by the text range from StartPos to EndPos. 
Indicates whether specified command may be processed. 
Returns folding state of the line at the specified index. 
Defines whether mouse position (in client coordinates) is over text icon of collapsed text range. 
Defines whether character is "word" character. 
Iterates visible lines and calls Proc for each line. 
Moves caret to the matching "delimiter" (changes range side). 
Responds to key press events. 
Responds to keyboard input. 
Responds to released key. 
Returns position of last letter in the string S. 
Returns line number at client coordinate Y. 
Comments lines. 
Returns total line height. 
Calculates logical position from the caret position. 
Calculates logical position from the position in line. 
Calculates logical line number. 
Loads text from the specified file. 
Loads state of the editor from file. 
Calculates real line number from logical line number. 
Calculates caret position from logical position. 
Responds to mouse down event. 
Respond to mouse moving into control area. 
Responds to mouse moving out of control area. 
Responds to mouse move event. 
Calculates caret position for the point in editor's client coordinates. 
Responds to mouse up event. 
Moves selected lines on one line up or down. 
Moves selected text to new position. 
Returns caret position of the next word after word at caret position pt. 
Forwards notification messages to all owned components. 
Renders the image of a syntax editor. 
Called before painting areas not occupied by text. By default method returns False which means using default drawing. To customize painting in descendent return True and perform painting yourself. 
Pastes contents of the Clipboard into edit control, replacing the current selection. 
Defines whether position is in selection. 
Returns caret position of the previous word before word at caret position pt. 
Main line processing procedure. 
Call Redo to repeat last undone operation. 
Refreshes results of syntactical analysis. 
Removes client. 
Removes trailing spaces. 
Replaces some portion of the text with the RepStr string. 
Closes hint window. 
Clears buffered line heights for lines after FromLine. 
Removes all search marks from the editor. 
Resets current selection. 
Responds to control resize. 
Save state of the editor to file. 
Saves text to the specified file. 
Scrolls text to make caret position visible. 
Scrolls text to specified scrolling position. 
Changes case of current selection. 
Selects all text in the edit control. 
Called when selection was changed. 
Selects specified line. 
Selects text lines. 
Selects word at the caret position. 
Sets text to the editor. 
Sets border style. 
Set cursor. 
Sets new search mark. 
Sets linear selected block and moves caret to the end of the selected block. 
Indents/unindents selected block. 
Expands all collapsed blocks which contain specified line, so this line becomes visible. 
Makes specified lines visible if they were folded. 
Calculates line height without word-wrapping. 
Repeats last single undone operation. 
Undoes last single operation. 
Looks for first visible character from the specified position. 
Returns nearest visible line relative specified line. 
Sorts lines. 
Sorts lines of selection. 
Calculates indent of the string S. Indent is a logical in-line position of the first non-space character. 
Returns caret position for the given text position. 
Prevents moving caret after following insert/delete operation. 
Drops marker at the caret position and collects the previous marker. 
Calculates rectangle of the editor text region. 
Called after text have been changed. 
ToggleBookmark sets or clears bookmarked locations. 
Toggles collapsing of the specified line. 
Toggles collapse state of internal (child) ranges of the range at the specified line. 
Returns index of the token at the specified mouse position. 
Backs out changes in the undo buffer. 
Replaces TAB characters with spaces. 
Updates standard edit actions to reflect the current state of the editor. 
Invalidates editor and adjusts scroll bars. 
Returns number of visible columns (characters). 
Returns number of visible lines. 
Provides specific message responses for the control. 
Returns word at the given caret position. 
Returns word bounds at the given caret position. 
TCustomSyntaxMemo Class
TCustomSyntaxMemo Class 
Library version. 
Specifies text alignment within text area. 
Represents animation properties container. 
Specifies background properties. 
Specifies the number of spaces to indent a marked block. 
Lists the bookmarks (TBookmark objects) in the editor. 
Returns zero-based position of the bookmark with the specified index. 
Determines whether the edit control has a single line border around the client area. 
Indicates whether clipboard contains text. 
Indicates whether the edit control contains changes that can be backed out. 
Specifies the TCanvas object that presents a drawing surface for the control. 
Caret manager with caret properties definitions for different modes. 
Indicates the position of the caret in the memo lines. 
Indicates the position of the caret in the memo text. 
Determines the case of the text drawing. 
Specifies character set of the text in editor. 
Indicates number of connected to syntax memo clients. 
Provides indexed access to the clients of syntax memo. 
Specifies color of the line separator drawn at the bottom of the collapsed region. 
Provides indexed access to collapsed ranges. 
Specifies level of text ranges that will be affected by the "Collapse all" command. 
Specifies how to display collapsed regions. 
Specifies the background color of the control. 
Specifies current line, i.e. index of line with caret. 
Specifies the image used to represent the mouse pointer when it passes into the region covered by the control. 
Specifies whether default popup menu should be used. 
Default styles. 
Specifies whether text folding is disabled. 
Specifies whether drag&drop operations are performed using OLE drag&drop engine. 
Specifies scroll bar appearance. 
Controls the attributes of text written on or in the control. 
Represents gutter properties (except of line numbers) container. 
Represents hint properties container. 
Horizontal ruler at the top side of the editor. The width of one unit is equal to default character width. 
Specifies whether incremental search has backward direction. 
Specifies whether incremental search has to ignore case. 
Indicates current incremental search text. 
Identifies the key mapping associated with the editor. 
Controls keystrokes queue. 
Provides indexed access to the line information records. 
Represents line numbers properties container. 
Contains the individual lines of text in the syntax memo control. 
Specifies extra interval between lines and sub-line. 
Specifies extra interval after each line. 
Specifies extra interval before each line. 
Represents line state display properties. 
Offsets of Text area 
Lists markers. 
Indicates whether the user edited the text of the edit control. 
Specifies mode of internal text size calculation. 
Specifies whether syntax memo works like multi-line or single-line edit control. 
Represents non printed characters properties container. 
Specifies a syntax memo's flags that allow to adjust editor behavior. 
Specifies a syntax memo's additional flags that allow to adjust editor behavior. 
Specifies options that are used to perform output to the external Canvas
Determines whether the user can change the text of the syntax memo. 
Specifies how user text input must be inserted in the editor text. 
Specifies right margin position in characters. 
Specifies the color of right margin line. 
Specifies options of save/load state operations. 
Determines whether the syntax memo control has scroll bars. 
Specifies horizontal scrolling position of the syntax memo. 
Specifies visible vertical scrolling position of the syntax memo. 
Specifies list of search marks. 
Provides interface for custom text formatting. 
Represents current selection mode of the syntax memo. 
Specifies the number of characters that are selected. 
Specifies the selected columnar block. 
Specifies the position of the first selected character in the text. 
Specifies the selected portion of the editor's text. 
Specifies whether right margin is visible. 
Specifies back offset of the block staples from the initial position. 
Specifies a pen to draw block staples. 
Manages synchronized editing. 
Specifies TSyntAnalyzer object that is used for syntax highlighting. 
Points to client syntactical analyzer object associated with the syntax memo. 
Represents container of tab positions list. 
Specifies action when user presses Tab key. 
Contains a text string associated with the control. 
Indicates length of the whole editor's text. 
Specifies distance between editor's text area and gutter. 
Represents collection of text margins. 
Specifies external text container. 
Specifies number of a top visible line. 
Makes syntax memo transparent. 
Specifies the number of keystrokes that can be undone. 
Lists the user ranges (TUserRange objects) in the editor. 
Specifies styles container to be used with the user ranges. 
Determines whether the editor wraps text at the right side of text area. 
Specifies zoom factor. 
Copyright (c) 2004-2011. All rights reserved.
What do you think about this topic? Send feedback!