Skip to main content

ThemeContext

Struct ThemeContext 

Source
pub struct ThemeContext<'a> { /* private fields */ }
Expand description

A theme in use on a Console until this guard drops. Returned by Console::use_theme; upstream’s ThemeContext.

Methods from Deref<Target = Console>§

Source

pub fn color_system(&self) -> Option<ColorSystem>

The active color system, or None when styles are not rendered at all. Port of Console.color_system.

Like upstream, this is independent of no_color: no-colour mode keeps the colour system and strips only the colours at output time, so bold, italic, underline and the like still render. Callers asking “will colour reach the terminal?” must check both.

Source

pub fn no_color(&self) -> bool

Whether colour output is disabled. Port of Console.no_color: set by the builder, or by a non-empty NO_COLOR environment variable.

Source

pub fn get_time(&self) -> f64

The current time in seconds from this console’s clock. Port of Console.get_time (default time.monotonic); override it with ConsoleBuilder::get_time for deterministic animation.

Source

pub fn width(&self) -> usize

The width in cells. Port of the Console.width property: the width of size.

Source

pub fn height(&self) -> usize

The height in rows. Port of the Console.height property: the height of size. Used by height-aware renderables such as Layout.

Source

pub fn set_width(&mut self, width: usize)

Set the width. Port of the Console.width setter.

Source

pub fn set_height(&mut self, height: usize)

Set the height. Port of the Console.height setter.

Source

pub fn set_size(&mut self, width: usize, height: usize)

Set the width and height. Port of the Console.size setter.

Source

pub fn quiet(&self) -> bool

Whether all output is suppressed. Port of Console.quiet.

Source

pub fn set_quiet(&self, quiet: bool)

Suppress (or restore) all output. Upstream’s Console.quiet is a plain attribute; on_broken_pipe sets it.

Source

pub fn soft_wrap(&self) -> bool

The default of print(soft_wrap=…). Port of Console.soft_wrap.

Source

pub fn set_soft_wrap(&mut self, soft_wrap: bool)

Change the soft wrap default. Upstream’s Console.soft_wrap is a plain attribute.

Source

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

The style applied to all output, if any. Port of Console.style.

Source

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

Change the style applied to all output. Upstream’s Console.style is a plain attribute.

Source

pub fn is_dumb_terminal(&self) -> bool

Whether the console writes to a terminal that cannot render styles: TERM is dumb or unknown. Port of Console.is_dumb_terminal.

Source

pub fn on_broken_pipe(&self)

Called when a write fails because the reader closed the pipe. Port of Console.on_broken_pipe: by default the console goes quiet and the process exits with status 1 (upstream raises SystemExit(1)). Upstream lets a subclass override it; here ConsoleBuilder::on_broken_pipe gives the replacement.

Upstream also points standard output at os.devnull so that the interpreter’s flush at exit does not fail again. A Rust process does not flush at exit, so nothing is redirected.

Source

pub fn is_terminal(&self) -> bool

Whether output is going to a real terminal.

Source

pub fn legacy_windows(&self) -> bool

Whether output targets a legacy Windows console (drives box substitution).

Source

pub fn safe_box(&self) -> bool

Whether to substitute box glyphs for terminal-safe variants (default on).

Source

pub fn ascii_only(&self) -> bool

Whether the terminal can only render ASCII (forces the ASCII box).

Source

pub fn theme(&self) -> &Theme

The active theme: the top of the theme stack.

Source

pub fn get_style(&self, style: &StyleType) -> Result<Style>

Resolve a style name (or pass a style through) against this console’s theme. Port of Console.get_style.

Source

pub fn push_theme(&mut self, theme: Theme, inherit: bool)

Push a theme on to the top of the stack. Port of Console.push_theme.

With inherit the new top is the current top’s styles overridden by theme’s; without it, the new top is exactly theme. Prefer use_theme, which pops again automatically.

