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. |
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.
- start_row
number
The first row of the scroll region. Negative values are resolved
from the bottom of the screen, such that
- 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.