Skip to main content

Screen

Trait Screen 

Source
pub trait Screen {
    type C: Cell;

    // Required methods
    fn cell(&self, row: u16, col: u16) -> Option<&Self::C>;
    fn hide_cursor(&self) -> bool;
    fn cursor_position(&self) -> (u16, u16);

    // Provided method
    fn cursor_shape(&self) -> CursorShape { ... }
}
Expand description

A trait representing a pseudo-terminal screen.

Implementing this trait allows for backends other than vt100 to be used with the PseudoTerminal widget.

All row coordinates use a visible coordinate system where row 0 is the topmost row currently displayed. When scrollback is active, this may differ from the underlying terminal buffer’s row numbering. Implementors must ensure that cell and cursor_position use the same coordinate space.

Required Associated Types§

Source

type C: Cell

The type of cell this screen contains

Required Methods§

Source

fn cell(&self, row: u16, col: u16) -> Option<&Self::C>

Returns the cell at the given location in visible coordinates.

Row 0 is the topmost visible row, accounting for any scrollback offset.

Source

fn hide_cursor(&self) -> bool

Returns whether the cursor should be hidden.

Source

fn cursor_position(&self) -> (u16, u16)

Returns the cursor position in visible coordinates.

The return value is (row, column), where row 0 is the topmost visible row. This must use the same coordinate space as cell. When scrollback is active, the cursor row must be shifted down by the number of scrollback rows visible above the active screen content.

If the cursor is not within the visible area (e.g., scrolled off-screen), the returned row may exceed the screen dimensions. The rendering layer handles bounds checking.

Provided Methods§

Source

fn cursor_shape(&self) -> CursorShape

Returns the preferred shape of the cursor.

The default implementation returns CursorShape::Default, which preserves the widget’s configured cursor symbol. Backends that can report the terminal’s preferred cursor shape should override this.

Implementations on Foreign Types§

Source§

impl Screen for Screen

Source§

type C = Cell

Source§

fn cell(&self, row: u16, col: u16) -> Option<&Self::C>

Source§

fn hide_cursor(&self) -> bool

Source§

fn cursor_position(&self) -> (u16, u16)

Implementors§