/usr/share/doc/lua-term/README.md is in lua-term 0.07-0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | Overview
--------
lua-term is a Lua module for manipulating a terminal.
Installation
------------
lua-term is available on Luarocks.
Usage
-----
```lua
local term = require 'term'
local colors = term.colors -- or require 'term.colors'
print(term.isatty(io.stdout)) -- true if standard output goes to the terminal
print(colors.red 'hello')
print(colors.red .. 'hello' .. colors.reset)
print(colors.red, 'hello', colors.reset)
-- The following functions take an optional IO handle (like io.stdout);
-- io.stdout is the default if you don't specify one
term.clear() -- clears the screen
term.cleareol() -- clears from the cursor to the end of the line
--term.cursor.goto(1, 1) -- It will fail in Lua >= 5.2 because goto is a reserved word.
term.cursor['goto'](1, 1) -- This will work on Lua >= 5.2, please use jump instead
term.cursor.jump(1, 1) -- jump is just an alias for goto
term.cursor.jump(io.stdout, 1, 1)
term.cursor.goup(1)
term.cursor.godown(1)
term.cursor.goright(1)
term.cursor.goleft(1)
term.cursor.save() -- save position
term.cursor.restore() -- restore position
```
`term` Functions
--------------
Some functions in lua-term take an optional file handle argument; if this is
not provided, `io.stdout` is used.
### `term.clear([opt_file])`
Clear the terminal's contents.
### `term.cleareol([opt_file])`
Clear from the current cursor position to the end of the current line.
### `term.isatty(file)`
Returns `true` if `file` is a TTY; `false` otherwise.
*NOTE*: This function has been deprecated in favor of luaposix's implementation.
If you would like this functionality in the future, please use luaposix.
`term.colors` Values
------------------
The following values are available in `term.colors`:
### Terminal Attributes
* reset
* clear (a synonym for reset)
* default (a synonym for reset)
* bright
* dim
* underscore
* blink
* reverse
* hidden
### Foreground Colors
* black
* red
* green
* yellow
* blue
* magenta
* cyan
* white
### Background Colors
* onblack
* onred
* ongreen
* onyellow
* onblue
* onmagenta
* oncyan
* onwhite
Every value in `term.colors` may be used in several ways:
### As a Function
```lua
print(colors.red 'hello')
```
### As a String
```lua
print(colors.red .. 'hello' .. colors.reset)
print(colors.red, 'hello', colors.reset)
```
`term.cursor` Functions
---------------------
### `term.cursor.goto([opt_file], x, y)`
Place the cursor at (`x`, `y`).
### `term.cursor.jump([opt_file], x, y)`
An alias for `term.cursor.goto`.
### `term.cursor.goup([opt_file], nlines)`
Moves the cursor up `nlines` lines.
### `term.cursor.godown([opt_file], nlines)`
Moves the cursor down `nlines` lines.
### `term.cursor.goright([opt_file], ncols)`
Moves the cursor right `ncols` columns.
### `term.cursor.goleft([opt_file], ncols)`
Moves the cursor left `ncols` columns.
### `term.cursor.save([opt_file])`
Saves the cursor position.
### `term.cursor.restore([opt_file])`
Restores the cursor position.
Alternatives
------------
If you are looking to simply provide coloration to a terminal application and would
like to use a more "tag-like" API (ex. `colors '%{red}hello%{reset}'`), there is a Lua rock
named ansicolors: https://github.com/kikito/ansicolors.lua
|