Made it possible not to give a filename

This commit is contained in:
2026-08-20 23:21:43 +02:00
parent f780c7f5b4
commit 0d3b55f252
4 changed files with 37 additions and 15 deletions
+23 -9
View File
@@ -2,6 +2,7 @@
@(require (for-label racket/base
racket/class
racket/contract
"../main.rkt"))
@title{rackedit}
@@ -11,12 +12,12 @@
@tt{rackedit} provides a small editor window based on Racket's GUI framework.
It is intended for situations where a program, DrRacket interaction, or command
line session needs to open a file in a simple Racket editor without starting a
separate full editor application.
line session needs a simple Racket editor, optionally for a specific file, without
starting a separate full editor application.
@section{Opening an editor}
@defproc[(rkdt [filename path-string?]
@defproc[(rkdt [filename (or/c path-string? #f) #f]
[#:wait? wait? boolean? #f]
[#:width width exact-positive-integer? 900]
[#:height height exact-positive-integer? 650]
@@ -26,11 +27,14 @@ separate full editor application.
(λ (call-time frame) #t)])
void?]{
@bold{Purpose.} Opens an editor window for @racket[filename].
@bold{Purpose.} Opens an editor window. When @racket[filename] is a path or
string, that file is opened. When @racket[filename] is @racket[#f], which is the
default, an empty editor is opened.
@bold{Preconditions.} @racket[filename] identifies the file to open.
@racket[frame-cb] must accept two arguments: a lifecycle symbol and the editor
frame. The geometry arguments specify valid dimensions and screen coordinates.
@bold{Preconditions.} When supplied, @racket[filename] identifies the file to
open. @racket[frame-cb] must accept two arguments: a lifecycle symbol and the
editor frame. The geometry arguments specify valid dimensions and screen
coordinates.
@bold{Postconditions.} An editor frame has been created and shown. When
@racket[wait?] is @racket[#f], @racket[rkdt] returns after the frame has been
@@ -40,7 +44,11 @@ shown and the @racket['after-show] callback has run. When @racket[wait?] is
@bold{Result.} The procedure returns @racket[(void)]. The editor frame itself is
made available to @racket[frame-cb] during its lifecycle callbacks.
@bold{Internal workings.} Each open editor receives an internal number. That
@bold{Internal workings.} A non-false @racket[filename] is converted to a
string before it is supplied to the Framework editor frame. A false filename is
passed through as @racket[#f], causing the frame to start without a file.
Each open editor receives an internal number. That
number is appended to the window title and is used to distinguish stored window
geometry. Numbers belonging to closed editors are reused. On close, the current
position and size are stored for that internal number and the current screen
@@ -85,11 +93,17 @@ between @racket['after-show] and @racket['on-close].
@section{Examples}
The simplest use opens a file and returns immediately:
The simplest use opens an empty editor and returns immediately:
@racketblock[
(require rackedit)
(rkdt)
]
Supply a filename to open a file:
@racketblock[
(rkdt "notes.rkt")
]