Struct textmode::blocking::Output

source ·
pub struct Output { /* private fields */ }
Expand description

Manages drawing to the terminal on stdout.

Most functionality is provided by the Textmode trait. You should call those trait methods to draw to the in-memory screen, and then call refresh when you want to update the terminal on stdout.

Implementations§

source§

impl Output

source

pub fn new() -> Result<Self>

Creates a new Output instance containing a ScreenGuard instance.

Errors
  • Error::WriteStdout: failed to write initialization to stdout
source

pub fn new_without_screen() -> Self

Creates a new Output instance without creating a ScreenGuard instance.

source

pub fn take_screen_guard(&mut self) -> Option<ScreenGuard>

Removes the ScreenGuard instance stored in this Output instance and returns it. This can be useful if you need to manage the lifetime of the ScreenGuard instance separately.

source

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

Draws the in-memory screen to the terminal on stdout. This is done using a diff mechanism to only update the parts of the terminal which are different from the in-memory screen.

Errors
  • Error::WriteStdout: failed to write screen state to stdout
source

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

Draws the in-memory screen to the terminal on stdout. This clears the screen and redraws it from scratch, rather than using a diff mechanism like refresh. This can be useful when the current state of the terminal screen is unknown, such as after the terminal has been resized.

Errors
  • Error::WriteStdout: failed to write screen state to stdout

Trait Implementations§

source§

impl Textmode for Output

source§

fn screen(&self) -> &Screen

Returns the in-memory screen itself. This is the screen that will be drawn on the next call to refresh.
source§

fn write(&mut self, buf: &[u8])

Writes a sequence of bytes, potentially containing terminal escape sequences, to the in-memory screen.
source§

fn set_size(&mut self, rows: u16, cols: u16)

Sets the terminal size for the in-memory screen.
source§

fn write_str(&mut self, text: &str)

Writes a string of printable characters to the in-memory screen.
source§

fn move_to(&mut self, row: u16, col: u16)

Moves the in-memory screen’s cursor.
source§

fn move_relative(&mut self, row_offset: i16, col_offset: i16)

source§

fn clear(&mut self)

Clears the in-memory screen.
source§

fn clear_line(&mut self)

Clears the line containing the cursor on the in-memory screen.
source§

fn reset_attributes(&mut self)

Clears the in-memory screen’s currently active drawing attributes.
source§

fn set_fgcolor(&mut self, color: Color)

Sets the foreground color for subsequent drawing operations to the in-memory screen.
source§

fn set_bgcolor(&mut self, color: Color)

Sets the background color for subsequent drawing operations to the in-memory screen.
source§

fn set_bold(&mut self, bold: bool)

Sets whether subsequent text drawn to the in-memory screen should be bold.
source§

fn set_italic(&mut self, italic: bool)

Sets whether subsequent text drawn to the in-memory screen should be italic.
source§

fn set_underline(&mut self, underline: bool)

Sets whether subsequent text drawn to the in-memory screen should be underlined.
source§

fn set_inverse(&mut self, inverse: bool)

Sets whether subsequent text drawn to the in-memory screen should have its colors inverted.
source§

fn hide_cursor(&mut self, hide: bool)

Sets whether the cursor should be visible.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.