rackedit
1 Opening an editor
rkdt
2 Examples
3 Window behavior
9.2

rackedit🔗

Hans Dijkema <hans@dijkewijk.nl>

 (require rackedit)

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.

1 Opening an editor🔗

procedure

(rkdt filename    
  [#:wait? wait?    
  #:width width    
  #:height height    
  #:x x    
  #:y y    
  #:frame-cb frame-cb])  void?
  filename : path-string?
  wait? : boolean? = #f
  width : exact-positive-integer? = 900
  height : exact-positive-integer? = 650
  x : exact-integer? = 100
  y : exact-integer? = 100
  frame-cb : procedure? = (λ (frame) #t)
Opens an editor window for filename. The file name is passed to the Racket editor frame and the editor is shown immediately.

The #:width, #:height, #:x, and #:y arguments specify the initial geometry for a window for which no stored geometry is available. When an editor window is closed, rackedit stores its position and size. A later editor window with the same internal window number restores that geometry.

Stored geometry is associated with the current screen configuration. The screen configuration is derived from the number and dimensions of the displays visible to Racket. Consequently, changing the monitor configuration causes the default geometry, or geometry previously stored for that configuration, to be used.

If wait? is #f, the procedure returns after the editor has been shown. If wait? is #t, the current event handler waits until the editor window is closed before the procedure continues.

The frame-cb procedure receives the editor frame. With the default #:wait? value it is called after the frame has been shown and can be used to customize the frame, for example to change its title. When wait? is #t, the callback is called only after the window has been closed. Its return value is ignored.

Each open editor has an internal number. That number is shown in the window title and is also used to distinguish stored window geometries. Numbers of closed editor windows are reused.

2 Examples🔗

The simplest use opens a file and returns immediately:

(require rackedit)
 
(rkdt "notes.rkt")

Use #:wait? #t when execution should continue only after the editor is closed:

(rkdt "notes.rkt" #:wait? #t)

A frame callback can customize the editor frame:

(require racket/class
         rackedit)
 
(rkdt "notes.rkt"
      #:frame-cb
      (λ (frame)
        (send frame set-label "Notes")))

The initial window geometry can be supplied explicitly:

(rkdt "notes.rkt"
      #:width 1200
      #:height 800
      #:x 50
      #:y 50)

3 Window behavior🔗

The editor uses Racket’s standard editor menus, except that the standard Exit or Quit command is not added to the File menu. Closing an editor window closes only that window and releases its internal window number for reuse by a later editor window.