Skip to main content

Control

Struct Control 

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

A renderable that inserts terminal control codes.

Mirrors rich.control.Control. Construct it via the factory methods (Control::clear, [Control::move], …) or Control::new with an explicit list of codes, which are concatenated in order.

Implementations§

Source§

impl Control

Source

pub fn new(codes: &[ControlType]) -> Self

Build a control from a sequence of codes, rendered end to end.

Source

pub fn bell() -> Self

Ring the terminal bell.

Source

pub fn home() -> Self

Move the cursor to the home position (top-left).

Source

pub fn clear() -> Self

Clear the screen.

Source

pub fn move_(x: i32, y: i32) -> Self

Move the cursor relative to its current position (x columns, y rows; positive is right/down). Port of Control.move.

Source

pub fn move_to_column(x: u32, y: i32) -> Self

Move to a zero-based column, optionally offset the row by y. Port of Control.move_to_column.

Source

pub fn move_to(x: u32, y: u32) -> Self

Move the cursor to an absolute zero-based (x, y) position.

Source

pub fn show_cursor(show: bool) -> Self

Show or hide the cursor.

Source

pub fn alt_screen(enable: bool) -> Self

Enable or disable the terminal’s alternate screen buffer.

Source

pub fn as_str(&self) -> &str

The raw escape string this control emits.

Trait Implementations§

Source§

impl Renderable for Control

Source§

fn rich_render( &self, _console: &Console, _options: &ConsoleOptions, ) -> Vec<Segment>

Source§

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

The (minimum, maximum) cell width this renderable wants. The default assumes the renderable fills the available width (e.g. Panel, Table); Text overrides it with its content width so the top-level print path can shrink to fit. Port of __rich_measure__ / Measurement.get.

Auto Trait Implementations§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.