Source

pub fn pop_theme(&mut self) -> Result<()>

Remove the top theme, restoring the previous one. Port of Console.pop_theme; popping the base theme is an error (upstream’s ThemeStackError("Unable to pop base theme")).

Source

pub fn use_theme(&mut self, theme: Theme) -> ThemeContext<'_>

Use a theme until the returned guard is dropped. Port of Console.use_theme, Python’s context manager as an RAII guard.

The guard dereferences to the console, so print through the guard while it is alive; dropping it pops the theme, including during a panic unwind.

let mut console = Console::builder().width(20).build();
let mut theme = Theme::new();
theme.insert("warning", Style::parse("bold red").unwrap());
{
    let themed = console.use_theme(theme);
    assert!(themed.theme().get("warning").is_some());
}
assert!(console.theme().get("warning").is_none());

Upstream’s use_theme also takes inherit, but its ThemeContext never passes it on to push_theme, so a used theme always inherits (verified against rich 15.0.0). This port keeps that behaviour and omits the ignored parameter; call push_theme to replace the styles outright.

Source

pub fn base_style(&self) -> &Style

The whole-output base style.

Source

pub fn add_highlighter(&mut self, highlighter: Box<dyn Highlighter + Send>)

Register a highlighter. The core plugin seam — see docs/PLUGINS.md. The highlighter must be Send so a Console can move to a background thread (e.g. an auto-refreshing Live).

Source

pub fn options(&self) -> ConsoleOptions

The default render options for this console (full width, no height).

Source

pub fn size(&self) -> ConsoleDimensions

The size of the console. Port of the Console.size property: the width and height given (the width one less on a legacy Windows console, as upstream subtracts it when both are set), else 80x25 on a dumb terminal, else the terminal’s size for whichever was not given.

Source

pub fn encoding(&self) -> &'static str

The output encoding: "ascii" for an ASCII-only console, else "utf-8". Port of the Console.encoding property (which reads the output file’s encoding; this port has no file to ask).

Source

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

Render a value to an ANSI string (no trailing newline). Primarily for tests and inline rendering.

When no explicit justify is requested, the width is first shrunk to the renderable’s measured width (matching upstream’s measurement-fit for a bare top-level renderable).

Source

pub fn render_segments_with( &self, renderable: &dyn Renderable, options: &ConsoleOptions, ) -> Vec<Segment>

Render a renderable to segments with explicit render options, exactly as print_with does before writing: a printed Text goes through upstream’s Text.join, a renderable that opts in is fitted to its measurement, and the result is cropped to the console width (print(crop=True)). No trailing newline is added.

For upstream’s lower-level Console.render, see render.

Source

pub fn render( &self, renderable: &dyn Renderable, options: Option<&ConsoleOptions>, ) -> Vec<Segment>

Render a renderable to segments. Port of Console.render: options defaults to options, and nothing is rendered when there is no width (max_width < 1).

Unlike the print path (render_segments_with) the renderable is rendered as-is: no Text.join, no fitting and no crop. Container renderables use this for their children.

As everywhere in this port, lines are separated by newline segments: the final line has no trailing "\n" where upstream’s has one.

Source

pub fn input(&self, prompt: &str) -> Result<Option<String>>

Display prompt and read a line of input from standard input. Port of Console.input: the prompt is console markup, printed through the console with end="" so it is captured and exported like any other output. None means end of input.

Source

pub fn input_from( &self, prompt: &dyn Renderable, stream: &mut dyn InputSource, ) -> Result<Option<String>>

input with a renderable prompt (upstream accepts a Text) and an explicit input source — upstream’s stream= argument.

Source

pub fn render_lines( &self, renderable: &dyn Renderable, options: &ConsoleOptions, pad: bool, ) -> Vec<Vec<Segment>>

Render a value into a list of lines, each a list of Segments.

