Display

Struct Display 

Source
pub struct Display<T: Tui> { /* private fields */ }
Expand description

A high level interface to the terminal display.

Implementations§

Source§

impl<T: Tui> Display<T>

Source

pub fn new(tui: T, theme: &Theme) -> Self

Create a new display instance.

Source

pub fn draw_str(&mut self, s: &str) -> Result<(), DisplayError>

Draws a string of text to the terminal interface.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

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

Clear the terminal interface and reset any style and color attributes.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn refresh(&mut self) -> Result<(), DisplayError>

Force a refresh of the terminal interface. This normally should be called after after all text has been drawn to the terminal interface. This is considered a slow operation, so should be called only as needed.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn color( &mut self, color: DisplayColor, selected: bool, ) -> Result<(), DisplayError>

Set the color of text drawn to the terminal interface. This will only change text drawn to the terminal after this function call.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn set_style( &mut self, dim: bool, underline: bool, reverse: bool, ) -> Result<(), DisplayError>

Set the style attributes of text drawn to the terminal interface. This will only change text drawn to the terminal after this function call.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn get_window_size(&self) -> Size

Get the width and height of the terminal interface. This can be a slow operation, so should not be called unless absolutely needed.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn ensure_at_line_start(&mut self) -> Result<(), DisplayError>

Reset the cursor position to the start of the line.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn move_from_end_of_line(&mut self, right: u16) -> Result<(), DisplayError>

Move the cursor position right characters from the end of the line.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn next_line(&mut self) -> Result<(), DisplayError>

Move the cursor to the next line.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn start(&mut self) -> Result<(), DisplayError>

Start the terminal interface interactions. This should be called before any terminal interactions are performed.

§Errors

Will error if the underlying terminal interface is in an error state.

Source

pub fn end(&mut self) -> Result<(), DisplayError>

End the terminal interface interactions. This should be called after all terminal interactions are complete. This resets the terminal interface to the default state, and should be called on program exit.

§Errors

Will error if the underlying terminal interface is in an error state.

Trait Implementations§

Source§

impl<T: Debug + Tui> Debug for Display<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Display<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Display<T>
where T: RefUnwindSafe,

§

impl<T> Send for Display<T>
where T: Send,

§

impl<T> Sync for Display<T>
where T: Sync,

§

impl<T> Unpin for Display<T>
where T: Unpin,

§

impl<T> UnwindSafe for Display<T>
where T: 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,