Term¶
The Term library is used to emulate a terminal.
Usage¶
Lua | |
---|---|
Functions¶
write¶
write( text )
Write a string to the terminal.
Parameters¶
text?
: string - Text to write on terminal
getPos¶
getPos()
Get the cursor position.
Coordinates start from 1, 1.
Returns¶
x
: integer - X coordinatey
: integer - Y coordinate
setPos¶
setPos( x, y )
Set the cursor position.
Coordinate start from 1,1.
Parameters¶
x
: number - X coordinatey
: number - Y coordinate
getSize¶
getSize()
Get the size of the terminal.
Returns¶
width
: integer - Width of the terminalheight
: integer - Height of the terminal
setSize¶
setSize( width, height )
Set the size of the terminal.
Parameters¶
width
: number - Width of the terminalheight
: number - Height of the terminal
getForeground¶
getForeground()
Get the decimal RGB value of the current text color.
Returns¶
rgb
: integer - Decimal RGB value
setForeground¶
setForeground( r, g, b )
or setForeground( rgb )
Set the text color.
Parameters¶
Values range from 0 to 255.
r
: integer - Red valueg
: integer - Green valueb
: integer - Blue value
OR¶
Value is hex color 0xRRGGBB (e.g. 0xff7700
).
rgb
: integer - Decimal value of RGB combined.
getBackground¶
getBackground()
Get the decimal RGB value of the current background color.
Returns¶
rgb
: integer - Decimal RGB value
setBackground¶
setBackground( r, g, b )
orsetBackground( rgb )
Set the background color.
Parameters¶
Values range from 0 to 255.
r
: integer - Red valueg
: integer - Green valueb
: integer - Blue value
OR¶
Value is hex color 0xRRGGBB (e.g. 0xff7700
).
rgb
: integer - Decimal value of RGB combined.
clear¶
clear()
Wipes the terminal and set the background to the current set.
clearLine¶
clearLine()
Like clear()
but only clears the horizontal line of the cursor position.
scroll¶
scroll( lines )
Scroll the terminal by n
lines.
Lines that go out of bounds are lost.
Parameters¶
lines
: integer - Lines to scroll
getBlink¶
getBlink()
Get the status of the cursor blink.
Returns¶
isBlinking
: boolean - Whether it is blinking.
setBlink¶
setBlink( enable )
Set the status of the cursor blink.
Parameters¶
enable
: boolean - Whether to blink.
blit¶
term.blit( text, foreground, background )
Write a text to the screen with foreground and background.
Text, foreground and background must be the same length.
Parameters¶
text
: string - Text to write on terminal.foreground
: table - Foreground of each character.background
: table - Background of each character.
Example¶
Lua | |
---|---|
toRealPos¶
toRealPos( x, y )
Convert from terminal coordinates to screen coordinates.
Parameters¶
x
: number - X coordinate of terminaly
: number - Y coordinate of terminal
Returns¶
x
: integer - X coordinate of screeny
: integer - Y coordinate of screen
fromRealPos¶
fromRealPos( x, y )
Convert from screen coordinates to terminal coordinates.
Use this function to convert mouse event positions relative to terminal
Parameters¶
x
: number - X coordinate of screeny
: number - Y coordinate of screen
Returns¶
x
: integer - X coordinate of terminaly
: integer - Y coordinate of terminal
Created: March 11, 2023