2.0 KiB
rackedit
rackedit opens a simple Racket editor window, optionally with a file. It can be
used from DrRacket, from a Racket program, or from the Racket command line.
The package exports one procedure. With no filename, rkdt opens an empty editor:
(require rackedit)
(rkdt)
Pass a filename to open an existing file:
(rkdt "notes.rkt")
By default rkdt shows the editor and returns immediately. Use #:wait? #t
when execution should continue only after the editor is closed:
(rkdt "notes.rkt" #:wait? #t)
The initial window geometry can be specified with #:width, #:height, #:x,
and #:y. Window positions and sizes are remembered per internal editor number
and per screen configuration.
The frame can be observed or customized with #:frame-cb. The callback receives
an event symbol and the editor frame. It is called at the lifecycle points
'before-show, 'after-show, 'wait-for-close, and 'on-close.
'wait-for-close is emitted only when #:wait? #t is used.
For example, the window title can be changed before the frame becomes visible:
(require racket/class
rackedit)
(rkdt "notes.rkt"
#:frame-cb
(λ (event frame)
(when (eq? event 'before-show)
(send frame set-label "Notes"))))
The standard File menu does not contain the Exit/Quit command, so closing one editor window does not imply exiting the application that opened it.
Headless environments
Requiring rackedit does not initialize Racket's GUI subsystem. This means that
(require rackedit) is safe in a headless Racket process, for example a server
process without access to an X11 or Wayland display.
The GUI implementation is loaded only when rkdt is actually called. Calling
rkdt still requires a usable graphical environment. Programs that also support
a terminal editor can therefore choose that editor before calling rkdt, without
merely requiring rackedit causing GTK initialization.
Full API documentation is included as Scribble documentation in
scrbl/rkdt.scrbl.