Text Window Input-Output Control

version 2 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next

  • Section: Basic Usage

    Text Window Input-Output Control provides two new global g-window variables:

        current text input window
        current text output window

    These variables define the windows into which the game's main output and input will be directed. Both are initially set to the main window (Flexible Windows's "main-window" object), so that if neither of the variables are changed during play, all I/O will occur in the main window (the standard behavior).

    The major use of this extension is expected to be for splitting input and output across two windows; that is, for creating a separate window for input. To do this, we can merely set the "current text input window" to window we wish to use for the command prompt. This can be either a text-buffer window or a text-grid window.

    It is important to note that the "current text output window" is distinct from the "current g-window" defined by Flexible Windows, and changing it will probably only rarely be necessary. Unlike the current g-window variable, the current text output window is intended to be used when the main output--that is, the game's main stream of output, occurring over multiple turns--needs to be redirected away from the (always open) main window to some other window. That window will then become, for nearly all intents and purposes, the "main window" (indeed, the Flexible Windows phrase "return to main screen" will direct output to the window that is defined as the current text output window). This is most likely to be useful when we want to use multiple "main windows" within a game, alternating a text-grid window, say, or a window with a different background color. See the "Terminal" example below for an example.

    There is thus no need to provide a Flexible Windows window-drawing rule for windows assigned as the current text output window or the current text input window; Inform's library takes care of requesting input and printing output. Note that when the current text input window or current text output window is closed, the main window will automatically take over.

    NOTE: The Inform library will not redirect input/output until the beginning of the next turn. If you want to begin printing to a new "current" window immediately, use the "set focus to <a text g-window>" phrase:

        Instead of turning on the computer:
            change the current text output window to the terminal-window;
            set focus to the current text output window;
            say "..."

    Most often, we will want to set a window to be the new current text output/input window at the time we open it. Two phrases are provided that take care of all of the bookkeeping fro us:

        open up <a text g-window> as the main text output window
        open up <a text g-window> as the main text input window

    If, for example we want to use the main window for output, but provide input in a separate window, we define the input window as usual (see the Flexible Windows documentation), and then we open it like so:

        When play begins:
            open up the input window as the main text input window.

    This is all that is required to split . These phrases will immediately shift I/O to the window, and they also ensure that the text that is printed to the window is also printed to the transcript.