scribble wxme docs
svn: r8000
This commit is contained in:
parent
012641498b
commit
a375882307
|
@ -15,8 +15,10 @@
|
|||
|
||||
(require (for-label mred
|
||||
mzlib/class
|
||||
mzlib/contract
|
||||
scheme/base))
|
||||
(provide (for-label (all-from-out mred)
|
||||
(all-from-out mzlib/class)
|
||||
(all-from-out mzlib/contract)
|
||||
(all-from-out scheme/base))))
|
||||
|
||||
|
|
|
@ -339,18 +339,19 @@ See @xmethod[text% get-styles-sticky] for more information about the
|
|||
@section[#:tag "editorfileformat"]{File Format}
|
||||
|
||||
To allow editor content to be saved to a file, the editor classes
|
||||
implement a special file format. (The format is used when cutting and
|
||||
pasting between applications or eventspaces, too). The file format is
|
||||
not documented, except that it begins
|
||||
@litchar{WXME01}@nonterm{digit}@nonterm{digit} ## }. Otherwise, the
|
||||
implement a special file format called @deftech{WXME}. (The format is
|
||||
used when cutting and pasting between applications or eventspaces,
|
||||
too). The file format is not documented, except that it begins
|
||||
@litchar{WXME01}@nonterm{digit}@nonterm{digit}@litchar{ ## }. Otherwise, the
|
||||
@method[editor<%> load-file] and @method[editor<%> save-file] methods
|
||||
define the format internally. The file format is the same for text
|
||||
and pasteboard editors. When a pasteboard saves its content to a
|
||||
file, it saves the snips from front to back, and also includes extra
|
||||
location information.
|
||||
location information. The @schememodname[wxme] library provides
|
||||
utilities for manipulating WXME files.
|
||||
|
||||
Editor data is read and written using @scheme[editor-stream-in%] and
|
||||
@scheme[editor-stream-out%] objects. Editor information can only be
|
||||
@scheme[editor-stream-out%] objects. Editor information can only be
|
||||
read from or written to one stream at a time. To write one or more
|
||||
editors to a stream, first call the function
|
||||
@scheme[write-editor-global-header] to write initialization data into
|
||||
|
@ -417,7 +418,7 @@ Snip classes, snip data, and snip data classes solve problems related
|
|||
Each snip can be associated to a @deftech{snip class}. This ``class''
|
||||
is not a class description in the programmer's language; it is an
|
||||
object which provides a way to create new snips of the appropriate
|
||||
type from an encoded snip specification.
|
||||
type from an encoded snip specification.
|
||||
|
||||
Snip class objects can be added to the eventspace-specific
|
||||
@deftech{snip class list}, which is returned by
|
||||
|
@ -427,13 +428,27 @@ Snip class objects can be added to the eventspace-specific
|
|||
snip's class. The snip class will then provide a decoding function
|
||||
that can create a new snip from the encoding.
|
||||
|
||||
If a snip class's name is of the form @scheme["(lib ...)"], then the
|
||||
snip class implementation can be loaded on demand. The name is parsed
|
||||
using @scheme[read]; if the result has the form @scheme[(lib _string
|
||||
...)], then it is supplied to @scheme[dynamic-require] along with
|
||||
@scheme['snip-class]. If the result is a @scheme[snip-class%] object,
|
||||
it is inserted into the current eventspace's snip class list, and
|
||||
loading or saving continues using the new class.
|
||||
If a snip class's name is of the form
|
||||
@;-
|
||||
@scheme["((lib ...) (lib ...))"],
|
||||
@;-
|
||||
then the snip class implementation can be loaded on
|
||||
demand. The name is parsed using @scheme[read]; if the result has the
|
||||
form @scheme[((lib _string ...) (lib _string ...))], then the first
|
||||
element used with @scheme[dynamic-require] along with
|
||||
@scheme['snip-class]. If the @scheme[dynamic-require] result is a
|
||||
@scheme[snip-class%] object, then it is inserted into the current
|
||||
eventspace's snip class list, and loading or saving continues using
|
||||
the new class.
|
||||
|
||||
The second @scheme[lib] form in @scheme["((lib ...) (lib ...))"]
|
||||
supplies a reader for a text-only version of the snip. See
|
||||
@schememodname[wxme] for more information.
|
||||
|
||||
A snip class's name can also be just @scheme["(lib ...)"], which is
|
||||
used like the first part of the two-@scheme[lib] form. However, this
|
||||
form provides no information for the text-only @schememodname[wxme]
|
||||
reader.
|
||||
|
||||
@subsubsection[#:tag "editordata"]{Editor Data}
|
||||
|
||||
|
@ -449,10 +464,10 @@ Just as a snip must be associated with a snip class to be decoded (see
|
|||
data class} for decoding. Every editor data class object can be added
|
||||
to the eventspace-specific @deftech{editor data class list}, returned
|
||||
by @scheme[get-the-editor-data-class-list]. Alternatively, like snip
|
||||
classes, editor data class names can use the form @scheme["(lib ...)"]
|
||||
to enable on-demand loading. The corresponding module should export an
|
||||
@scheme[editor-data-class%] object named
|
||||
@scheme['editor-data-class].
|
||||
classes (see @secref["editorsnipclasses"]), editor data class names
|
||||
can use the form @scheme["((lib ...) (lib ...))"] to enable
|
||||
on-demand loading. The corresponding module should export an
|
||||
@scheme[editor-data-class%] object named @scheme['editor-data-class].
|
||||
|
||||
To store and load information about a snip or region in an editor:
|
||||
|
||||
|
|
|
@ -11,3 +11,4 @@
|
|||
@include-section["draw-funcs.scrbl"]
|
||||
@include-section["editor-classes.scrbl"]
|
||||
@include-section["editor-funcs.scrbl"]
|
||||
@include-section["wxme.scrbl"]
|
||||
|
|
|
@ -44,9 +44,9 @@ Returns the class's name, a string uniquely designating this snip
|
|||
class. For example, the standard text snip classname is
|
||||
@scheme["wxtext"]. Names beginning with @litchar{wx} are reserved.
|
||||
|
||||
A snip class name should usually have the form @scheme["(lib ...)"] to
|
||||
enable on-demand loading of the class; see @|snipclassdiscuss| for
|
||||
details.
|
||||
A snip class name should usually have the form @scheme["((lib ...)
|
||||
(lib ...))"] to enable on-demand loading of the class. See
|
||||
@|snipclassdiscuss| for details.
|
||||
|
||||
}
|
||||
|
||||
|
|
623
collects/scribblings/gui/wxme.scrbl
Normal file
623
collects/scribblings/gui/wxme.scrbl
Normal file
|
@ -0,0 +1,623 @@
|
|||
#lang scribble/doc
|
||||
@(require "common.ss"
|
||||
(for-label wxme
|
||||
wxme/editor
|
||||
wxme/image
|
||||
(except-in wxme/comment reader)
|
||||
(except-in wxme/xml reader)
|
||||
(except-in wxme/scheme reader)
|
||||
(except-in wxme/text reader)
|
||||
(except-in wxme/test-case reader)
|
||||
(except-in wxme/cache-image reader)))
|
||||
|
||||
@(define-syntax-rule (in mod . content)
|
||||
(begin
|
||||
(define-syntax-rule (intro)
|
||||
(begin (require (for-label mod))
|
||||
. content))
|
||||
(intro)))
|
||||
|
||||
@title{WXME Decoding}
|
||||
|
||||
@defmodule[wxme]{The @schememodname[wxme] library provides tools for
|
||||
reading @tech{WXME} @scheme[editor<%>]-format files (see
|
||||
@secref["editorfileformat"]) without the @scheme[scheme/gui] library
|
||||
(i.e., using @exec{mzscheme} instead of @exec{mred}).}
|
||||
|
||||
|
||||
@defproc[(is-wxme-stream? [in input-port?]) boolean?]{
|
||||
|
||||
Peeks from @scheme[in] and returns @scheme[#t] if it starts with the
|
||||
magic bytes indicating a @tech{WXME}-format stream (see
|
||||
@secref["editorfileformat"]), @scheme[#f] otherwise.}
|
||||
|
||||
|
||||
@defproc[(wxme-port->text-port [in input-port?] [close? any/c #t])
|
||||
input-port?]{
|
||||
|
||||
Takes an input port whose stream starts with @tech{WXME}-format data
|
||||
and returns an input port that produces a text form of the WXME
|
||||
content, like the result of opening a WXME file in DrScheme and saving
|
||||
it as text.
|
||||
|
||||
If @scheme[close?] is true, then closing the result port close the
|
||||
original port.
|
||||
|
||||
See @secref["snipclassmapping"] for information about the kinds of
|
||||
non-text content that can be read.}
|
||||
|
||||
|
||||
@defproc[(wxme-port->port [in input-port?]
|
||||
[close? any/c #t]
|
||||
[snip-filter (any/c . -> . any/c) (lambda (_x) _x)])
|
||||
input-port?]{
|
||||
|
||||
Takes an input port whose stream starts with @tech{WXME}-format data
|
||||
and returns an input port that produces text content converted to
|
||||
bytes, and non-text content as ``special'' values (see
|
||||
@scheme[read-char-or-special]).
|
||||
|
||||
These special values produced by the new input port are different than
|
||||
the ones produced by reading a file into an @scheme[editor<%>]
|
||||
object. Instead of instances of the @scheme[snip%], the special values
|
||||
are typically simple extensions of @scheme[object%]. See
|
||||
@secref["snipclassmapping"] for information about the kinds of
|
||||
non-text content that can be read.
|
||||
|
||||
If @scheme[close?] is true, then closing the result port close the
|
||||
original port.
|
||||
|
||||
The @scheme[snip-filter] procedure is applied to any special value
|
||||
generated for the stream, and its result is used as an alternate
|
||||
special value.
|
||||
|
||||
If a special value (possibly produced by the filter procedure) is an
|
||||
object implementing the @scheme[readable<%>] interface, then the
|
||||
object's @method[readable<%> read-special] method is called to produce
|
||||
the special value.}
|
||||
|
||||
|
||||
@defproc[(extract-used-classes [in input-port?])
|
||||
(values (listof string?)
|
||||
(listof string?))]{
|
||||
|
||||
Returns two values: a list of snip-class names used by the given
|
||||
stream, and a list of data-class names used by the stream. If the
|
||||
stream is not a @tech{WXME} stream, the result is two empty lists. The
|
||||
given stream is not closed, and only data for a @tech{WXME} stream (if
|
||||
any) is consumed.}
|
||||
|
||||
|
||||
@defproc[(register-lib-mapping! [str string?]
|
||||
[mod-path (cons/c (one-of/c 'lib) (listof string?))])
|
||||
void?]{
|
||||
|
||||
Maps a snip-class name to a quoted module path that provides a
|
||||
@scheme[reader%] implementation. The module path must have the form
|
||||
@scheme['(lib #,(scheme _string ...))], where each @scheme[_string]
|
||||
contains only alpha-numeric ASCII characters, @litchar{.},
|
||||
@litchar{_}, @litchar{-}, and spaces.}
|
||||
|
||||
|
||||
@defproc[(string->lib-path [str string?] [gui? any/c])
|
||||
(cons/c (one-of/c 'lib) (listof string?))]{
|
||||
|
||||
Returns a quoted module path for @scheme[str] for either
|
||||
@scheme[editor<%>] mode when @scheme[gui?] is true, or
|
||||
@schememodname[wxme] mode when @scheme[gui?] is @scheme[#f]. For the
|
||||
latter, built-in mappings and mapping registered via
|
||||
@scheme[register-lib-mapping!] are used. If @scheme[str] cannot be
|
||||
parsed as a library path, and if no mapping is available (either
|
||||
because the class is built-in or not known), the result is
|
||||
@scheme[#f].}
|
||||
|
||||
|
||||
@defboolparam[unknown-extensions-skip-enabled skip?]{
|
||||
|
||||
A parameter. When set to #f (the default), an exception is raised when
|
||||
an unrecognized snip class is encountered in a @tech{WXME}
|
||||
stream. When set to a true value, instances of unrecognized snip
|
||||
classes are simply omitted from the transformed stream.}
|
||||
|
||||
|
||||
@defboolparam[broken-wxme-big-endian? big?]{
|
||||
|
||||
A parameter. Some old and short-lived @tech{WXME} formats depended on
|
||||
the endian order of the machine where the file was saved. Set this
|
||||
parameter to pick the endian order to use when reading the file; the
|
||||
default is the current platform's endian order.}
|
||||
|
||||
|
||||
@defproc[(wxme-read [in input-port?]) any/c]{
|
||||
|
||||
Like @scheme[read], but for a stream that starts with
|
||||
@tech{WXME}-format data. If multiple S-expressions are in the
|
||||
@tech{WXME} data, they are all read and combined with
|
||||
@scheme['begin].
|
||||
|
||||
If @scheme[scheme/gui/base] is available (as determined by
|
||||
@scheme[gui-available?]), then @scheme[open-input-text-editor] is
|
||||
used. Otherwise, @scheme[wxme-port->port] is used.}
|
||||
|
||||
|
||||
@defproc[(wxme-read-syntax [source-v any/c] [in input-port?])
|
||||
(or/c syntax? eof-object?)]{
|
||||
|
||||
Like @scheme[read-syntax], but for a @tech{WXME}-format input stream.
|
||||
If multiple S-expressions are in the @tech{WXME} data, they are all
|
||||
read and combined with @scheme['begin].
|
||||
|
||||
If @scheme[scheme/gui/base] is available (as determined by
|
||||
@scheme[gui-available?]), then @scheme[open-input-text-editor] is
|
||||
used. Otherwise, @scheme[wxme-port->port] is used.}
|
||||
|
||||
|
||||
@definterface[snip-reader<%> ()]{
|
||||
|
||||
An interface to be implemented by a reader for a specific kind of data
|
||||
in a @tech{WXME} stream. The interface has two methods:
|
||||
@method[snip-reader<%> read-header] and @method[snip-reader<%> read-snip].
|
||||
|
||||
@defmethod[(read-header [version exact-nonnegative-integer?]
|
||||
[stream (is-a?/c stream<%>)])
|
||||
any]{
|
||||
|
||||
Called at most once per @tech{WXME} stream to initialize the data
|
||||
type's stream-specific information. This method usually does nothing.}
|
||||
|
||||
@defmethod[(read-snip [text-only? Boolean?]
|
||||
[version exact-nonnegative-integer?]
|
||||
[stream (is-a?/c stream<%>)])
|
||||
any/c]{
|
||||
|
||||
Called when an instance of the data type is encountered in the
|
||||
stream. This method reads the data and returns either bytes to be
|
||||
returned as part of the decoded stream or any other kind of value to
|
||||
be returned as a ``special'' value from the decoded stream. The result
|
||||
value can optionally be an object that implements
|
||||
@scheme[readable<%>].}
|
||||
|
||||
}
|
||||
|
||||
@definterface[readable<%> ()]{
|
||||
|
||||
An interface to be implemented by values returned from a snip reader.
|
||||
The only method is @method[readable<%> read-special].
|
||||
|
||||
@defmethod[(read-special [source any/c]
|
||||
[line (or/c nonnegative-exact-integer? false/c)]
|
||||
[column (or/c nonnegative-exact-integer? false/c)]
|
||||
[position (or/c nonnegative-exact-integer? false/c)])
|
||||
any/c]{
|
||||
|
||||
Like @method[readable-snip<%> read-special], but for non-graphical
|
||||
mode. When a value implements this interface, its @method[readable<%>
|
||||
read-special] method is called with source-location information to
|
||||
obtain the ``special'' result from the @tech{WXME}-decoding port.}
|
||||
|
||||
}
|
||||
|
||||
@definterface[stream<%> ()]{
|
||||
|
||||
Represents a @tech{WXME} input stream for use by
|
||||
@scheme[snip-reader<%>] instances.
|
||||
|
||||
@defmethod[(read-integer [what any/c]) exact-integer?]{
|
||||
|
||||
Reads an exact integer, analogous to @method[editor-stream-in%
|
||||
get-exact].
|
||||
|
||||
The @scheme[what] field describes what is being read, for
|
||||
error-message purposes, in case the stream does not continue with an
|
||||
integer.}
|
||||
|
||||
@defmethod[(read-fixed-integer [what any/c]) exact-integer?]{
|
||||
|
||||
Reads an exact integer that has a fixed size in the stream, analogous
|
||||
to @method[editor-stream-in% get-fixed].
|
||||
|
||||
The @scheme[what] argument is as for @method[stream<%> read-integer].}
|
||||
|
||||
@defmethod[(read-inexact [what any/c]) (and/c real? inexact?)]{
|
||||
|
||||
Reads an inexact real number, analogous to @method[editor-stream-in%
|
||||
get-inexact].
|
||||
|
||||
The @scheme[what] argument is as for @method[stream<%> read-integer].}
|
||||
|
||||
@defmethod[(read-raw-bytes [what any/c]) bytes?]{
|
||||
|
||||
Reads raw bytes, analogous to @method[editor-stream-in%
|
||||
get-unterminated-bytes].
|
||||
|
||||
The @scheme[what] argument is as for @method[stream<%> read-integer].}
|
||||
|
||||
@defmethod[(read-bytes [what any/c]) bytes?]{
|
||||
|
||||
Reads raw bytes, analogous to @method[editor-stream-in% get-bytes].
|
||||
|
||||
The @scheme[what] argument is as for @method[stream<%> read-integer].}
|
||||
|
||||
@defmethod[(read-editor [what any/c]) input-port?]{
|
||||
|
||||
Reads a nested editor, producing a new input port to extract the
|
||||
editor's content.
|
||||
|
||||
The @scheme[what] argument is as for @method[stream<%> read-integer].}
|
||||
}
|
||||
|
||||
@; ----------------------------------------------------------------------
|
||||
|
||||
@section[#:tag "snipclassmapping"]{Snip Class Mapping}
|
||||
|
||||
When graphical data is marshaled to the WXME format, it is associated
|
||||
with a snip-class name to be matched with an implementation at load
|
||||
time. See also @secref["editorsnipclasses"].
|
||||
|
||||
Ideally, the snip-class name is generated as
|
||||
|
||||
@schemeblock[
|
||||
(format "~s" (list '(lib #,(scheme _string ...))
|
||||
'(lib #,(scheme _string ...))))
|
||||
]
|
||||
|
||||
where each element of the @scheme[format]ed list is a quoted module
|
||||
path (see @scheme[module-path?]). The @scheme[_string]s must contain only
|
||||
alpha-numeric ASCII characters, plus @litchar{.}, @litchar{_},
|
||||
@litchar{-}, and spaces, and they must not be @scheme["."] or
|
||||
@scheme[".."].
|
||||
|
||||
In that case, the first quoted module path is used for loading
|
||||
@tech{WXME} files in graphical mode; the corresponding module must
|
||||
provide @schemeidfont{snip-class} object that implements the
|
||||
@scheme[snip-class%] class. The second quoted module path is used by
|
||||
the @schememodname[wxme] library for converting @tech{WXME} streams
|
||||
without graphical support; the corresponding module must provide a
|
||||
@schemeidfont{reader} object that implements the @scheme[reader<%>]
|
||||
interface. Naturally, the @scheme[snip-class%] instance and
|
||||
@scheme[reader<%>] instance are expected to parse the same format, but
|
||||
generate different results suitable for the different contexts (i.e.,
|
||||
graphical or not).
|
||||
|
||||
If a snip-class name is generated as
|
||||
|
||||
@schemeblock[
|
||||
(format "~s" '(lib #,(scheme _string ...)))
|
||||
]
|
||||
|
||||
then graphical mode uses the sole module path, and
|
||||
@schememodname[wxme] needs a compatibility mapping. Install one with
|
||||
@scheme[register-lib-mapping!].
|
||||
|
||||
If a snip-class name has neither of the above formats, then graphical
|
||||
mode can use the data only if a snip class is registered for the name,
|
||||
or if it the name of one of the built-in classes: @scheme["wxtext"],
|
||||
@scheme["wxtab"], @scheme["wximage"], or @scheme["wxmedia"] (for
|
||||
nested editors). The @schememodname[wxme] library needs a
|
||||
compatibility mapping installed with @scheme[register-lib-mapping!]
|
||||
if it is not one of the built-in classes.
|
||||
|
||||
Several compatibility mappings are installed automatically for the
|
||||
@schememodname[wxme] library. They correspond to popular graphical
|
||||
elements supported by various versions of DrScheme, including comment
|
||||
boxes, fractions, XML boxes, Scheme boxes, text boxes, and images
|
||||
generated by the ``world'' and ``image'' teachpacks (or, more
|
||||
generally, from @schememodname[mrlib/cache-image-snip]), and test-case
|
||||
boxes.
|
||||
|
||||
For a port created by @scheme[wxme-port->port], nested editors are
|
||||
represented by instances of the @scheme[editor%] class provided by the
|
||||
@schememodname[wxme/editor] library. This class provides a single
|
||||
method, @method[editor% get-content-port], which returns a port for
|
||||
the editor's content. Images are represented as instances of the
|
||||
@scheme[image%] class provided by the @schememodname[wxme/image]
|
||||
library.
|
||||
|
||||
Comment boxes are represented as instances of a class that extends
|
||||
@scheme[editor%] to implement @scheme[readable<%>]; see
|
||||
@schememodname[wxme/comment]. The read form produces a special comment
|
||||
(created by @scheme[make-special-comment]), so that the comment box
|
||||
disappears when @scheme[read] is used to read the stream; the
|
||||
special-comment content is the readable instance. XML, Scheme, and
|
||||
text boxes similarly produce instances of @scheme[editor%] and
|
||||
@scheme[readable<%>] that expand in the usual way; see
|
||||
@schememodname[wxme/xml], @schememodname[wxme/scheme], and
|
||||
@scheme[wxme/text]. Images from the ``world'' and ``image'' teachpacks
|
||||
are packaged as instances of @scheme[cache-image%] from the
|
||||
@schememodname[wxme/cache-image] library. Test-case boxes are packaged
|
||||
as instances of @scheme[test-case%] from the
|
||||
@schememodname[wxme/test-case] library.
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@subsection{Nested Editors}
|
||||
|
||||
@defmodule[wxme/editor]
|
||||
|
||||
@defclass[editor% object% ()]{
|
||||
|
||||
Instantiated for plain nested editors in a @tech{WXME} stream in text
|
||||
mode.
|
||||
|
||||
@defmethod[(get-content-port) input-port?]{
|
||||
|
||||
Returns a port (like the one from @scheme[wxme-port->port]) for the
|
||||
editor's content.}
|
||||
|
||||
}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@subsection{Images}
|
||||
|
||||
@defmodule[wxme/image]
|
||||
|
||||
@defclass[image% object% ()]{
|
||||
|
||||
Instantiated for images in a @tech{WXME} stream in text mode.
|
||||
|
||||
@defmethod[(get-filename) (or/c bytes? false/c)]{
|
||||
|
||||
Returns a filename as bytes, or @scheme[#f] if data is available
|
||||
instead.}
|
||||
|
||||
@defmethod[(get-data) (or/c bytes? false/c)]{
|
||||
|
||||
Returns bytes for a PNG, XBM,or XPM file for the image.}
|
||||
|
||||
@defmethod[(get-w) (or/c exact-nonnegative-integer? (one-of/c -1))]{
|
||||
|
||||
Returns the display width of the image, which may differ from the
|
||||
width of the actual image specified as data or by a filename; -1 means
|
||||
that the image data's width should be used.}
|
||||
|
||||
@defmethod[(get-h) (or/c exact-nonnegative-integer? (one-of/c -1))]{
|
||||
|
||||
Returns the display height of the image, which may differ from the
|
||||
height of the actual image specified as data or by a filename; -1
|
||||
means that the image data's height should be used.}
|
||||
|
||||
@defmethod[(get-dx) exact-integer?]{
|
||||
|
||||
Returns an offset into the actual image to be used
|
||||
as the left of the display image.}
|
||||
|
||||
@defmethod[(get-dy) exact-integer?]{
|
||||
|
||||
Returns an offset into the actual image to be used as the top of the
|
||||
display image.}
|
||||
|
||||
}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@section{DrScheme Comment Boxes}
|
||||
|
||||
@defmodule[wxme/comment]
|
||||
|
||||
@in[wxme/comment
|
||||
@defthing[reader (is-a?/c snip-reader<%>)]{
|
||||
|
||||
A text-mode reader for comment boxes.}]
|
||||
|
||||
|
||||
@defclass[comment-editor% editor% (readable<%>)]{
|
||||
|
||||
Instantiated for DrScheme comment boxes in a @tech{WXME} stream for
|
||||
text mode.
|
||||
|
||||
@defmethod[(get-data) false/c]{
|
||||
|
||||
No data is available.
|
||||
|
||||
}
|
||||
|
||||
@defmethod[(read-special [source any/c]
|
||||
[line (or/c nonnegative-exact-integer? false/c)]
|
||||
[column (or/c nonnegative-exact-integer? false/c)]
|
||||
[position (or/c nonnegative-exact-integer? false/c)])
|
||||
any/c]{
|
||||
|
||||
Generates a special comment using @scheme[make-special-comment]. The
|
||||
special comment contains the comment text.}
|
||||
|
||||
}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@section{DrScheme XML Boxes}
|
||||
|
||||
@defmodule[wxme/xml]
|
||||
|
||||
@in[wxme/xml
|
||||
@defthing[reader (is-a?/c snip-reader<%>)]{
|
||||
|
||||
A text-mode reader for XML boxes.}]
|
||||
|
||||
|
||||
@defclass[comment-editor% editor% (readable<%>)]{
|
||||
|
||||
Instantiated for DrScheme XML boxes in a @tech{WXME} stream for text
|
||||
mode.
|
||||
|
||||
@defmethod[(get-data) any/c]{
|
||||
|
||||
Returns @scheme[#t] if whitespace is elimited from the contained XML
|
||||
literal, @scheme[#f] otherwise.}
|
||||
|
||||
@defmethod[(read-special [source any/c]
|
||||
[line (or/c nonnegative-exact-integer? false/c)]
|
||||
[column (or/c nonnegative-exact-integer? false/c)]
|
||||
[position (or/c nonnegative-exact-integer? false/c)])
|
||||
any/c]{
|
||||
|
||||
Generates a @scheme[quasiquote] S-expression that enclosed the XML,
|
||||
with @scheme[unquote] and @scheme[unquote-splicing] escapes for nested
|
||||
Scheme boxes.}
|
||||
|
||||
}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@section{DrScheme Scheme Boxes}
|
||||
|
||||
@defmodule[wxme/scheme]
|
||||
|
||||
@in[wxme/scheme
|
||||
@defthing[reader (is-a?/c snip-reader<%>)]{
|
||||
|
||||
A text-mode reader for Scheme boxes.}]
|
||||
|
||||
|
||||
@defclass[comment-editor% editor% (readable<%>)]{
|
||||
|
||||
Instantiated for DrScheme Scheme boxes in a @tech{WXME} stream for text
|
||||
mode.
|
||||
|
||||
@defmethod[(get-data) any/c]{
|
||||
|
||||
Returns @scheme[#t] if the box corresponds to a splicing unquote,
|
||||
@scheme[#f] for a non-splicing unquote.}
|
||||
|
||||
@defmethod[(read-special [source any/c]
|
||||
[line (or/c nonnegative-exact-integer? false/c)]
|
||||
[column (or/c nonnegative-exact-integer? false/c)]
|
||||
[position (or/c nonnegative-exact-integer? false/c)])
|
||||
any/c]{
|
||||
|
||||
Generates an S-expression for the code in the box.}
|
||||
|
||||
}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@section{DrScheme Text Boxes}
|
||||
|
||||
@defmodule[wxme/scheme]
|
||||
|
||||
@in[wxme/scheme
|
||||
@defthing[reader (is-a?/c snip-reader<%>)]{
|
||||
|
||||
A text-mode reader for text boxes.}]
|
||||
|
||||
|
||||
@defclass[comment-editor% editor% (readable<%>)]{
|
||||
|
||||
Instantiated for DrScheme text boxes in a @tech{WXME} stream for text
|
||||
mode.
|
||||
|
||||
@defmethod[(get-data) false/c]{
|
||||
|
||||
No data is available.}
|
||||
|
||||
@defmethod[(read-special [source any/c]
|
||||
[line (or/c nonnegative-exact-integer? false/c)]
|
||||
[column (or/c nonnegative-exact-integer? false/c)]
|
||||
[position (or/c nonnegative-exact-integer? false/c)])
|
||||
any/c]{
|
||||
|
||||
Generates a string containing the text.}
|
||||
|
||||
}
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@section{DrScheme Fractions}
|
||||
|
||||
@defmodule[wxme/number]
|
||||
|
||||
@in[wxme/number
|
||||
@defthing[reader (is-a?/c snip-reader<%>)]{
|
||||
|
||||
A text-mode reader for DrScheme fractions that generates exact,
|
||||
rational numbers.}]
|
||||
|
||||
@; ----------------------------------------
|
||||
|
||||
@section{DrScheme Teachpack Images}
|
||||
|
||||
@defmodule[wxme/cache-image]
|
||||
|
||||
@in[wxme/cache-image
|
||||
@defthing[reader (is-a?/c snip-reader<%>)]{
|
||||
|
||||
A text-mode reader for images in a WXME stream generated by the
|
||||
``image'' and ``world'' teachpacks---or, more generally, by
|
||||
@schememodname[mrlib/cache-image-snip].}]
|
||||
|
||||
|
||||
@defclass[cache-image% object% ()]{
|
||||
|
||||
Instantiated for DrScheme teachpack boxes in a @tech{WXME} stream for
|
||||
text mode.
|
||||
|
||||
@defmethod[(get-argb) (vectorof byte?)]{
|
||||
|
||||
Returns a vector of bytes representing the content of the image.}
|
||||
|
||||
@defmethod[(get-width) exact-nonnegative-integer?]{
|
||||
|
||||
Returns the width of the image.}
|
||||
|
||||
@defmethod[(get-height) exact-nonnegative-integer?]{
|
||||
|
||||
Returns the height of the image.}
|
||||
|
||||
@defmethod[(get-pin-x) exact-integer?]{
|
||||
|
||||
Returns an offset across into the image for the pinhole.}
|
||||
|
||||
@defmethod[(get-pin-y) exact-integer?]{
|
||||
|
||||
Returns an offset down into the image for the pinhole.}
|
||||
|
||||
}
|
||||
|
||||
@section{DrScheme Test-Case Boxes}
|
||||
|
||||
@defmodule[wxme/test-case]
|
||||
|
||||
@in[wxme/test-case
|
||||
@defthing[reader (is-a?/c snip-reader<%>)]{
|
||||
|
||||
A text-mode reader for DrScheme test-case boxes in a WXME stream. It
|
||||
generates instances of @scheme[test-case%].}]
|
||||
|
||||
@defclass[test-case% object% ()]{
|
||||
|
||||
Instantiated for old-style DrScheme test-case boxes in a @tech{WXME}
|
||||
stream for text mode.
|
||||
|
||||
@defmethod[(get-comment) (or/c false/c input-port?)]{
|
||||
|
||||
Returns a port for the comment field, if any.}
|
||||
|
||||
@defmethod[(get-test) input-port?]{
|
||||
|
||||
Returns a port for the ``test'' field.}
|
||||
|
||||
@defmethod[(get-expected) input-port?]{
|
||||
|
||||
Returns a port for the ``expected'' field.}
|
||||
|
||||
@defmethod[(get-should-raise) (or/c false/c input-port?)]{
|
||||
|
||||
Returns a port for the ``should raise'' field, if any.}
|
||||
|
||||
@defmethod[(get-error-message) (or/c false/c input-port?)]{
|
||||
|
||||
Returns a port for the ``error msg'' field, if any.}
|
||||
|
||||
@defmethod[(get-enabled?) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if the test is enabled.}
|
||||
|
||||
@defmethod[(get-collapsed?) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if the test is collapsed.}
|
||||
|
||||
@defmethod[(get-error-box?) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if the test is for an exception.}
|
||||
|
||||
}
|
|
@ -734,9 +734,9 @@ The resulting procedure should accept the same arguments as
|
|||
arguments are provided. The procedure is given the port whose stream
|
||||
contained @litchar{#reader}, and it should produce a datum result. If
|
||||
the result is a syntax object in @scheme[read] mode, then it is
|
||||
converted to a datum using @scheme[syntax-object->datum]; if the
|
||||
converted to a datum using @scheme[syntax->datum]; if the
|
||||
result is not a syntax object in @scheme[read-syntax] mode, then it is
|
||||
converted to one using @scheme[datum->syntax-object]. See also
|
||||
converted to one using @scheme[datum->syntax]. See also
|
||||
@secref["reader-procs"] for information on the procedure's results.
|
||||
|
||||
If the @scheme[read-accept-reader] @tech{parameter} is set to
|
||||
|
|
4
collects/wxme/main.ss
Normal file
4
collects/wxme/main.ss
Normal file
|
@ -0,0 +1,4 @@
|
|||
#lang scheme/base
|
||||
|
||||
(require "wxme.ss")
|
||||
(provide (all-from-out "wxme.ss"))
|
|
@ -529,6 +529,8 @@
|
|||
|
||||
(super-new)))
|
||||
|
||||
(define stream<%> (class->interface stream%))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(define lib-mapping (make-hash-table 'equal))
|
||||
|
@ -715,5 +717,6 @@
|
|||
broken-wxme-big-endian?
|
||||
snip-reader<%>
|
||||
readable<%>
|
||||
stream<%>
|
||||
wxme-read
|
||||
wxme-read-syntax))
|
||||
|
|
Loading…
Reference in New Issue
Block a user