Module termio

Provides convenience wrappers over VT100 functionality.

This module supports use of handlers to allow functionality across a wide variety of terminal emulators.

Functions

getCursor () Get the current cursor position.
getTermSize () Get the size of the terminal.
cursorVisible (vis) Set whether the cursor is visible.
readKey () Read a keypress from standard input.

Tables

keyflags Flags returned by readKey.


Functions

getCursor ()
Get the current cursor position. If this cannot be determined, the result will be 1, 1.

Returns:

  1. number Cursor X position
  2. number Cursor Y position
getTermSize ()
Get the size of the terminal. If this cannot be determined, the result will be 1, 1.

Returns:

  1. number Terminal width
  2. number Terminal height
cursorVisible (vis)
Set whether the cursor is visible.

Parameters:

  • vis boolean Whether the cursor is visible
readKey ()
Read a keypress from standard input. This function will read a single keypress (NOT a single character) and return a symbolic name for it. Characters within the ASCII range are left alone. Escape sequences representing e.g. arrow keys are recognized and returned as left, right, up, or down. ctrl-[Key] sequences are also supported, and returned with the ctrl flag set to true.

Returns:

  1. string The character that was read
  2. Additional flags

Tables

keyflags
Flags returned by readKey.

Fields:

  • ctrl boolean Whether the Control key was pressed
  • alt boolean Whether the Alt (Option) key was pressed
generated by LDoc 1.4.6 Last updated 2023-03-04 11:42:14