On this page:
in-terminal
on-terminal-run
terminal<%>
is-closed?
close
can-close?
can-close-evt
get-button-panel

19 Terminal Window

 (require mrlib/terminal) package: gui-lib
The mrlib/terminal library provides a simple GUI wrapper around functions that normally would run in command-line scripts.

procedure

(in-terminal doit 
  [#:container container 
  #:cleanup-thunk cleanup-thunk 
  #:title title 
  #:abort-label abort-label 
  #:aborted-message aborted-message 
  #:canvas-min-width canvas-min-width 
  #:canvas-min-height canvas-min-height 
  #:close-button? close-button? 
  #:close-label close-label 
  #:close-callback close-callback] 
  #:close-when-hidden? boolean?) 
  (is-a?/c terminal<%>)
  doit : 
(-> eventspace?
    (or/c (is-a?/c top-level-window<%>) #f)
    void?)
  container : (or/c #f (is-a?/c area-container<%>)) = #f
  cleanup-thunk : (-> void?) = void
  title : string? = "mrlib/terminal"
  abort-label : string?
   = (string-constant plt-installer-abort-installation)
  aborted-message : string?
   = (string-constant plt-installer-aborted)
  canvas-min-width : (or/c #f (integer-in 0 10000)) = #f
  canvas-min-height : (or/c #f (integer-in 0 10000)) = #f
  close-button? : boolean? = #t
  close-label : string? = (string-constant close)
  close-callback : (-> any) = void
  boolean? : #t
Creates a GUI, sets up the current error and output ports to print into the GUI’s content, and calls doit in a separate thread under a separate custodian. The exit-handler is set to a function that shuts down the new custodian.

The GUI is created in a new frame%, unless container is not #f, in which case the GUI is created as a new panel inside container. If a frame is created, it is provided as the second argument to doit, otherwise the second argument to doit is #f. If a frame is created, its title is title.

The result of in-terminal is a terminal<%> object that reports on the state of the terminal; this result is produced just after doit is started.

The cleanup-thunk is called on a queued callback to the eventspace active when in-terminal is invoked after doit completes.

In addition to the I/O generated by doit, the generated GUI contains two buttons: the abort button (with label abort-label) and the close button (with label close-label). The close button is present only if close-button? is #t.

When the abort button is pushed, the newly created custodian is shut down and the aborted-message is printed in the dialog. The close button becomes active when doit returns or when the thread running it is killed (via a custodian shut down, typically).

If container is #f, then the close button closes the frame; otherwise, the close button causes the container created for the terminal’s GUI to be removed from its parent.

The canvas-min-width and canvas-min-height are passed to the min-width and min-height initialization arguments of the editor-canvas% object that holds the output generated by doit.

The value of on-terminal-run is invoked after doit returns, but not if it is aborted or an exception is raised.

The close-callback function is called after the terminal frame is closed or container is removed.

When the container argument is not #f, then hiding removing the window from it’s frame will abort the computation in the terminal, unless close-when-hidden? is #f.

Changed in version 1.4 of package gui-lib: Added the #:close-callback argument.

parameter

(on-terminal-run)  (-> void?)

(on-terminal-run run)  void?
  run : (-> void?)
Invoked by in-terminal.

interface

terminal<%> : interface?

The interface of a terminal status and control object produced by in-terminal.

method

(send a-terminal is-closed?)  boolean?

Returns #t if the terminal GUI has been closed, #f otherwise.

method

(send a-terminal close)  void?

Closes the terminal GUI. Call this method only if can-close? returns #t.

method

(send a-terminal can-close?)  boolean?

Reports whether the terminal GUI can be closed, because the terminal process is complete (or, equivalently, whether the close button is enabled).

method

(send a-terminal can-close-evt)  evt?

Returns a synchronizable event that becomes ready for synchronization when the terminal GUI can be closed.

method

(send a-terminal get-button-panel)

  (is-a?/c horizontal-panel%)
Returns a panel that contains the abort and close buttons.