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
+9 -3
View File
@@ -1,13 +1,19 @@
# rackedit
`rackedit` opens a simple Racket editor window for a file. It can be used from
DrRacket, from a Racket program, or from the Racket command line.
`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:
The package exports one procedure. With no filename, `rkdt` opens an empty editor:
```racket
(require rackedit)
(rkdt)
```
Pass a filename to open an existing file:
```racket
(rkdt "notes.rkt")
```
+1 -1
View File
@@ -1,7 +1,7 @@
#lang info
(define pkg-authors '(hnmdijkema))
(define version "0.1.5")
(define version "0.1.7")
(define license 'MIT) ;
(define collection "rackedit")
(define pkg-desc "rackedit exports the rkdt procedure, that can be used to open an editor window with a given file")
+4 -2
View File
@@ -97,7 +97,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (rkdt filename
(define (rkdt [filename #f]
#:wait? [wait? #f]
#:width [width 900]
#:height [height 650]
@@ -109,7 +109,9 @@
(closed (make-semaphore 0))
(frame (new (make-editor-frame% closed
(λ (num x y w h) (store-cfg num x y w h)))
[filename (format "~a" filename)]
[filename (if (eq? filename #f)
#f
(format "~a" filename))]
[editor% racket:text%]
[width 900]
[height 650]
+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")
]