Skip to main content

ScreenContext

Struct ScreenContext 

Source
pub struct ScreenContext<'a, W: Write = Stdout> { /* private fields */ }
Expand description

Context guard for alternate screen mode.

This struct provides RAII semantics for alternate screen operations. When dropped, it automatically leaves alternate screen mode and restores the cursor if it was hidden.

Use Console::screen() to create a ScreenContext.

Implementations§

Source§

impl<'a, W: Write> ScreenContext<'a, W>

Source

pub fn update<R: Renderable + 'static>(&mut self, renderable: R) -> Result<()>

Update the screen with new content.

This renders the given renderable to fill the terminal dimensions.

§Arguments
  • renderable - The content to display on the screen.
§Example
let mut screen = console.screen(true, None)?;
screen.update(Text::plain("Hello, World!"))?;
Source

pub fn update_with_style<R: Renderable + 'static>( &mut self, renderable: R, style: Option<Style>, ) -> Result<()>

Update the screen with new content and optional style override.

§Arguments
  • renderable - The content to display on the screen.
  • style - Optional style override for the screen background.
Source

pub fn update_many<I, R>(&mut self, renderables: I) -> Result<()>
where I: IntoIterator<Item = R>, R: Renderable + 'static,

Update the screen with multiple renderables.

The renderables are grouped together and rendered as a single unit.

§Arguments
  • renderables - Iterator of renderables to display.
Source

pub fn update_many_with_style<I, R>( &mut self, renderables: I, style: Option<Style>, ) -> Result<()>
where I: IntoIterator<Item = R>, R: Renderable + 'static,

Update the screen with multiple renderables and optional style.

§Arguments
  • renderables - Iterator of renderables to display.
  • style - Optional style override for the screen background.
Source

pub fn set_style(&mut self, style: Option<Style>)

Set the default style for the screen.

This style will be used for all subsequent update() calls unless overridden with update_with_style().

Source

pub fn style(&self) -> Option<Style>

Get the current default style.

Source

pub fn is_active(&self) -> bool

Check if alternate screen mode is active.

Source

pub fn console(&self) -> &Console<W>

Get a reference to the underlying console.

Source

pub fn console_mut(&mut self) -> &mut Console<W>

Get a mutable reference to the underlying console.

Trait Implementations§

Source§

impl<W: Write> Drop for ScreenContext<'_, W>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, W> Freeze for ScreenContext<'a, W>

§

impl<'a, W = Stdout> !RefUnwindSafe for ScreenContext<'a, W>

§

impl<'a, W> Send for ScreenContext<'a, W>
where W: Send,

§

impl<'a, W> Sync for ScreenContext<'a, W>
where W: Sync,

§

impl<'a, W> Unpin for ScreenContext<'a, W>

§

impl<'a, W = Stdout> !UnwindSafe for ScreenContext<'a, W>

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.