Terminal

Struct Terminal 

Source
pub struct Terminal<B: Backend> { /* private fields */ }
Expand description

A terminal interface managing rendering and buffering.

The terminal orchestrates frame rendering, maintains double buffers, and coordinates with the backend.

§Example

use tuxtui_core::terminal::Terminal;
use tuxtui_core::backend::TestBackend;

let backend = TestBackend::new(80, 24);
let mut terminal = Terminal::new(backend).unwrap();
terminal.draw(|frame| {
    // Render widgets
}).unwrap();

Implementations§

Source§

impl<B: Backend> Terminal<B>

Source

pub fn new(backend: B) -> Result<Self, B::Error>

Create a new terminal with the given backend.

Source

pub fn with_options( backend: B, options: TerminalOptions, ) -> Result<Self, B::Error>

Create a new terminal with options.

Source

pub fn size(&self) -> Result<Rect, B::Error>

Get the size of the terminal.

Source

pub fn viewport(&self) -> Rect

Get the current viewport.

Source

pub fn clear(&mut self) -> Result<(), B::Error>

Clear the terminal.

Source

pub fn draw<F>(&mut self, render: F) -> Result<(), B::Error>
where F: FnOnce(&mut Frame<'_>),

Draw a frame using the provided closure.

§Example
terminal.draw(|frame| {
    let area = frame.area();
    frame.render_widget(widget, area);
})?;
Source

pub fn show_cursor(&mut self) -> Result<(), B::Error>

Show the cursor.

Source

pub fn hide_cursor(&mut self) -> Result<(), B::Error>

Hide the cursor.

Source

pub fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), B::Error>

Set the cursor position.

Source

pub fn backend_mut(&mut self) -> &mut B

Get mutable access to the backend.

Source

pub fn flush(&mut self) -> Result<(), B::Error>

Flush the backend.

Trait Implementations§

Source§

impl<B: Backend> Drop for Terminal<B>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<B> Freeze for Terminal<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for Terminal<B>
where B: RefUnwindSafe,

§

impl<B> Send for Terminal<B>
where B: Send,

§

impl<B> Sync for Terminal<B>
where B: Sync,

§

impl<B> Unpin for Terminal<B>
where B: Unpin,

§

impl<B> UnwindSafe for Terminal<B>
where B: UnwindSafe,

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.