Module terminal.scroll

Terminal scroll module.

Provides utilities to handle scroll-regions and scrolling in terminals.

Functions

down ([n=1]) Scrolls down by a specified number of lines and writes the sequence to the terminal.
reset () Applies the default scroll reset sequence by writing it to the terminal.
set (start_row, end_row) Sets the scroll region and writes the ANSI sequence to the terminal.
up ([n=1]) Scrolls up by a specified number of lines and writes the sequence to the terminal.
vertical (n) Scrolls vertically by a specified number of lines and writes the sequence to the terminal.

Sequences

down_seq ([n=1]) Creates an ANSI sequence to scroll down by a specified number of lines.
reset_seq () Function to return the default scroll reset sequence
set_seq (start_row, end_row) Creates an ANSI sequence to set the scroll region without writing to the terminal.
up_seq ([n=1]) Creates an ANSI sequence to scroll up by a specified number of lines.
vertical_seq (n) Creates an ANSI sequence to scroll vertically by a specified number of lines.

Stack based functions

apply () Applies the current scroll region by writing it to the terminal.
apply_seq () Retrieves the current scroll region sequence from the top of the stack.
pop (n) Pops the specified number of scroll regions from the stack and applies the new top by writing to the terminal.
pop_seq (n) Pops the specified number of scroll regions from the stack without applying it.
push (top, bottom) Pushes a new scroll region onto the stack and applies it by writing to the terminal.
push_seq (top, bottom) Pushes a new scroll region onto the stack without applying it.


Functions

down ([n=1])
Scrolls down by a specified number of lines and writes the sequence to the terminal.

Parameters:

  • n number The number of lines to scroll down. (default 1)

Returns:

    true Always returns true after scrolling.
reset ()
Applies the default scroll reset sequence by writing it to the terminal.

Returns:

    true Always returns true after applying.
set (start_row, end_row)
Sets the scroll region and writes the ANSI sequence to the terminal. Negative indices are supported, counting from the bottom of the screen. For example, -1 refers to the last row, -2 refers to the second-to-last row, etc.

Parameters:

  • start_row number The first row of the scroll region (can be negative).
  • end_row number The last row of the scroll region (can be negative).

Returns:

    true Always returns true after setting the scroll region.
up ([n=1])
Scrolls up by a specified number of lines and writes the sequence to the terminal.

Parameters:

  • n number The number of lines to scroll up. (default 1)

Returns:

    true Always returns true after scrolling.
vertical (n)
Scrolls vertically by a specified number of lines and writes the sequence to the terminal.

Parameters:

  • n number The number of lines to scroll (positive for down, negative for up).

Returns:

    true Always returns true after scrolling.

Sequences

down_seq ([n=1])
Creates an ANSI sequence to scroll down by a specified number of lines.

Parameters:

  • n number The number of lines to scroll down. (default 1)

Returns:

    string The ANSI sequence for scrolling down.
reset_seq ()
Function to return the default scroll reset sequence

Returns:

    string The ANSI sequence for resetting the scroll region.
set_seq (start_row, end_row)
Creates an ANSI sequence to set the scroll region without writing to the terminal. Negative indices are supported, counting from the bottom of the screen. For example, -1 refers to the last row, -2 refers to the second-to-last row, etc.

Parameters:

  • start_row number The first row of the scroll region. Negative values are resolved from the bottom of the screen, such that -1 is the last row.
  • end_row number The last row of the scroll region. Negative values are resolved from the bottom of the screen, such that -1 is the last row.

Returns:

    string The ANSI sequence for setting the scroll region.
up_seq ([n=1])
Creates an ANSI sequence to scroll up by a specified number of lines.

Parameters:

  • n number The number of lines to scroll up. (default 1)

Returns:

    string The ANSI sequence for scrolling up.
vertical_seq (n)
Creates an ANSI sequence to scroll vertically by a specified number of lines. Positive values scroll down, negative values scroll up.

Parameters:

  • n number The number of lines to scroll (positive for down, negative for up).

Returns:

    string The ANSI sequence for vertical scrolling.

Stack based functions

These functions provide direct access to the cursor position stack.
apply ()
Applies the current scroll region by writing it to the terminal.

Returns:

    true Always returns true after applying.
apply_seq ()
Retrieves the current scroll region sequence from the top of the stack.

Returns:

    string The ANSI sequence representing the current scroll region.
pop (n)
Pops the specified number of scroll regions from the stack and applies the new top by writing to the terminal.

Parameters:

  • n number The number of scroll regions to pop. Defaults to 1.

Returns:

    true Always returns true after applying.
pop_seq (n)
Pops the specified number of scroll regions from the stack without applying it.

Parameters:

  • n number The number of scroll regions to pop. Defaults to 1.

Returns:

    string The ANSI sequence representing the new top of the stack.
push (top, bottom)
Pushes a new scroll region onto the stack and applies it by writing to the terminal.

Parameters:

  • top number The top line number of the scroll region.
  • bottom number The bottom line number of the scroll region.

Returns:

    true Always returns true after applying.
push_seq (top, bottom)
Pushes a new scroll region onto the stack without applying it.

Parameters:

  • top number The top line number of the scroll region.
  • bottom number The bottom line number of the scroll region.

Returns:

    string The ANSI sequence representing the pushed scroll region.
generated by LDoc 1.5.0