Skip to main content

Screen

Struct Screen 

Source
pub struct Screen { /* private fields */ }
Expand description

A renderable that fills the terminal screen and crops excess.

Screen renders its content to fill the full terminal dimensions, cropping any excess and padding if needed.

§Example

use rich_rs::{Console, Text};
use rich_rs::screen::Screen;

let text = Text::plain("Hello, World!");
let screen = Screen::new(text);

Implementations§

Source§

impl Screen

Source

pub fn new(renderable: impl Renderable + 'static) -> Self

Create a new Screen with a renderable.

Source

pub fn new_many<I, R>(renderables: I) -> Self
where I: IntoIterator<Item = R>, R: Renderable + 'static,

Create a new Screen from multiple renderables.

Python Rich’s Screen(*renderables) wraps the inputs in Group. This is the closest Rust equivalent.

Source

pub fn from_arc(renderable: Arc<dyn Renderable>) -> Self

Create a new Screen from an Arc<dyn Renderable>.

This avoids an extra Arc allocation when you already have one.

Source

pub fn with_style(self, style: impl Into<Style>) -> Self

Set the background style.

Source

pub fn with_application_mode(self, mode: bool) -> Self

Enable application mode (uses \n\r newlines).

Application mode is typically used when the terminal is in alternate screen mode, where \n\r provides correct cursor positioning.

Trait Implementations§

Source§

impl Renderable for Screen

Source§

fn render(&self, console: &Console, options: &ConsoleOptions) -> Segments

Render this object to a sequence of segments.
Source§

fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement

Measure the minimum and maximum width requirements. Read more

Auto Trait Implementations§

§

impl Freeze for Screen

§

impl !RefUnwindSafe for Screen

§

impl Send for Screen

§

impl Sync for Screen

§

impl Unpin for Screen

§

impl !UnwindSafe for Screen

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.