drscheme:modes:add-mode in DrScheme Tools Functions
(drscheme:modes:add-mode -> drscheme:modes:mode?
name surrogate repl-submit matches-language)
name : string?
surrogate : (union false? (is-a?/c mode:surrogate-text<%>))
repl-submit : ((is-a?/c drscheme:rep:text%) number? . -> . boolean?)
matches-language : ((union false? (listof string?)) . -> . boolean?)
Adds a mode to DrScheme. Returns a mode value that identifies the mode.
The first argument, name, is the name
of the mode, used in DrScheme's GUI to allow
the user to select this mode.
The surrogate argument is set to the
definitions text and the interactions text
(via the
set-surrogate method) whenever this mode is enabled.
The repl-submit procedure is called
whenever the user types a return in the interactions
window. It is passed the interactions editor
and the position where the last prompt occurs.
If it
returns #t, the text after the last
prompt is treated as a program fragment and
evaluated, according to the language settings.
If it returns #f, the text is
assumed to be an incomplete program fragment, and
the keystroke is not treated specially.
The matches-language predicate is called whenever
the language changes. If it returns #t
this mode is installed. It is passed the list of strings
that correspond to the names of the language in the
language dialog.
Modes are tested in the opposite order that they are added. That is, the last mode to be added gets tested first when the filename changes or when the language changes.
See also
drscheme:modes:get-modes.