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.


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
generated by LDoc 1.5.0