Terminal

Struct Terminal 

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

Interface to the terminal backed by Termion

Implementations§

Source§

impl Terminal<ZuiBackend<'_>>

Source

pub fn print(&mut self, c: &str) -> Result<()>

Source

pub fn get_size(&self) -> (u16, u16)

Source

pub fn get_position(&self) -> (u16, u16)

Source

pub fn size_did_change(&mut self) -> bool

Source

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

Source

pub fn keys(&self, stdin: Stdin) -> KeyIterator

Source

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

Source

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

Source

pub fn set_cursor_to(&mut self, x_pos: u16, y_pos: u16) -> Result<()>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl<B> Terminal<B>
where B: Backend,

Source

pub fn new(backend: B) -> Result<Terminal<B>>

Wrapper around Terminal initialization. Each buffer is initialized with a blank string and default colors for the foreground and the background

Source

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

UNSTABLE

Source

pub fn get_frame(&mut self) -> Frame<'_, B>

Get a Frame object which provides a consistent view into the terminal state for rendering.

Source

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

Source

pub fn backend(&self) -> &B

Source

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

Source

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

Obtains a difference between the previous and the current buffer and passes it to the current backend for drawing.

Source

pub fn resize(&mut self, area: Rect) -> Result<()>

Updates the Terminal so that internal buffers match the requested size. Requested size will be saved so the size can remain consistent when rendering. This leads to a full clear of the screen.

Source

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

Queries the backend for size and resizes if it doesn’t match the previous size.

Source

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

Synchronizes terminal size, calls the rendering closure, flushes the current internal state and prepares for the next draw call.

Source

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

Source

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

Source

pub fn get_cursor(&mut self) -> Result<(u16, u16)>

Source

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

Source

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

Clear the terminal and force a full redraw on the next draw call.

Source

pub fn size(&self) -> Result<Rect>

Queries the real size of the backend.

Trait Implementations§

Source§

impl<B> Debug for Terminal<B>
where B: Backend + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

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.