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:
- number Cursor X position
- number Cursor Y position
- getTermSize ()
-
Get the size of the terminal.
If this cannot be determined, the result will be
1, 1
.Returns:
- number Terminal width
- 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
, ordown
.ctrl-[Key]
sequences are also supported, and returned with thectrl
flag set totrue
.Returns:
- string The character that was read
- 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