Skip to main content

Module control

Module control 

Source
Expand description

Terminal control sequence generation — cursor movement, screen, titles, bells. Terminal control sequence generation — equivalent to Rich’s control.py.

Provides a unified Control type for composing terminal escape sequences: cursor movement, screen manipulation, window titles, and bells. Individual control codes can be combined and rendered as ANSI escape sequences.

§Quick Example

use rusty_rich::control::{Control, control_bell, control_home};

let bell = control_bell();
assert_eq!(bell.to_ansi(), "\x07");

let combined = Control::new(&["\x1b[H", "\x1b[2J"]);

Structs§

Control
A composable terminal control sequence.

Constants§

ALT_SCREEN_ENTER
Enter alternate screen buffer: \x1b[?1049h
ALT_SCREEN_EXIT
Exit alternate screen buffer: \x1b[?1049l
CARRIAGE_RETURN
Carriage return: \r
CLEAR_HOME
Clear entire screen and move cursor to home: \x1b[2J\x1b[H
CLEAR_SCREEN
Clear entire screen: \x1b[2J
CURSOR_HIDE
Hide cursor: \x1b[?25l
CURSOR_HOME
Move cursor to home: \x1b[H
CURSOR_SHOW
Show cursor: \x1b[?25h
CURSOR_UP
Move cursor up one row: \x1b[1A
ERASE_LINE
Erase the current line: \x1b[2K
NEWLINE
Newline: \n
OSC
Operating System Command (OSC) introducer: \x1b]
ST
String Terminator (ST) for OSC sequences: \x07

Functions§

control_bell
Ring the terminal bell.
control_clear
Clear the entire screen.
control_home
Move cursor to home position.
control_move_to
Move cursor to an absolute position.
control_show_cursor
Show or hide the cursor.
control_title
Set terminal window title.
escape_control_codes
Escape control characters in a string, replacing them with visible representations like \\a, \\b, etc.
strip_control_codes
Strip control characters (bell, backspace, vertical tab, form feed) from a string.