9 Editor
Classes matching this interface support the basic
editor<%>
functionality required by the framework.
This function returns
#t when the editor has the keyboard
focus. It is implemented using:
on-focusIndicates if this editor is in an edit sequence. Enclosing buffer’s
edit-sequence status is not considered by this method.
See
begin-edit-sequence
and
end-edit-sequence
for more info about edit sequences.
This method is used to install callbacks that will be run after any
edit-sequence completes.
The procedure thunk will be called immediately if the edit is
not in an edit-sequence. If the edit is in an edit-sequence, it will
be called when the edit-sequence completes.
If tag is a symbol, the thunk is keyed on that symbol, and
only one thunk per symbol will be called after the
edit-sequence. Specifically, the last call to
run-after-edit-sequence’s argument will be called.
This does not work for embedded editors.
Returns #t if the file on disk has been modified, by some other program.
|
→ boolean? |
filename : (union path #f) = #f |
| format | | : | | (union 'guess 'standard 'text 'text-force-cr same copy) | | | | = | | 'same |
|
show-errors? : boolean = |#t| |
This method is an alternative to
save-file. Rather than showing errors via the original stdout, it
opens a dialog with an error message showing the error.
The result indicates if an error happened (the error has
already been shown to the user). It returns #t if
no error occurred and #f if an error occurred.
|
→ boolean? |
filename : (union string #f) = #f |
| format | | : | | (union 'guess 'standard 'text 'text-force-cr 'same 'copy) | | | | = | | 'guess |
|
show-errors? : boolean = |#t| |
This method is an alternative to
load-file. Rather than showing errors via the original stdout, it
opens a dialog with an error message showing the error.
The result indicates if an error happened (the error has
already been shown to the user). It returns #t if
no error occurred and #f if an error occurred.
This method is called when an editor is closed.
Typically, this method is called when the frame
containing the editor is closed, but in some cases an
editor is considered “closed” before the frame it is
in is closed (e.g., when a tab in DrRacket is closed), and
thus
on-close will be called at that point.
See also
can-close?
and
close.
Does nothing.
This method is called to query the editor if is okay to
close the editor. Although there is no visible effect
associated with closing an editor, there may be some cleanup
actions that need to be run when the user is finished with
the editor (asking if it should be saved, for example).
See also
on-close and
close.
Returns #t.
This method is merely
(if (can-close?) |
(begin (on-close) #t) |
#f) |
It is intended as a shorthand, helper method for closing
an editor. See also
can-close?
and
on-close.
Returns the printed version of the filename for this
editor. If the editor doesn’t yet have a filename, it
returns a symbolic name (something like "Untitled").
This method’s first result is #f when the mouse
event does not correspond to a location in the editor.
If the first result is an text% object, then the
second result will be a position in the editor and
otherwise the second result will be #f.
The
editor<%> object will always be the nearest
enclosing editor containing the mouse click.
This provides the basic editor services required by the rest of the
framework.
The result of this mixin uses the same initialization arguments as the
mixin’s argument.
Each instance of a class created with this mixin contains a private
keymap% that is chained to the global keymap via:
(send keymap chain-to-keymap (keymap:get-global) #f).
This installs the global keymap
keymap:get-global to
handle keyboard and mouse mappings not handled by
keymap. The
global keymap is created when the framework is invoked.
Checks to see if the file on the disk has been modified out
side of this editor, using
save-file-out-of-date?.
If it has, this method prompts the user to be sure they want to save.
If the current filename is not a temporary filename, this method calls
handler:add-to-recentwith the current filename.
to add the new filename to the list of recently opened files.
Additionally, updates a private instance variable with the
modification time of the file, for using in implementing
save-file-out-of-date?.
Updates a private instance variable with the modification
time of the file, for using in implementing
save-file-out-of-date?(super on-new-image-snip |
(if (eq? kind 'unknown) 'unknown/mask kind) |
relative-path? |
inline?) |
In addition, it calls
set-load-overwrites-styles
with
#f.
This ensures that saved files with different
settings for the style list do not clobber
the shared style list.
Classes matching this interface add support for mixing in multiple
keymaps. They provides an extensible interface to chained keymaps,
through the
get-keymaps
method.
The keymaps returned from this method are chained to this
editor<%>’s keymap.
The result of this method should not change – that is, it
should return the same list of keymaps each time it is
called.
See also editor:add-after-user-keymap.
Classes implementing this interface keep the
auto-wrap
state set based on the
'framework:auto-set-wrap? preference
(see
preferences:get for more information about preferences).
Objects supporting this interface are expected to support files.
The result of this method is used as the parent for the
dialog that asks about closing.
Defaultly returns #f.
Attempts to find a frame that displays this editor. If it
does, it updates the frame’s title based on a new filename
in the editor.
This method indicates if closing the file when it hasn’t
been saved is a reason to alert the user. See also
can-close?.
Defaultly returns #f.
If the file has not been saved, this prompts the user about saving and,
if the user says to save, then it saves the file.
The result is #t if the save file is up to date, or if
the user says it is okay to continue without saving. Generally used
when closing the file or quiting the app.
This editor locks itself when the file that is opened is read-only in
the filesystem.
The class that this mixin produces uses the same initialization
arguments as its input.
|
name : string |
temp? : boolean = #f |
Updates the filename on each frame displaying this editor, for each
frame that matches
frame:editor<%>.
If the
allow-close-with-no-filename?
method returns
#f, this method checks to see if the file
has been saved at all yet. If not, it asks the user
about saving (and saves if they ask).
If the
allow-close-with-no-filename?
method returns #t, this method does as before,
except only asks if the editor’s
get-filenamemethod returns a path.
Also calls inner.
This returns a list containing the super-class’s keymaps, plus the
result of
keymap:get-file
Classes matching this interface support backup files and autosaving.
Indicates whether this
editor<%>
should be backed up.
Returns the value of the
preferences:get
applied to
'framework:backup-files?.
Indicates whether this
editor<%>
should be autosaved.
Returns #t.
When the file has been modified since it was last saved and autosaving
it turned on (via the
autosave?
method) an autosave file is created for this
editor<%>.
Returns the filename where the autosave took place, or
#f if none did.
This method removes the autosave file associated with this
editor<%>.
This mixin adds backup and autosave functionality to an editor.
The result of this mixin uses the same initialization arguments as the
mixin’s argument.
|
filename : path? |
format : (one-of/c 'guess 'standard 'text 'text-force-cr 'same 'copy) |
If a backup file has not been created this session for this file,
deletes any existing backup file and copies the old save file into the
backup file. For the backup file’s name, see
path-utils:generate-backup-name
Deletes the autosave file and turns off autosaving.
Sets a flag indicating that this
editor<%> needs to be autosaved.
If the file is no longer modified, this method deletes the autosave
file. If it is, it updates a flag to indicate that the autosave file
is out of date.
If the style named by name is already in the style list, it must
be a delta style.
Returns a style list that is used for all instances of
editor:standard-style-list%.
Returns a list that contains all of the keymaps in
keymaps, in the
same relative order, but also with
keymap, where
keymap
is now the first keymap after
keymap:get-user (if that keymap is
in the list.)