Port of Console.render_lines. When pad is true, every line is padded (or cropped) to options.max_width — this is what container renderables such as Panel/Padding rely on to get uniform-width child rows.

Source

pub fn render_lines_styled( &self, renderable: &dyn Renderable, options: &ConsoleOptions, style: Option<&Style>, pad: bool, ) -> Vec<Vec<Segment>>

render_lines with upstream’s style= argument: the style is applied under every rendered segment and to the padding that fills each line, as Panel and Padding use it.

Source

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

Render a value exactly as print would write it, returning the string (including the single trailing newline). For tests and export.

Source

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

Render a value and write it to stdout, followed by a newline (unless the renderable ends without one upstream: Renderable::print_end_line).

Source

pub fn print_with(&self, renderable: &dyn Renderable, options: &ConsoleOptions)

Print with explicit render options, the equivalent of upstream’s Console.print(renderable, justify=…, overflow=…, no_wrap=…). Start from options and set the fields to override. A printed Text defers to these options, because upstream’s Text.join drops the text’s own justify, overflow and no_wrap.

Source

pub fn render_export_with( &self, renderable: &dyn Renderable, options: &ConsoleOptions, ) -> String

Like render_export, with explicit render options as for print_with.

Source

pub fn control(&self, control: &Control)

Write a terminal control sequence to stdout.

Port of Console.control. Control codes are only written when output is a real terminal (they are meaningless when redirected to a file).

Source

pub fn push_render_hook(&self, hook: Arc<dyn RenderHook>)

Add a render hook to the stack. Port of Console.push_render_hook.

Source

pub fn pop_render_hook(&self)

Remove the last render hook pushed. Port of Console.pop_render_hook; with none left, nothing happens (upstream raises IndexError).

Source

pub fn set_live(&self, live: Arc<dyn Any + Send + Sync>) -> bool

Push a live display on to this console’s stack, returning whether it is the only one (the display that draws). Port of Console.set_live, which upstream’s Live calls when it starts.

The stack is shared by the console’s clones. A Live pushes itself here when it starts and pops the stack when it stops; one started while the stack is not empty is nested, and the first display draws it below its own renderable. Anything else pushed here takes a place on the stack and draws nothing.

Source

pub fn clear_live(&self)

Pop the last live display pushed by set_live. Port of Console.clear_live; with none left, nothing happens (upstream raises IndexError).

Source

pub fn screen( &self, hide_cursor: bool, style: Option<StyleType>, ) -> ScreenContext<'_>

Use the alternate screen until the returned guard drops. Port of Console.screen(hide_cursor=…, style=…), Python’s context manager as an RAII guard: the alternate screen is switched on (and the cursor hidden, when hide_cursor), and switched back when the guard drops, if it was switched at all (only a terminal is). Print a full-screen renderable with ScreenContext::update.

Source

pub fn status(&self, status: Status) -> LiveStatus<Stdout>

Display a status and spinner until it is stopped. Port of Console.status: status carries the message and upstream’s keyword arguments (spinner, spinner_style, speed, refresh_per_second), and the display starts at once on a copy of this console, writing to standard output, as with console.status(…): does; LiveStatus::stop ends it.

Source

pub fn status_to<W: Write + Send + 'static>( &self, status: Status, writer: W, ) -> LiveStatus<W>

status, writing to writer instead of standard output (upstream’s console file).

Source

pub fn is_alt_screen(&self) -> bool

Whether the alternate screen is enabled. Port of Console.is_alt_screen.

Source

pub fn set_alt_screen(&self, enable: bool) -> bool

Enable or disable the alternate screen. Port of Console.set_alt_screen: only a terminal (not a legacy Windows console) switches, and the result says whether it did.

Source

pub fn update_screen( &self, renderable: &dyn Renderable, region: Option<Region>, options: Option<&ConsoleOptions>, ) -> Result<()>

Render renderable into region of the alternate screen (the whole screen when None). Port of Console.update_screen.

