# Screen

The unit at io/screen.fs is a very thin layer on top of [gr/pix]. It defines the
"screen" struct as a pixbuf in which pixels are [gr/color]. It supplies the
"screen" global value, which represents the main screen we want to draw to in a
system with graphical capabilities.

## Mode management

Some systems have distinct "graphics" and "console" mode. That is, the console
is shown in a mode that precludes any graphical capabilities, but they do have
that capability if they switch to another mode. One such example is
[drv/pc/vesa].

This is fine, but this means that executing any word that involves showing
graphics requires us to switch to that mode, and more importantly, switch back
to console mode afterwards.

This unit has a generic API to do so. It revolves around the ( -- ) words
"graphicmode" and "consolemode", which by default alias to "noop". The
applicative layer calls upon those words before and after doing graphical stuff.

The system takes care of realiasing, if needed, those words. It's also a good
idea to add "consolemode" to quit hooks so that errors during graphics mode
return to the console.

## API

### Fields

encoding  Color encoding of the screen struct

### Values

screen    Main screen of the system

### Words

screen# ( -- )
  Aborts with error if "screen" is zero.

newscreen ( width height encoding -- screen )
  Create a new screen struct with the supplied initial values.

graphicsmode ( -- )
  Enables the graphics mode. "screen" can now be used.

consolemode ( -- )
  Disables the graphics mode, showing the console. "screen" now can't be used.

graphicsexec ( w -- )
  Execute "w" inside a graphicsmode/consolemode pair.

graphicsrun< ( -- )
  Read the rest of the input stream line, then interpret that code in a
  graphicsmode/consolemode pair.
