Console

Struct Console 

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

The main console type for rich terminal output.

Implementations§

Source§

impl Console

Source

pub fn new() -> Self

Create a new Console writing to stdout.

Source

pub fn stderr() -> Self

Create a new Console writing to stderr.

Source

pub fn capture() -> Self

Create a new Console that captures output to memory.

Useful for testing output verification.

Source

pub fn get_captured_output(&self) -> String

Get the captured output as a string (if using capture mode).

Source

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

Set a fixed terminal width.

Source

pub fn force_color(self, force: bool) -> Self

Force color output even when not detected.

Source

pub fn color_system(self, system: ColorSystem) -> Self

Set the color system explicitly.

Source

pub fn markup(self, enabled: bool) -> Self

Enable or disable markup parsing.

Source

pub fn emoji(self, enabled: bool) -> Self

Enable or disable emoji shortcode translation.

Source

pub fn soft_wrap(self, enabled: bool) -> Self

Enable or disable soft word wrapping.

Source

pub fn record(self, enabled: bool) -> Self

Enable or disable recording of output.

Source

pub fn start_recording(&self)

Start recording output.

Source

pub fn stop_recording(&self)

Stop recording output.

Source

pub fn get_width(&self) -> usize

Get the current terminal width.

Source

pub fn print(&self, content: &str)

Print a string with markup support.

Source

pub fn print_renderable(&self, renderable: &dyn Renderable)

Print any renderable object.

Source

pub fn println(&self, content: &str)

Print a line (with newline at the end).

Source

pub fn print_raw(&self, content: &str)

Print a string without markup parsing.

Use this when printing content that may contain brackets [...] that should NOT be interpreted as markup (e.g., debug output).

Source

pub fn println_raw(&self, content: &str)

Print a line without markup parsing (with newline at the end).

Use this when printing content that may contain brackets [...] that should NOT be interpreted as markup (e.g., debug output).

Source

pub fn newline(&self)

Print an empty line.

Source

pub fn clear(&self)

Clear the screen.

Source

pub fn show_cursor(&self, show: bool)

Show or hide the cursor.

Source

pub fn move_cursor_up(&self, n: u16)

Move the cursor up by n lines.

Source

pub fn move_cursor_down(&self, n: u16)

Move the cursor down by n lines.

Source

pub fn clear_line(&self)

Clear the current line.

Source

pub fn rule(&self, title: &str)

Show a rule (horizontal line).

Source

pub fn print_debug<T: Debug>(&self, obj: &T)

Pretty print a debug-printable object.

Uses syntax highlighting if the syntax feature is enabled.

Source

pub fn export_text(&self, renderable: &dyn Renderable) -> String

Export a renderable as plain text.

Returns the plain text representation without any ANSI codes.

Source

pub fn export_html(&self, renderable: &dyn Renderable) -> String

Export a renderable as HTML with inline styles.

Returns an HTML string with styled <span> elements.

Source

pub fn save_html(&self, path: &str) -> Result<()>

Save the recorded output as HTML.

Source

pub fn export_svg(&self, renderable: &dyn Renderable) -> String

Export a renderable as SVG.

Returns an SVG string with text elements.

Source

pub fn save_svg(&self, path: &str) -> Result<()>

Save the recorded output as SVG.

Trait Implementations§

Source§

impl ConsoleLog for Console

Source§

fn log(&self, message: &str)

Log a message with timestamp and location.
Source§

fn debug(&self, message: &str)

Log a debug message.
Source§

fn warn(&self, message: &str)

Log a warning message.
Source§

fn error(&self, message: &str)

Log an error message.
Source§

impl Debug for Console

Source§

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

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

impl Default for Console

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> 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.