Source

pub fn update_screen_lines( &self, lines: &[Vec<Segment>], x: usize, y: usize, ) -> Result<()>

Write rendered lines to the alternate screen at column x, row y. Port of Console.update_screen_lines (through ScreenUpdate).

Source

pub fn show_cursor(&self, show: bool)

Show or hide the cursor. Port of Console.show_cursor.

Source

pub fn clear(&self)

Clear the screen. Port of Console.clear.

Source

pub fn bell(&self)

Ring the terminal bell. Port of Console.bell.

Source

pub fn capture(&self, f: impl FnOnce(&Console)) -> String

Capture everything printed inside f instead of writing it to stdout, returning it as a rendered (ANSI) string.

The Rust analogue of upstream’s with console.capture() as capture: — the closure receives the same console, and captures nest correctly. Equivalent to what would have been written to the terminal.

Each closure capture holds only what was printed inside it. Upstream’s nested capture() contexts share one buffer, so the inner one takes everything printed since the outer one began; begin_capture and end_capture behave that way.

Source

pub fn begin_capture(&self)

Begin capturing this thread’s output: what is printed is held until end_capture instead of written. Port of Console.begin_capture.

Source

pub fn end_capture(&self) -> String

End the innermost capture begun with begin_capture on this thread, returning what was printed as a terminal string. Port of Console.end_capture.

As upstream, which holds one buffer per thread, everything captured on the thread so far is returned, including what outer captures hold, and those are left empty. Without a capture to end, the result is empty (upstream’s console would stop writing altogether).

Source

pub fn export_text(&self, f: impl FnOnce(&Console)) -> String

Like capture but with all styles stripped, returning plain text. Port of Console.export_text(styles=False).

Source

pub fn export_text_styled(&self, f: impl FnOnce(&Console)) -> String

Like export_text with escape codes. Port of Console.export_text(styles=True): each segment in the console’s colour system (upstream’s style keeps the codes printing rendered), or in truecolor, Style.render’s default, without one.

Source

pub fn save_text( &self, path: impl AsRef<Path>, styles: bool, f: impl FnOnce(&Console), ) -> Result<()>

Write what f prints to path as text, with escape codes when styles. Port of Console.save_text.

Source

pub fn save_html( &self, path: impl AsRef<Path>, f: impl FnOnce(&Console), ) -> Result<()>

Write what f prints to path as HTML with a stylesheet. Port of Console.save_html (its default inline_styles=False).

Source

pub fn save_svg( &self, path: impl AsRef<Path>, title: &str, unique_id: &str, f: impl FnOnce(&Console), ) -> Result<()>

Write what f prints to path as SVG. Port of Console.save_svg; as for export_svg, the unique_id is given.

Source

pub fn page(&self, styles: bool, f: impl FnOnce(&Console)) -> Result<()>

Buffer everything printed inside f and display it through the system pager. The Rust analogue of upstream’s with console.pager(): block.

Styles are stripped unless styles is set, matching Console.pager(styles=False). When there’s no terminal to page in (piped output, TERM=dumb) or no pager can be started, the content is written straight to stdout.

Source

pub fn page_with( &self, pager: &dyn Pager, styles: bool, f: impl FnOnce(&Console), ) -> Result<()>

Like page but with an explicit Pager — the seam upstream exposes as Console.pager(pager=…). Hyperlinks are stripped, as upstream’s default links=False does.

Like page_with, keeping hyperlinks when links and styles are both set. Port of Console.pager(pager, styles, links): without styles everything is plain, and without links each style loses its link (Segment.strip_links).

Source

pub fn export_html(&self, f: impl FnOnce(&Console)) -> String

Capture output printed inside f and export it as a self-contained HTML document (inline styles), using the default terminal theme. Port of Console.export_html(inline_styles=True).

Source

pub fn export_html_themed( &self, theme: &TerminalTheme, f: impl FnOnce(&Console), ) -> String

