gsh/input/terminal

The terminal module handles low-level stdout rendering and ANSI escape sequences.

When operating in TTY raw mode, standard carriage return and newline behaviors (\n) are unhandled by the terminal driver. This module provides an abstraction layer for rendering output, handling newline translations (\r\n), managing visibility, and controlling 2D hardware cursor movement via ANSI control codes.

Values

pub fn clear_below() -> Nil

Erases all stdout content from the active cursor position to the bottom of the viewport using ANSI \u{001b}[J.

pub fn clear_line() -> Nil

Clears the active terminal line and repositions the cursor to column 0.

Dispatches ANSI \u{001b}[2K (clear entire line) preceded by \r (carriage return).

pub fn clear_screen() -> Nil

Clears the full terminal viewport (\u{001b}[2J) and resets cursor placement to home coordinates (0, 0) (\u{001b}[H).

pub fn cursor_down(count: Int) -> Nil

Repositions the cursor downward by the specified row count using ANSI B sequences.

pub fn cursor_left(count: Int) -> Nil

Repositions the hardware cursor leftward by the specified column count using ANSI D sequences.

pub fn cursor_right(count: Int) -> Nil

Repositions the hardware cursor rightward by the specified column count using ANSI C sequences.

pub fn cursor_up(count: Int) -> Nil

Repositions the cursor upward by the specified row count using ANSI A sequences.

pub fn hide_cursor() -> Nil

Suppresses hardware cursor rendering (\u{001b}[?25l) to eliminate visual flickering during full-buffer editor redraws.

pub fn move_start() -> Nil

Snaps the cursor position to column 0 of the current line via a raw carriage return (\r).

pub fn print(text: String) -> Nil

Outputs string content to stdout while translating standard line feeds (\n) into raw-mode carriage return/line feed pairs (\r\n) to prevent staircasing.

pub fn println(text: String) -> Nil

Outputs string content to stdout with \r\n line-end translation and appends a trailing \r\n.

pub fn show_cursor() -> Nil

Restores hardware cursor rendering (\u{001b}[?25h).

Search Document