See also add-editor-keymap-functions.
See also add-editor-keymap-functions.
Appends menu items to a given menu (not a popup menu) to implement a standard set of font-manipulation operations, such as changing the font face or style. The callback for each menu item uses get-edit-target-object in top-level-window<%> (finding the frame by following a chain of parents until a frame is reached); if the result is an editor<%> object, change-style in editor<%> is called on the editor.
text-only? : any/c = #t
Appends menu items to a given menu (not a popup menu) to implement the standard editor operations, such as cut and paste. The callback for each menu item uses get-edit-target-object in top-level-window<%> (finding the frame by following a chain of parents until a frame is reached); if the result is an editor<%> object, do-edit-operation in editor<%> is called on the editor.
If text-only? is #f, then menu items that insert non-text snips (such as Insert Image...) are appended to the menu.
The initializer takes a keymap object and returns nothing. The default initializer chains the given keymap to an internal keymap that implements standard text editor keyboard and mouse bindings for cut, copy, paste, undo, and select-all. The right mouse button is mapped to popup an edit menu when the button is released. Under X, start-of-line (Ctl-A) and end-of-line (Ctl-E) are also mapped.
on : any/c
Under X Windows, editor selections conform to the X Windows selection conventions instead of a clipboard-based convention. If on is #f, the behavior is switched to the clipboard-based convention (where copy must be explicitly requested before a paste).
Gets the editor data class list instance for the current eventspace.
Gets the snip class list instance for the current eventspace.
on? : any/c
If on? is #t, m: corresponds to the Command key. If on? is #f, then m: corresponds to no key under Mac OS X.
Returns #t if m: corresponds to Command, #f otherwise.
(open-input-graphical-file filename) → input-port
filename : string?
Opens filename (in 'binary mode) and checks whether it looks like a “graphical” file in editor format. If the file does not appear to be an editor file, the file port is returned with line counting enabled. Otherwise, the file is loaded into an editor, and the result port is created with open-input-text-editor.
start-position : exact-nonnegative-integer? = 0
port-name : any/c = (scheme text-editor)
expect-to-read-all? : any/c = #f
Creates an input port that draws its content from text-editor. The editor content between positions start-position and end-position is the content of the port. If end-position is 'end, the content runs until the end of the editor. If a snip that is not a string-snip% object spans start-position or end-position, the entire snip contributes to the port. If a string-snip% instance spans start-position, only the part of the snip after start-position contributes, and if a string-snip% object spans end-position, only the part before end-position contributes.
An instance of string-snip% in text-editor generates a character sequence in the resulting port. All other kinds of snips are passed to snip-filter to obtain a “special” value for the port. If a snip is returned as the first result from snip-filter, and if the snip is an instance of readable-snip<%>, the snip generates a special value for the port through the read-special method. If snip-filter returns any other kind of snip, it is copied for the special result. Finally, a non-snip first result from snip-filter is used directly as the special result.
The port-name argument is used for the input port’s name. The expect-to-read-all? argument is a performance hint; use #t if the entire port’s stream will be read.
The result port must not be used if text-editor changes in any of the following ways: a snip is inserted (see after-insert), a snip is deleted (see after-delete), a snip is split (see after-split-snip), snips are merged (see after-merge-snips), or a snip changes its count (which is rare; see recounted). The get-revision-number method can be used to detect any of these changes.
port-name : any/c = (scheme text-editor)
Creates an output port that delivers its content to text-editor. The content is written to text-editor starting at the position start-position, where 'end indicates that output should start at the text editor’s current end position.
If special-filter is provided, it is applied to any value written to the port with write-special, and the result is inserted in its place. If a special value is a snip% object, it is inserted into the editor. Otherwise, the special value is displayed into the editor.
If line counting is enabled for the resulting output port, then the port will report the line, offset from the line’s start, and position within the editor at which the port writes data.
Reads data from in to initialize for reading editors from the stream. The return value is #t if the read succeeds, or #f otherwise.
One or more editors can be read from the stream by calling the editor’s read-from-file method. (The number of editors to be read must be known by the application beforehand.) When all editors are read, call read-editor-global-footer. Calls to read-editor-global-header and read-editor-global-footer must bracket any call to read-from-file, and only one stream at a time can be read using these methods or written using write-editor-global-header and write-editor-global-footer.
When reading from streams that span PLT Scheme versions, use read-editor-version before this procedure.
parse-format? : any/c
raise-errors? : any/c = #t
Reads version information from in-base, where in-base is the base for in. The version information parsed from in-base is recorded in in for later version-sensitive parsing. The procedure result is true if the version information was read successfully and if the version is supported.
If parse-format? is true, then in-base is checked for an initial "WXME" format indicator. Use #f when "WXME" has been consumed already by format-dispatching code.
If raise-errors? is true, then an error in reading triggers an exception, instead of a #f result.
filename : path = string
This procedure is a load handler for use with current-load.
The handler recognizes editor files by the first twelve characters of the file: WXME01‹digit›‹digit› ## . Such a file is opened for loading by creating a text% object, loading the file into the object with insert-file, and then converting the editor content into a port with open-input-text-editor. After obtaining a port in this way, the content is read in essentially the same way as by the default MzScheme load handler. The difference is that the editor may contain instances of readable-snip<%>, which are “read” though the snips’ read-special method; see open-input-text-editor for details.
Writes data to out, initializing it for writing editors to the stream. The return value is #t if the write succeeds, or #f otherwise.
One or more editors can be written to the stream by calling the editor’s write-to-file method. When all editors are written, call write-editor-global-footer. Calls to write-editor-global-header and write-editor-global-footer must bracket any call to write-to-file, and only one stream at a time can be written using these methods or read using read-editor-global-header and read-editor-global-footer.
To support streams that span PLT Scheme versions, use write-editor-version before this procedure.
See also File Format.
Writes version information to out-base in preparation for writing editor information to the stream out.
The out argument is currently not used, but out-base should be the base for out. In the future, out may record information about the version for later version-sensitive output.
The result is #t if the write succeeded, #f otherwise.