Like export_html but with an explicit palette — upstream’s export_html(theme=…). See terminal_theme for the bundled presets.

Source

pub fn export_html_classes(&self, f: impl FnOnce(&Console)) -> String

Like export_html but with a generated CSS-class stylesheet (.r1 {…}) instead of inline styles. Port of upstream’s default Console.export_html(inline_styles=False).

Source

pub fn export_html_classes_themed( &self, theme: &TerminalTheme, f: impl FnOnce(&Console), ) -> String

Like export_html_classes but with an explicit palette — upstream’s export_html(theme=…, inline_styles=False).

Source

pub fn export_svg( &self, title: &str, unique_id: &str, f: impl FnOnce(&Console), ) -> String

Capture output printed inside f and export it as a self-contained SVG image of a terminal window, using SVG_EXPORT_THEME. Port of Console.export_svg.

unique_id prefixes every generated id/class. Upstream’s auto-computed default hashes Python repr() output (not reproducible in Rust), so this port takes an explicit id; output is byte-parity with export_svg(title=…, unique_id=…) (see docs/DIVERGENCES.md #15).

Source

pub fn export_svg_themed( &self, theme: &TerminalTheme, title: &str, unique_id: &str, f: impl FnOnce(&Console), ) -> String

Like export_svg but with an explicit palette — upstream’s export_svg(theme=…).

Source

pub fn export_html_with( &self, theme: &TerminalTheme, code_format: Option<&str>, inline_styles: bool, f: impl FnOnce(&Console), ) -> Result<String, ExportFormatError>

Capture output printed inside f and export it as HTML with every option of upstream’s Console.export_html: code_format (default CONSOLE_HTML_FORMAT) and inline_styles. See export::export_html_with.

Source

pub fn export_svg_with( &self, theme: &TerminalTheme, title: &str, unique_id: &str, code_format: Option<&str>, font_aspect_ratio: f64, f: impl FnOnce(&Console), ) -> Result<String, ExportFormatError>

Capture output printed inside f and export it as SVG with every option of upstream’s Console.export_svg: code_format (default CONSOLE_SVG_FORMAT) and font_aspect_ratio (upstream default 0.61). See svg::export_svg_with.

Source

pub fn record_output(&self, f: impl FnOnce(&Console)) -> Vec<Segment>

Record everything f prints and hand back the raw segments, without writing to the terminal.

This is the seam for producing several outputs from one render — the terminal bytes and an HTML and an SVG file, say — which is what rich --export-html … --export-svg … needs. Upstream reaches the same place with Console(record=True) plus save_html(clear=False); here the buffer is returned instead of being held on the console, so the caller decides what to do with it and there is no hidden state to clear.

Pair with segments_to_string to get the terminal form, export::export_html_classes for HTML, and svg::export_svg for SVG.

Rendering twice instead would be wrong, not merely wasteful: a renderable reading standard input only yields its content once.

Source

pub fn record(&self) -> bool

Whether what is written is recorded. Port of Console.record.

Source

pub fn set_record(&self, record: bool)

Start (or stop) recording. Upstream’s Console.record is a plain attribute.

Source

pub fn export_text_recorded(&self, clear: bool, styles: bool) -> Result<String>

The recorded output as text, with escape codes when styles, the record cleared when clear. Port of Console.export_text(clear=…, styles=…) for a console built with record; upstream’s default is clear=True, styles=False. Without plain text, control codes are left out; with styles they stay, as upstream’s.

The styled form renders each style in the console’s colour system, truecolor without one, as export_text_styled.

§Errors

RichError::Console when the console is not recording (upstream asserts).

Source

pub fn save_text_recorded( &self, path: impl AsRef<Path>, clear: bool, styles: bool, ) -> Result<()>

Write export_text_recorded to path. Port of Console.save_text(path, clear=…, styles=…).

Source

pub fn export_html_recorded( &self, options: &ExportHtmlOptions<'_>, ) -> Result<String>

The recorded output as an HTML document. Port of Console.export_html(theme=…, clear=…, code_format=…, inline_styles=…) for a console built with record.

§Errors

RichError::Console when the console is not recording, or when code_format is not a template this port can fill (see export::export_html_with).

Source

pub fn save_html_recorded( &self, path: impl AsRef<Path>, options: &ExportHtmlOptions<'_>, ) -> Result<()>

Write export_html_recorded to path. Port of Console.save_html.

Source

pub fn export_svg_recorded( &self, options: &ExportSvgOptions<'_>, ) -> Result<String>

The recorded output as an SVG image of a terminal window. Port of Console.export_svg(title=…, theme=…, clear=…, code_format=…, font_aspect_ratio=…, unique_id=…) for a console built with record. Control codes are left out, and the image is as wide as the console is now.

§Errors

As for export_html_recorded.

Source

pub fn save_svg_recorded( &self, path: impl AsRef<Path>, options: &ExportSvgOptions<'_>, ) -> Result<()>

Write export_svg_recorded to path. Port of Console.save_svg.

Source

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

Parse content as console markup, apply registered highlighters, and print it. This is the console.print("...") path.

Source

pub fn render_str_to_string(&self, content: &str) -> String

Same as Console::print_str but returns the ANSI string.

Source

pub fn build_text(&self, content: &str) -> Text

Parse content as console markup (expanding emoji + applying the active highlighters), returning the styled Text that print_str would print. Exposed so callers can wrap the markup in another renderable.

Source

pub fn try_build_text(&self, content: &str) -> Result<Text>

As build_text, but returns RichError::Markup for malformed markup instead of falling back to the raw text — upstream’s behaviour.

Source

pub fn render_str(&self, content: &str, highlight: Option<bool>) -> Text

Convert a plain string to Text the way a str renderable is converted upstream: emoji codes expand (per the console), console markup is parsed, and highlighting runs when highlight (or, when None, the console default) enables it. Port of Console.render_str, which Table cells, Tree labels and Columns items go through.

Malformed markup falls back to the literal text, as build_text does (docs/DIVERGENCES.md §2).

Source

pub fn try_print_str(&self, content: &str) -> Result<()>

As print_str, but reports malformed markup.

Source

pub fn try_print_justified(&self, content: &str, justify: Justify) -> Result<()>

As print_justified, but reports malformed markup.

Source

pub fn render_str_with( &self, content: &str, options: &RenderStrOptions<'_>, ) -> Result<Text>

Convert a string to Text with every keyword upstream’s Console.render_str takes. Port of Console.render_str, strict: malformed markup is an error (MarkupError), not the literal text.

Emoji, markup and highlighting default to the console’s settings when the option is None. As upstream, a highlighted result is a fresh Text carrying only spans (the highlighter’s, then the markup’s): the style, justify and overflow are dropped by copy_styles.

Source

pub fn emoji(&self) -> bool

Whether :emoji: codes are replaced by default. Port of Console(emoji=…).

Source

pub fn highlight(&self) -> bool

Whether printed strings are highlighted by default. Port of Console(highlight=…).

Source

pub fn markup(&self) -> bool

Whether printed strings are parsed as console markup by default. Port of Console(markup=…).

Source

pub fn emoji_variant(&self) -> Option<EmojiVariant>

The default emoji variant. Port of Console(emoji_variant=…).

Source

pub fn tab_size(&self) -> usize

The tab stop width Text expands tabs to. Port of Console.tab_size.

Source

pub fn set_tab_size(&mut self, tab_size: usize)

Change the tab stop width. Upstream’s Console.tab_size is a plain attribute.

Source

pub fn set_window_title(&self, title: &str) -> bool

Set the terminal window title. Port of Console.set_window_title: only a terminal is sent the code, and the return value says whether it was.

Source

pub fn print_justified(&self, content: &str, justify: Justify)

Parse content as markup and print it justified to the console width. This is the console.print("...", justify=...) path.

Source

pub fn render_justified_to_string( &self, content: &str, justify: Justify, ) -> String

Same as Console::print_justified but returns the ANSI string.

The justify is passed via options.justify, which — matching upstream — disables the measurement-fit so the text pads to the full width.

Source

pub fn segments_to_string(&self, segments: &[Segment]) -> String

Convert rendered segments into a terminal string, applying this console’s colour system (and honouring no_color). Port of Console._render_buffer.

Source

pub fn log( &self, objects: &[LogObject<'_>], options: &LogOptions<'_>, ) -> Result<()>

Log objects with the time and the caller’s file and line. Port of Console.log(*objects, sep=…, end=…, style=…, justify=…, emoji=…, markup=…, highlight=…): the objects are joined as for print and laid out by upstream’s LogRender table, with the time (blank when it repeats the last one) and file:line linked to the file.

The caller is the code calling log, found with #[track_caller] (upstream inspects the stack). log_at names it.

Source

pub fn log_at( &self, objects: &[LogObject<'_>], options: &LogOptions<'_>, file: &str, line: u32, ) -> Result<()>

log with the caller’s file and line given: upstream’s _caller_frame_info. The path column shows the file’s name, linked to its absolute path unless it starts with <.

Source

pub fn print_objects( &self, objects: &[PrintObject<'_>], options: &PrintOptions<'_>, ) -> Result<()>

Print objects as upstream’s Console.print(*objects, sep=…, end=…, style=…, justify=…, overflow=…, no_wrap=…, emoji=…, markup=…, highlight=…, width=…, height=…, crop=…, soft_wrap=…, new_line_start=…) does. Strings and texts in a row join into one Text with sep and end with end; other renderables stand alone. Malformed markup is an error, as upstream’s MarkupError.

Source

pub fn render_objects( &self, objects: &[PrintObject<'_>], options: &PrintOptions<'_>, ) -> Result<Vec<Segment>>

The segments print_objects writes, ending as upstream’s do (a trailing newline included).

Source

pub fn line(&self, count: usize)

Write count blank lines. Port of Console.line.

Source

pub fn rule( &self, title: &str, characters: &str, style: impl Into<StyleType>, align: HorizontalAlign, )

Draw a rule with an optional title. Port of Console.rule(title, characters=…, style=…, align=…).

Source

pub fn out( &self, objects: &[&str], sep: &str, end: &str, style: Option<StyleType>, highlight: Option<bool>, ) -> Result<()>

Write objects joined by sep with no markup, emoji, wrapping or cropping. Port of Console.out.

Source

pub fn print_json(&self, json: &str, options: &JsonOptions) -> Result<()>

Pretty print a JSON string. Port of Console.print_json: a Json printed with soft_wrap=True.

Source

pub fn measure( &self, renderable: &dyn Renderable, options: Option<&ConsoleOptions>, ) -> Measurement

The width renderable needs under options (the console’s when None). Port of Console.measure.

Trait Implementations§

Source§

impl Deref for ThemeContext<'_>

Source§

type Target = Console

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Console

Dereferences the value.
Source§

impl DerefMut for ThemeContext<'_>

Source§

fn deref_mut(&mut self) -> &mut Console

Mutably dereferences the value.
Source§

impl Drop for ThemeContext<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ThemeContext<'a>

§

impl<'a> !UnwindSafe for ThemeContext<'a>

§

impl<'a> Freeze for ThemeContext<'a>

§

impl<'a> Send for ThemeContext<'a>

§

impl<'a> Sync for ThemeContext<'a>

§

impl<'a> Unpin for ThemeContext<'a>

§

impl<'a> UnsafeUnpin for ThemeContext<'a>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.