# Module terminal

This module contains a few procedures to control the terminal (also called console). On UNIX, the implementation simply uses ANSI escape sequences and does not depend on any other module, on Windows it uses the Windows API. Changing the style is permanent even after program termination! Use the code `system.addQuitProc(resetAttributes)` to restore the defaults.

# Imports

macros, windows, os

# Types

    TStyle* = enum
      styleBright = 1,            ## bright text
      styleDim,                   ## dim text
      styleUnknown,               ## unknown
      styleUnderscore = 4,        ## underscored text
      styleBlink,                 ## blinking/bold text
      styleReverse = 7,           ## unknown
      styleHidden                 ## hidden text

  different styles for text output

    TForegroundColor* = enum
      fgBlack = 30,               ## black
      fgRed,                      ## red
      fgGreen,                    ## green
      fgYellow,                   ## yellow
      fgBlue,                     ## blue
      fgMagenta,                  ## magenta
      fgCyan,                     ## cyan
      fgWhite                     ## white

  terminal's foreground colors

    TBackgroundColor* = enum
      bgBlack = 40,               ## black
      bgRed,                      ## red
      bgGreen,                    ## green
      bgYellow,                   ## yellow
      bgBlue,                     ## blue
      bgMagenta,                  ## magenta
      bgCyan,                     ## cyan
      bgWhite                     ## white

  terminal's background colors

# Procs

    proc setCursorPos*(x, y: int)

  sets the terminal's cursor to the (x,y) position. (0,0) is the upper left of the screen.

    proc setCursorXPos*(x: int)

  sets the terminal's cursor to the x position. The y position is not changed.

    proc setCursorYPos*(y: int)

  sets the terminal's cursor to the y position. The x position is not changed. Warning: This is not supported on UNIX!

    proc CursorUp*(count = 1)

  Moves the cursor up by count rows.

    proc CursorDown*(count = 1)

  Moves the cursor down by count rows.

    proc CursorForward*(count = 1)

  Moves the cursor forward by count columns.

    proc CursorBackward*(count = 1)

  Moves the cursor backward by count columns.

    proc EraseLine*()

  Erases the entire current line.

    proc EraseScreen*()

  Erases the screen with the background colour and moves the cursor to home.

    proc ResetAttributes*() {.noconv.}

  resets all attributes; it is advisable to register this as a quit proc with `system.addQuitProc(resetAttributes)`.

    proc setStyle*(style: set[TStyle])

  sets the terminal style

    proc WriteStyled*(txt: string; style: set[TStyle] = {styleBright})

  writes the text txt in a given style.

    proc setForegroundColor*(fg: TForegroundColor; bright = false)

  sets the terminal's foreground color

    proc setBackgroundColor*(bg: TBackgroundColor; bright = false)

  sets the terminal's background color

    proc isatty*(f: TFile): bool

  returns true if f is associated with a terminal device.

# Macros

    macro styledEcho*(m: varargs[expr]): stmt

  to be documented.

Generated: 2012-09-23 21:47:54 UTC