# Screen

The unit at io/screen.fs is a very thin layer on top of [gr/pix]. It provides
the "screen" value, which represents the main screen we want to draw to in a
system with graphical capabilities. It also provides the "encoding" value which
is the color [gr/color] encoding of pixels on that screen.

## 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

### Values

screen    Main screen of the system
encoding  Color encoding of the screen

### Words

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

screen$ ( width height encoding -- )
  Initialize the screen with a pixbuf of widthxheight pixels of the specified
  color encoding.

>screencolor ( r8 g8 b8 -- n )
  Alias to the appropriate "color converter" word for the screen color encoding.
  See [gr/color].

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.
