Skip to main content

ConsoleOptions

Struct ConsoleOptions 

Source
pub struct ConsoleOptions {
Show 21 fields pub size: (usize, usize), pub min_width: usize, pub max_width: usize, pub max_height: usize, pub height: Option<usize>, pub is_terminal: bool, pub encoding: String, pub legacy_windows: bool, pub justify: Option<JustifyMethod>, pub overflow: Option<OverflowMethod>, pub no_wrap: bool, pub highlight: Option<bool>, pub markup: Option<bool>, pub theme_stack: ThemeStack, pub theme_name: String, pub markup_enabled: bool, pub emoji_enabled: bool, pub highlight_enabled: bool, pub tab_size: usize, pub disable_line_wrap: bool, pub color_system: Option<ColorSystem>,
}
Expand description

Options passed through the rendering pipeline.

This struct carries rendering context that flows through the entire render pipeline, allowing renderables to adapt to the output context.

§Console State

In addition to rendering options, this struct carries console configuration that renderables may need to access (theme styles, feature flags, etc.). This allows nested renderables to access console configuration without needing a direct reference to the Console.

Fields§

§size: (usize, usize)

Terminal dimensions as (width, height).

§min_width: usize

Minimum width for rendering.

§max_width: usize

Maximum width for rendering.

§max_height: usize

Maximum height constraint.

§height: Option<usize>

Optional height constraint for specific renderables.

§is_terminal: bool

Whether output is to a terminal (vs file/pipe).

§encoding: String

Character encoding.

§legacy_windows: bool

Whether to use legacy Windows console.

§justify: Option<JustifyMethod>

Text justification override.

§overflow: Option<OverflowMethod>

Text overflow handling override.

§no_wrap: bool

Disable text wrapping.

§highlight: Option<bool>

Highlight override for render_str.

§markup: Option<bool>

Markup parsing enabled.

§theme_stack: ThemeStack

Theme stack for style lookups. Cloned from the console.

§theme_name: String

Current theme name (e.g., “default”, “dracula”). Renderables can use this to match their theme to the console.

§markup_enabled: bool

Whether markup parsing is enabled by default.

§emoji_enabled: bool

Whether emoji replacement is enabled by default.

§highlight_enabled: bool

Whether highlighting is enabled by default.

§tab_size: usize

Tab size for tab expansion.

§disable_line_wrap: bool

Disable terminal automatic line wrap while printing.

This prevents “soft wrap” artifacts when output fills exactly the last column of the terminal (common on Windows Terminal and xterm-like VTs).

When enabled and writing to a real terminal, the Console will emit ESC[?7l before printing and ESC[?7h after.

§color_system: Option<ColorSystem>

Detected color system (None = no colors).

Implementations§

Source§

impl ConsoleOptions

Source

pub fn from_terminal() -> Self

Create options from the current terminal.

Source

pub fn get_style(&self, name: &str) -> Option<Style>

Get a style from the theme stack by name.

Source

pub fn ascii_only(&self) -> bool

Check if renderables should use ASCII only.

Source

pub fn copy(&self) -> Self

Create a copy of the options.

Source

pub fn update( &self, width: Option<usize>, min_width: Option<usize>, max_width: Option<usize>, justify: Option<Option<JustifyMethod>>, overflow: Option<Option<OverflowMethod>>, no_wrap: Option<bool>, highlight: Option<Option<bool>>, markup: Option<Option<bool>>, height: Option<Option<usize>>, ) -> Self

Update values and return a new copy.

Only non-None values in the update parameters will override the existing values.

Source

pub fn update_width(&self, width: usize) -> Self

Update just the width, return a copy.

Source

pub fn update_height(&self, height: usize) -> Self

Update the height and return a copy.

Source

pub fn update_dimensions(&self, width: usize, height: usize) -> Self

Update both width and height, return a copy.

Source

pub fn reset_height(&self) -> Self

Reset height to None, return a copy.

Trait Implementations§

Source§

impl Clone for ConsoleOptions

Source§

fn clone(&self) -> ConsoleOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConsoleOptions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ConsoleOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.