Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter SixFile Functions (continued)

6.7 Edit Objects

6.7.1 Overview

All edit windows that are based on text (i.e., Code View or Page View) will employ an edit object for tracking and processing changes to the document. Other edit views will also have an edit object with limited functionality.

The Edit Object (sometimes referred as Edit Data Exchange or EDX) is the conduit for other windows, processes and functions to communicate with a window using a well-defined methodology. For example, via the Edit Object the MDI tab manager retrieves the filename and edit status (window modified) for display.

Legato can act like any other function to access the Edit Object. While text based windows will share underlying data via the Mapped Text Object, each window will have its own select and caret position information.

The Edit Object also manages the edit transaction. An edit transaction consists of a series of changes made to the underlying file and grouped together as a single transaction group. The group can then be unwound, if necessary, to facilitate the undo function or spooled back to provide for redo. Edit transactions are spooled to a temporary file located in the user’s data area. This can then be used to replay all the changes to a file in the event of an application or workstation crash or significant failure. An edit transaction can be as simple as deleting a character or as complex as changing the font attributes for a series of table cells in the form of a column.

When a change is requested using the Edit Object, it will automatically open an edit transaction. When the Edit Object is closed, the transaction will be completed. The associated windows are not normally updated until the Edit Object is closed.

For text windows, all positions are referenced in the form of start and end x/y position, where x is the column position and y is the line position. These are considered text segments. This differs from the Mapped Text Object which allows access via complete lines or in the form of text segments. Use of the Edit Object does not preclude access of data via lines, but all data must be written in the form of a text segment. (Transaction data is stored in text segments.) Scripts must not use the DeleteLine, InsertLine or ReplaceLine functions with the underlying Mapped Text Object.

Select and caret positions are also managed via the Edit Object. A script can determine the type of selection, the select data and the position of the caret. Likewise, a script can also set this information.

An interesting problem with the x position within text files is the difference between native and realized positions. A tab character counts as a single character but will cause the file to potentially render in a different column position. For this reason select positions are always native and caret position are realized.

See the ExpandTabs and CollapseTabs functions for more information.

6.7.2 Related Functions

Caret:

GetCaretXPosition — Returns the current caret X position from an Edit Object or Edit View (column position) in native or realized position.

GetCaretYPosition — Returns the current caret Y position from an Edit Object or Edit View (line position).

GetLastXPosition — Returns the last X position written to by an Edit Object.

GetLastYPosition — Returns the last Y position written to by an Edit Object.

SetCaretPosition — Sets the caret position (updated on CloseHandle or UpdateEditWindow).

Mapped Text Object:

GetAbsoluteFilePosition — Translates X and Y position to the absolute file position within a Mapped Text Object.

GetLineCount — Gets the number of lines in a Mapped Text or Edit Object.

GetLineSize — Gets the size of a line in a Mapped Text or Edit Object as native or optional realized bytes.

GetMappedTextEncoding — Returns the encoding for a Mapped Text Object.

GetMappedTextEncodingString — Returns the encoding for a Mapped Text Object as a string.

GetMappedTextFilename — Returns the name of the file associated with a Mapped Text Object.

IsBlankLine — Tests a line within a Mapped Text Object for being blank (white space does not count as text).

MappedTextExport — Exports a Mapped Text Object to the specified file.

MappedTextSave — Saves a Mapped Text Object (remaps to new saved file).

MoveToNonBlankLine — Looks forward until a non-blank line is encountered within a Mapped Text Object.

ReadSegment — Reads a segment of data from a Mapped Text or Edit Object.

WriteSegment — Writes a segment of string data to a Mapped Text or Edit Object at an optional specified position.

Object Control:

GetEditObject — Gets an Edit Object and associates it with an edit window.

GetEditObjectFilename — Returns the fully qualified name (source file or object) for an edit object or window.

GetEditObjectFileType — Returns the file type associated with an Edit Object.

GetEditObjectName — Returns the edit object/window name without path (source file or object).

GetEditObjectType — Returns the edit/object window type.

GetEditObjectWindow — Returns the view handle associated with the Edit Object.

GetName — Gets the name of an object or entry, value depends on the object handle type.

Select:

GetSelectClue — Returns the select clue.

GetSelectCount — Returns the number of selected items (if the mode is array).

GetSelectEndXPosition — Returns the select end X position.

GetSelectEndYPosition — Returns the select end Y position.

GetSelectMode — Returns the current select mode.

GetSelectStartXPosition — Returns the select start X position.

GetSelectStartYPosition — Returns the select start X position.

SetSelectMode — Sets the select mode.

Transaction Management:

GetEditObjectChangeCount — Returns the number of pending changes or total changes, if flag is TRUE.

GetEditObjectElapsedTime — Returns the elapsed time in seconds since opened.

Window:

UpdateEditWindow — Updates the edit window as required.