Skip to main content

Terminal

Struct Terminal 

Source
pub struct Terminal { /* private fields */ }
Available on crate feature crossterm only.
Expand description

Concrete crossterm terminal backends, exposed (issue #278) so external integrations can drive SLT’s render pipeline with their own event loop — pair with event::from_crossterm. Most apps should use run / run_inline, which build and drive these internally. Fullscreen crossterm terminal backend: owns raw mode + the alternate screen, double-buffers cells, and flushes only the diff each frame.

Exposed (issue #278) so external integrations can drive SLT’s rendering with their own event loop instead of reimplementing the backend. Pair with crate::event::from_crossterm to translate input. The built-in crate::run entry point uses this same type internally.

Implementations§

Source§

impl Terminal

Source

pub fn new( mouse: bool, kitty_keyboard: bool, report_all_keys: bool, color_depth: ColorDepth, ) -> Result<Self>

Construct a fullscreen terminal backend; enters raw mode and the alternate screen and optionally enables mouse capture and the kitty keyboard protocol. When report_all_keys is set (and kitty_keyboard is too), bare modifier presses are reported.

Source

pub fn size(&self) -> (u32, u32)

Return the fullscreen terminal’s current (cols, rows).

Source

pub fn buffer_mut(&mut self) -> &mut Buffer

Mutable access to the back buffer used by the next render pass.

Source

pub fn flush(&mut self) -> Result<()>

Diff the back buffer against the front buffer, write the changed cells to stdout under a synchronized-output guard, then swap front and back buffers.

Source

pub fn handle_resize(&mut self) -> Result<()>

Re-query the terminal size and resize the front and back buffers to match. Called from the SIGWINCH handler.

Trait Implementations§

Source§

impl Backend for Terminal

Source§

fn size(&self) -> (u32, u32)

Returns the current display size as (width, height) in cells.
Source§

fn buffer_mut(&mut self) -> &mut Buffer

Returns a mutable reference to the display buffer. Read more
Source§

fn flush(&mut self) -> Result<()>

Flush the buffer contents to the display. Read more
Source§

impl Drop for Terminal

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.