ULOS Manual Pages - termio(3) | Back
NAME
  termio - terminal-specific abstraction
DESCRIPTION
  termio is a library created out of necessity.  It is portable to many systems by the creation of a corresponding terminal-specific handler.
  Note that termio is only intended to simplify a few specific actions.  These actions are getting terminal size and reading keyboard input.  termio does not support terminals except those that follow the VT100 specification.
FUNCTIONS
  setCursor(x:number, y:number)
    Set the cursor position to (x,y).  Equivalent to io.write("\27[Y;XH").  Included for the sake of completeness and ease-of-use.  If the input and output streams do not point to a TTY, this will do nothing.
  getCursor(): number, number
    Get the cursor position.  This is not as easy to do as setting the cursor, requiring some terminal-specific commands.  This, along with readKey, is the reason for the usage of terminal handlers.
    If the terminal is not recognized, or the input and output streams do not point to a TTY, then (1, 1) will be returned.
  getTermSize(): number, number
    Returns the dimensions of the terminal.  If the terminal is not recognized, or the input and output streams do not point to a TTY, then (1, 1) will be returned.
  readKey(): string, table
    Reads one keypress from the standard input.  The table contains two fields, ctrl and alt, both booleans, indicate whether the Control or Alt keys were pressed, respectively.  The string return is the key that was pressed.  Unless it is a key such as Return, Backspace, or Delete, it will be the character generated by the key press - so instead of "space", readKey would return " ".
TERMINAL HANDLERS
  Terminal handlers should be placed in lib/termio/TERM.lua, and must contain a library with the following functions:
    
    ttyIn(): boolean
      This function should return whether the input stream points to a TTY.
    ttyOut(): boolean
      This function should return whether the output stream points to a TTY.
    setRaw(raw:boolean)
      Set the terminal raw mode.  This must do the following:
        - Enable or disable line buffering on at least the terminal input
        - Enable or disable local echo
COPYRIGHT
  ULOS Core Libraries copyright (c) 2021 Ocawesome101 under the DSLv2.
REPORTING BUGS
  Bugs should be reported at https://github.com/ocawesome101/oc-ulos/issues.