Module terminal.draw
Module for drawing lines and boxes.
Provides functions to create lines and boxes on a terminal screen.
box_fmt |
Table with pre-defined box formats. |
-
box (height, width, format, clear_flag[, title=""[, lastcolumn=false]])
-
Draws a box and writes it to the terminal.
Parameters:
- height
number
the height of the box in rows
- width
number
the width of the box in columns
- format
table
the format for the box, see
boxs
for details.
- clear_flag
bool
whether to clear the box contents
- title
string
the title to draw
(default "")
- lastcolumn
boolean
whether to draw the last column of the terminal
(default false)
Returns:
true
-
box_fmt.copy (default)
-
Copy a box format.
Parameters:
- default
table
the default format to copy
Returns:
table
a copy of the default format provided
Usage:
local fmt = t.box_fmt.copy(t.box_fmt.single)
fmt.pre = fmt.pre .. " "
fmt.post = " " .. fmt.post
-
box_fmt
-
Table with pre-defined box formats.
Fields:
- single
Single line box format
- double
Double line box format
- copy
Function to copy a box format, see box_fmt.copy for details
-
box_seq (height, width[, format[, clear_flag=" "[, title=""[, lastcolumn=""]]]])
-
Creates a sequence to draw a box, without writing it to the terminal.
The box is drawn starting from the top-left corner at the current cursor position,
after drawing the cursor will be in the same position.
Parameters:
- height
number
the height of the box in rows
- width
number
the width of the box in columns
- format the format for the box (default is single line), with keys:
- h
string
the horizontal line character
(default " ")
- v
string
the vertical line character
(default "")
- tl
string
the top left corner character
(default "")
- tr
string
the top right corner character
(default "")
- bl
string
the bottom left corner character
(default "")
- br
string
the bottom right corner character
(default "")
- pre
string
the title-prefix character(s)
(default "")
- post
string
the left-postfix character(s)
(default "")
- clear_flag
bool
whether to clear the box contents
(default false)
- title
string
the title to draw
(default "")
- lastcolumn
boolean
whether to draw the last column of the terminal
(default false)
Returns:
string
ansi sequence to write to the terminal