Module terminal.draw

Module for drawing lines and boxes.

Provides functions to create lines and boxes on a terminal screen.

Functions

box (height, width, format, clear_flag[, title=""[, lastcolumn=false[, type="right"[, title_attr]]]]) Draws a box and writes it to the terminal.
box_fmt.copy (default) Copy a box format.

Tables

box_fmt Table with pre-defined box formats.

Sequences

box_seq (height, width[, format[, clear_flag=" "[, title=" "[, lastcolumn=""[, type=""[, title_attr=""]]]]]]) Creates a sequence to draw a box, without writing it to the terminal.


Functions

box (height, width, format, clear_flag[, title=""[, lastcolumn=false[, type="right"[, title_attr]]]])
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 box_seq 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)
  • type string the type of title-truncation to apply, either "left", "right", or "drop", see draw.line.title_fmt for details (default "right")
  • title_attr table table of attributes for the title, eg. { fg = "red", bg = "blue" } (optional)

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:

    -- create new format with spaces around the title
    local fmt = t.box_fmt.copy(t.box_fmt.single)
    fmt.pre = fmt.pre .. " "
    fmt.post = " " .. fmt.post

Tables

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

Sequences

box_seq (height, width[, format[, clear_flag=" "[, title=" "[, lastcolumn=""[, type=""[, title_attr=""]]]]]])
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. The left, right, top, bottom characters can be empty strings(eg. ""), to not draw them.

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:
    • t string the top horizontal line character (default " ")
    • b string the bottom horizontal line character (default " ")
    • l string the left vertical line character (default "")
    • r string the right 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)
  • type string the type of title-truncation to apply, either "left", "right", or "drop", see draw.line.title_fmt for details (default "right")
  • title_attr table table of attributes for the title, eg. { fg = "red", bg = "blue" } (optional)

Returns:

    Sequence The sequence to write to the terminal
generated by LDoc 1.5.0