Module terminal.draw.line

Module for drawing lines.

Provides functions to create lines on a terminal screen.

Functions

horizontal (n[, char="─"]) Draws a horizontal line and writes it to the terminal.
title (title, width[, char="─"[, pre=""[, post=""]]]) Draws a horizontal line with a title centered in it and writes it to the terminal.
vertical (n[, char="│"[, lastcolumn]]) Draws a vertical line and writes it to the terminal.

Sequences

horizontal_seq (n[, char="─"]) Creates a sequence to draw a horizontal line without writing it to the terminal.
title_seq (width[, title=""[, char="─"[, pre=""[, post=""]]]]) Creates a sequence to draw a horizontal line with a title centered in it without writing it to the terminal.
vertical_seq (n[, char="│"[, lastcolumn]]) Creates a sequence to draw a vertical line without writing it to the terminal.


Functions

horizontal (n[, char="─"])
Draws a horizontal line and writes it to the terminal. Line is drawn left to right. Returned sequence might be shorter than requested if the character is a multi-byte character and the number of columns is not a multiple of the character width.

Parameters:

  • n number number of columns to draw
  • char string the character to draw (default "─")

Returns:

    true
title (title, width[, char="─"[, pre=""[, post=""]]])
Draws a horizontal line with a title centered in it and writes it to the terminal. Line is drawn left to right. If the width is too small for the title, the title is truncated with "trailing "...". If less than 4 characters are available for the title, the title is omitted alltogether.

Parameters:

  • title string the title to draw
  • width number the total width of the line in columns
  • char string the line-character to use (default "─")
  • pre string the prefix for the title, eg. "┤ " (default "")
  • post string the postfix for the title, eg. " ├" (default "")

Returns:

    true
vertical (n[, char="│"[, lastcolumn]])
Draws a vertical line and writes it to the terminal. Line is drawn top to bottom. Cursor is left to the right of the last character (so not below it).

Parameters:

  • n number number of rows/lines to draw
  • char string the character to draw (default "│")
  • lastcolumn boolean whether to draw the last column of the terminal (optional)

Returns:

    true

Sequences

horizontal_seq (n[, char="─"])
Creates a sequence to draw a horizontal line without writing it to the terminal. Line is drawn left to right. Returned sequence might be shorter than requested if the character is a multi-byte character and the number of columns is not a multiple of the character width.

Parameters:

  • n number number of columns to draw
  • char string the character to draw (default "─")

Returns:

    string ansi sequence to write to the terminal
title_seq (width[, title=""[, char="─"[, pre=""[, post=""]]]])
Creates a sequence to draw a horizontal line with a title centered in it without writing it to the terminal. Line is drawn left to right. If the width is too small for the title, the title is truncated with "trailing "...". If less than 4 characters are available for the title, the title is omitted alltogether.

Parameters:

  • width number the total width of the line in columns
  • title string the title to draw (if empty or nil, only the line is drawn) (default "")
  • char string the line-character to use (default "─")
  • pre string the prefix for the title, eg. "┤ " (default "")
  • post string the postfix for the title, eg. " ├" (default "")

Returns:

    string ansi sequence to write to the terminal
vertical_seq (n[, char="│"[, lastcolumn]])
Creates a sequence to draw a vertical line without writing it to the terminal. Line is drawn top to bottom. Cursor is left to the right of the last character (so not below it).

Parameters:

  • n number number of rows/lines to draw
  • char string the character to draw (default "│")
  • lastcolumn boolean whether to draw the last column of the terminal (optional)

Returns:

    string ansi sequence to write to the terminal
generated by LDoc 1.5.0