Function terminal_selection_text

Source
pub fn terminal_selection_text(
    state: &TerminalState,
    selection: TerminalSelection,
) -> String
Expand description

Extracts selected terminal text in visual-line order.

Normal-screen visual lines are scrollback followed by the visible screen; alternate-screen visual lines contain no scrollback. Selection direction is normalized, line indices clamp to available lines, and the ending column is exclusive. Wide trailing cells are skipped, trailing ASCII spaces are removed from each selected line, and lines are joined with \n. Empty state or an empty range returns an empty string.

ยงExamples

use ailloli_ui_terminal_core::TerminalState;
use ailloli_ui_widgets::controls::{
    terminal_selection_text, TerminalPosition, TerminalSelection,
};
let mut state = TerminalState::new();
state.write_str("hello");
let selection = TerminalSelection::new(
    TerminalPosition::new(0, 0),
    TerminalPosition::new(0, 5),
);
assert_eq!(terminal_selection_text(&state, selection), "hello");