Module terminal.progress

A module for progress updating.

Functions

spinner (opts) Create a progress spinner.
ticker (text[, width=40[, text_done=""]]) Create a text/led ticker like sprite-sequence for use with a progress spinner.

Fields

sprites table with predefined sprites for progress spinners.


Functions

spinner (opts)
Create a progress spinner. The returned spinner function can be called as often as needed to update the spinner. It will only update after the stepsize has passed since the last update. So try to call it at least every stepsize seconds, or more often. If row and col are given then terminal memory is used to (re)store the cursor position. If they are not given then the spinner will be printed at the current cursor position, and the cursor will return to the same position after each update.

Parameters:

  • opts a table of options;
    • sprites table a table of strings to display, one at a time, overwriting the previous one. Index 0 is the "done" message. See sprites for a table of predefined sprites.
    • stepsize number the time in seconds between each step (before printing the next string from the sequence) (default 0.2)
    • textattr textattr a table of text attributes to apply to the text (using the stack), or nil to not change the attributes.
    • done_textattr textattr a table of text attributes to apply to the "done" message, or nil to not change the attributes. (optional)
    • done_sprite string the sprite to display when the spinner is done. This overrides sprites[0] if provided. (optional)
    • row number the row to print the spinner (required if col is provided) (optional)
    • col number the column to print the spinner (required if row is provided) (optional)

Returns:

    function a stepper function that should be called in a loop to update the spinner. Signature: nil = stepper(done) where done is a boolean indicating that the spinner should print the "done" message.
ticker (text[, width=40[, text_done=""]])
Create a text/led ticker like sprite-sequence for use with a progress spinner.

Parameters:

  • text string the text to display
  • width number the width of the ticker, in characters (default 40)
  • text_done string the text to display when the spinner is done (default "")

Returns:

    table a table of sprites to use with a spinner

Fields

sprites

table with predefined sprites for progress spinners. The sprites are tables of strings, where each string is a frame in the spinner animation. The frame at index 0 is optional and is the "done" message, the rest are the animation frames.

Available pre-defined spinners are:

  • bar_vertical - a vertical bar that grows from the bottom to the top
  • bar_horizontal - a horizontal bar that grows from left to right
  • square_rotate - a square that rotates clockwise
  • moon - a moon that waxes and wanes
  • dot_expanding - a dot that expands and contracts
  • dot_vertical - a dot that moves up and down
  • dot1_snake - a dot that moves in a snake-like pattern
  • dot2_snake - 2 dots that move in a snake-like pattern
  • dot3_snake - 3 dots that move in a snake-like pattern
  • dot4_snake - 4 dots that move in a snake-like pattern
  • block_pulsing - a block that pulses in transparency
  • bar_rotating - a bar that rotates clockwise
  • spinner - a spinner that rotates clockwise
  • dot_horizontal - 3 dots growing from left to right
generated by LDoc 1.5.0 Last updated 2025-03-03 09:04:53