Skip to main content

Tui

Struct Tui 

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

Manages the terminal User Interface (TUI) lifecycle, event handling, and rendering

Implementations§

Source§

impl Tui

Source

pub fn new(cancellation_token: CancellationToken) -> Result<Self>

Constructs a new terminal ui with default settings

Source

pub fn tick_rate(self, tick_rate: f64) -> Self

Sets the tick rate for the TUI.

The tick rate determines how frequently Event::Tick is generated.

Source

pub fn frame_rate(self, frame_rate: f64) -> Self

Sets the frame rate for the TUI.

The frame rate determines how often Event::Render is emitted.

Source

pub fn mouse(self, mouse: bool) -> Self

Enables or disables mouse event capture.

If true, Event::Mouse events will be emitted.

Source

pub fn paste(self, paste: bool) -> Self

Enables or disables bracketed paste mode.

If true, Event::Paste events will be emitted.

Source

pub fn keyboard_enhancement(self, keyboard_enhancement: bool) -> Self

Enables or disables keyboard enhancement flags.

Source

pub async fn next_event(&mut self) -> Option<Event>

Asynchronously retrieves the next event from the event queue.

Returns None if the event channel has been closed (e.g., the event loop has stopped).

Source

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

Prepares the terminal for full-screen TUI interaction and starts the event loop

Source

pub fn enter_inline(&mut self, extra_line: bool, min_height: u16) -> Result<()>

Prepares the terminal for inline TUI interaction and starts the event loop

Source

pub fn render<F>(&mut self, render_callback: F) -> Result<CompletedFrame<'_>>
where F: FnOnce(&mut Frame<'_>, Rect),

Renders the TUI using the provided callback function.

The callback receives a mutable reference to the Frame and the area to render in, which might not be the same as the frame area for inline TUIs.

Source

pub fn exit(self) -> Result<()>

Restores the terminal to its original state and stops the event loop

Methods from Deref<Target = Terminal<Backend<Stdout>>>§

Source

pub fn backend(&self) -> &B

Returns a shared reference to the backend.

This is primarily useful for backend-specific inspection in tests (e.g. reading TestBackend’s buffer) or for backend-specific APIs that Ratatui does not model.

Reading from the backend does not desynchronize Ratatui, but values observed here may lag behind the current render callback because Ratatui does not apply a frame to the backend until the end of Terminal::draw / Terminal::try_draw.

Source

pub fn backend_mut(&mut self) -> &mut B

Returns a mutable reference to the backend.

This is an advanced escape hatch. Normal applications should render through Terminal::draw / Terminal::try_draw instead of mutating the backend directly.

Use this when integrating with backend-specific APIs that Ratatui does not model, or when tests need direct control over backend state.

Mutating the backend directly can desynchronize Ratatui’s internal buffers, cursor tracking, or viewport assumptions from what’s on-screen. If you do this, call Terminal::clear or perform a full draw pass before relying on Ratatui’s view of the terminal again.

Source

pub fn size(&self) -> Result<Size, <B as Backend>::Error>

Queries the real size of the backend.

This returns the backend’s current terminal size and does not update Ratatui’s internal viewport bookkeeping by itself. The current renderable area depends on the configured Viewport; use Frame::area inside Terminal::draw / Terminal::try_draw if you want the area you should render into for the current pass.

To make Ratatui observe backend size changes for fullscreen or inline viewports, see Terminal::autoresize.

Source

pub fn get_frame(&mut self) -> Frame<'_>

Returns a Frame for manual rendering.

Most applications should render via Terminal::draw / Terminal::try_draw. This is an escape hatch that exposes the frame construction step used by Terminal::try_draw so tests and advanced callers can render without running the full draw pipeline.

This is primarily useful for tests, backend adapters, and specialized integrations that intentionally manage presentation themselves.

Unlike draw / try_draw, this does not call Terminal::autoresize, does not write updates to the backend, and does not apply any cursor changes. After rendering, you typically call Terminal::flush, Terminal::swap_buffers, and Backend::flush.

For the full render-pass behavior that also handles resizing, cursor updates, buffer swapping, and backend flushing, see Terminal::draw and Terminal::try_draw.

The returned Frame mutably borrows the current buffer, so it must be dropped before you can call methods like Terminal::flush. The example below uses a scope to make that explicit.

§Example
use ratatui::Terminal;
use ratatui::backend::{Backend, TestBackend};

let backend = TestBackend::new(30, 5);
let mut terminal = Terminal::new(backend)?;
{
    let mut frame = terminal.get_frame();
    frame.render_widget("Hello", frame.area());
}
// When not using `draw`, present the buffer manually:
terminal.flush()?;
terminal.swap_buffers();
terminal.backend_mut().flush()?;
Source

pub fn current_buffer_mut(&mut self) -> &mut Buffer

Gets the current buffer as a mutable reference.

This is the buffer that the next Frame will render into (see Terminal::get_frame). This is a low-level escape hatch; normal applications should render inside Terminal::draw and access the buffer through widgets, or through Frame::buffer_mut when they intentionally need direct cell access during a render pass.

Mutating this buffer does not update the backend immediately. The changes become visible only after a later Terminal::flush or full draw pass applies the diff. Because this bypasses the usual render callback structure, it is mainly useful for tests and specialized integrations that intentionally manage presentation themselves.

Source

pub fn flush(&mut self) -> Result<(), <B as Backend>::Error>

Applies the current buffer diff to the backend’s active display surface.

This compares the current buffer with the previous buffer and passes only the changed cells to Backend::draw. It is one of the building blocks used by Terminal::draw / Terminal::try_draw.

This method does not swap buffers, does not update cursor visibility or position, and does not call Backend::flush. See Terminal::swap_buffers and Backend::flush.

Terminal::flush only reasons about Ratatui’s internal buffers. It does not know whether the backend’s display surface changed since the last render pass. For example, if you leave the alternate screen and then call Terminal::flush, Ratatui may replay a diff that was computed for the alternate screen onto the main screen. In normal applications, prefer Terminal::draw / Terminal::try_draw unless you are intentionally managing the whole render pipeline yourself.

Implementation note: when there are updates, Ratatui records the position of the last updated cell as the “last known cursor position”. Inline viewports use this to preserve the cursor’s relative position within the viewport across resizes.

Source

pub fn swap_buffers(&mut self)

Clears the inactive buffer and swaps it with the current buffer.

This is part of the standard rendering flow (see Terminal::try_draw). If you render manually using Terminal::get_frame and Terminal::flush, call this immediately afterward so the next flush can compute diffs against the correct “previous” buffer.

Source

pub fn clear(&mut self) -> Result<(), <B as Backend>::Error>

Clear the terminal and force a full redraw on the next draw call.

What gets cleared depends on the active Viewport:

Current behavior: for Viewport::Inline, clearing runs from the viewport origin through the end of the visible display area, not just the viewport’s rectangle. This is an implementation detail rather than a contract; do not rely on it.

This preserves the backend’s current cursor position.

This also resets the “previous” buffer so the next Terminal::flush redraws the full viewport.

Implementation note: this uses ClearType::AfterCursor starting at the viewport origin.

Source

pub fn hide_cursor(&mut self) -> Result<(), <B as Backend>::Error>

Hides the cursor.

When using Terminal::draw / Terminal::try_draw, prefer controlling the cursor with Frame::set_cursor_position. A later successful Terminal::draw / Terminal::try_draw call may overwrite this change.

Source

pub fn show_cursor(&mut self) -> Result<(), <B as Backend>::Error>

Shows the cursor.

When using Terminal::draw / Terminal::try_draw, prefer controlling the cursor with Frame::set_cursor_position. A later successful Terminal::draw / Terminal::try_draw call may overwrite this change.

Source

pub fn get_cursor(&mut self) -> Result<(u16, u16), <B as Backend>::Error>

👎Deprecated:

use get_cursor_position() instead which returns Result<Position>

Gets the current cursor position.

This queries the backend for the current cursor position and returns it as an (x, y) tuple.

Source

pub fn set_cursor( &mut self, x: u16, y: u16, ) -> Result<(), <B as Backend>::Error>

👎Deprecated:

use set_cursor_position((x, y)) instead which takes impl Into<Position>

Sets the cursor position.

Source

pub fn get_cursor_position(&mut self) -> Result<Position, <B as Backend>::Error>

Gets the current cursor position.

This queries the backend for the current cursor position. It is not limited to Ratatui’s last render pass, so direct backend mutations may also affect the returned value.

When using Terminal::draw / Terminal::try_draw, prefer controlling the cursor with Frame::set_cursor_position. For direct control, see Terminal::set_cursor_position.

Source

pub fn set_cursor_position<P>( &mut self, position: P, ) -> Result<(), <B as Backend>::Error>
where P: Into<Position>,

Sets the cursor position.

This updates the backend cursor and Ratatui’s internal cursor tracking. Inline viewports use that tracking when recomputing the viewport on resize.

When using Terminal::draw / Terminal::try_draw, consider using Frame::set_cursor_position instead so the cursor is updated as part of the normal rendering flow. A later successful Terminal::draw / Terminal::try_draw call may overwrite a direct cursor move.

Source

pub fn insert_before<F>( &mut self, height: u16, draw_fn: F, ) -> Result<(), <B as Backend>::Error>
where F: FnOnce(&mut Buffer),

Insert some content before the current inline viewport. This has no effect when the viewport is not inline.

This is intended for inline UIs that want to print output (e.g. logs or status messages) above the UI without breaking it. See Viewport::Inline for how inline viewports are anchored.

The draw_fn closure will be called to draw into a writable Buffer that is height lines tall. The content of that Buffer will then be inserted before the viewport.

When Ratatui is built with the scrolling-regions feature, this can be done without clearing and redrawing the viewport. Without scrolling-regions, Ratatui falls back to a more portable approach and clears the viewport so the next Terminal::draw / Terminal::try_draw repaints it.

If the viewport isn’t yet at the bottom of the screen, inserted lines will push it towards the bottom. Once the viewport is at the bottom of the screen, inserted lines will scroll the area of the screen above the viewport upwards.

Before:

+---------------------+
| pre-existing line 1 |
| pre-existing line 2 |
+---------------------+
|       viewport      |
+---------------------+
|                     |
|                     |
+---------------------+

After inserting 2 lines:

+---------------------+
| pre-existing line 1 |
| pre-existing line 2 |
|   inserted line 1   |
|   inserted line 2   |
+---------------------+
|       viewport      |
+---------------------+
+---------------------+

After inserting 2 more lines:

+---------------------+
| pre-existing line 2 |
|   inserted line 1   |
|   inserted line 2   |
|   inserted line 3   |
|   inserted line 4   |
+---------------------+
|       viewport      |
+---------------------+

If more lines are inserted than there is space on the screen, then the top lines will go directly into the terminal’s scrollback buffer. At the limit, if the viewport takes up the whole screen, all lines will be inserted directly into the scrollback buffer.

§Examples
§Insert a single line before the current viewport
use ratatui::backend::{Backend, TestBackend};
use ratatui::layout::Position;
use ratatui::style::{Color, Style};
use ratatui::text::{Line, Span};
use ratatui::widgets::Widget;
use ratatui::{Terminal, TerminalOptions, Viewport};

let mut backend = TestBackend::new(10, 10);
// Simulate existing output above the inline UI.
backend.set_cursor_position(Position::new(0, 3))?;
let mut terminal = Terminal::with_options(
    backend,
    TerminalOptions {
        viewport: Viewport::Inline(4),
    },
)?;

terminal.insert_before(1, |buf| {
    Line::from(vec![
        Span::raw("This line will be added "),
        Span::styled("before", Style::default().fg(Color::Blue)),
        Span::raw(" the current viewport"),
    ])
    .render(buf.area, buf);
})?;
Source

pub fn draw<F>( &mut self, render_callback: F, ) -> Result<CompletedFrame<'_>, <B as Backend>::Error>
where F: FnOnce(&mut Frame<'_>),

Draws a single frame to the terminal.

Returns a CompletedFrame if successful, otherwise a backend error (B::Error).

If the render callback passed to this method can fail, use try_draw instead.

Applications should call draw or try_draw in a loop to continuously render the terminal. These methods are the main entry points for drawing to the terminal.

The Frame passed to the render callback represents the currently configured Viewport (see Frame::area and Terminal::with_options).

Build layout relative to the Rect returned by Frame::area rather than assuming the origin is (0, 0), so the same rendering code works for fixed and inline viewports.

This method will:

If any backend step fails, the error is returned immediately and later steps in the render pass are skipped.

The CompletedFrame returned by this method can be useful for debugging or testing purposes, but it is often not used in regular applications.

The render callback should fully render the entire frame when called, including areas that are unchanged from the previous frame. This is because each frame is compared to the previous frame to determine what has changed, and only the changes are written to the terminal. If the render callback does not fully render the frame, the terminal will not be in a consistent state.

§Examples
use ratatui::backend::TestBackend;
use ratatui::layout::Position;
use ratatui::{Frame, Terminal};

let backend = TestBackend::new(10, 10);
let mut terminal = Terminal::new(backend)?;

// With a closure.
terminal.draw(|frame| {
    let area = frame.area();
    frame.render_widget("Hello World!", area);
    frame.set_cursor_position(Position { x: 0, y: 0 });
})?;

// Or with a function.
terminal.draw(render)?;

fn render(frame: &mut Frame<'_>) {
    frame.render_widget("Hello World!", frame.area());
}
Source

pub fn try_draw<F, E>( &mut self, render_callback: F, ) -> Result<CompletedFrame<'_>, <B as Backend>::Error>
where F: FnOnce(&mut Frame<'_>) -> Result<(), E>, E: Into<<B as Backend>::Error>,

Tries to draw a single frame to the terminal.

Returns Result::Ok containing a CompletedFrame if successful, otherwise Result::Err containing the backend error (B::Error) that caused the failure.

This is the equivalent of Terminal::draw but the render callback is a function or closure that returns a Result instead of nothing.

Applications should call try_draw or draw in a loop to continuously render the terminal. These methods are the main entry points for drawing to the terminal.

The Frame passed to the render callback represents the currently configured Viewport (see Frame::area and Terminal::with_options).

Build layout relative to the Rect returned by Frame::area rather than assuming the origin is (0, 0), so the same rendering code works for fixed and inline viewports.

This method will:

If the render callback returns an error, Ratatui leaves the backend, buffers, cursor state, and frame count unchanged.

The render callback passed to try_draw can return any Result with an error type that can be converted into B::Error using the Into trait. This makes it possible to use the ? operator to propagate errors that occur during rendering. If the render callback returns an error, the error will be returned from try_draw and the terminal will not be updated.

The CompletedFrame returned by this method can be useful for debugging or testing purposes, but it is often not used in regular applications.

The render callback should fully render the entire frame when called, including areas that are unchanged from the previous frame. This is because each frame is compared to the previous frame to determine what has changed, and only the changes are written to the terminal. If the render function does not fully render the frame, the terminal will not be in a consistent state.

§Examples
use std::io;

use ratatui::backend::CrosstermBackend;
use ratatui::layout::Position;
use ratatui::{Frame, Terminal};

let backend = CrosstermBackend::new(std::io::stdout());
let mut terminal = Terminal::new(backend)?;

// With a closure that returns `Result`.
terminal.try_draw(|frame| -> io::Result<()> {
    let _value: u8 = "42".parse().map_err(io::Error::other)?;
    let area = frame.area();
    frame.render_widget("Hello World!", area);
    frame.set_cursor_position(Position { x: 0, y: 0 });
    Ok(())
})?;

// Or with a function.
terminal.try_draw(render)?;

fn render(frame: &mut Frame<'_>) -> io::Result<()> {
    frame.render_widget("Hello World!", frame.area());
    Ok(())
}
Source

pub fn apply_buffer( &mut self, ) -> Result<CompletedFrame<'_>, <B as Backend>::Error>

A low-level function that applies and flushes the current buffer to the backend.

This calls Terminal::apply_buffer_with_cursor with None, which hides the cursor.

§Examples
use std::io;

use ratatui::Terminal;
use ratatui::backend::CrosstermBackend;
use ratatui::buffer::Buffer;
use ratatui::widgets::Widget;

let backend = CrosstermBackend::new(io::stdout());
let mut terminal = Terminal::new(backend)?;

terminal.autoresize()?;

let mut custom_buffer = Buffer::default();
custom_buffer.resize(terminal.get_frame().area());
custom_buffer.reset();

"Hello World!".render(custom_buffer.area, &mut custom_buffer);

terminal.current_buffer_mut().merge(&custom_buffer);
terminal.apply_buffer()?;
Source

pub fn apply_buffer_with_cursor( &mut self, cursor_position: Option<Position>, ) -> Result<CompletedFrame<'_>, <B as Backend>::Error>

A low-level function that applies and flushes the current buffer to the backend and re-positions the cursor. This function is useful if you need to manage your own custom draw lifecycle and buffer.

Returns Result::Ok containing a CompletedFrame if successful, otherwise Result::Err containing the backend error (B::Error) that caused the failure.

This method will:

  • show/hide the cursor based on cursor_position (None will hide the cursor)
  • call Terminal::swap_buffers to prepare for the next render pass
  • call Backend::flush to flush any buffered backend output
  • return a CompletedFrame with the current buffer and the area used for rendering

The CompletedFrame returned by this method can be useful for debugging or testing purposes, but it is often not used in regular applications.

§Examples
use std::io;

use ratatui::Terminal;
use ratatui::backend::CrosstermBackend;
use ratatui::buffer::Buffer;
use ratatui::widgets::Widget;

let backend = CrosstermBackend::new(io::stdout());
let mut terminal = Terminal::new(backend)?;

terminal.autoresize()?;

let mut custom_buffer = Buffer::default();
custom_buffer.resize(terminal.get_frame().area());
custom_buffer.reset();

"Hello World!".render(custom_buffer.area, &mut custom_buffer);

terminal.current_buffer_mut().merge(&custom_buffer);
terminal.apply_buffer_with_cursor(None)?;
Source

pub fn resize(&mut self, area: Rect) -> Result<(), <B as Backend>::Error>

Updates the Terminal so that internal buffers match the requested area.

This updates the buffer size used for rendering and triggers a full clear so the next Terminal::draw / Terminal::try_draw paints into a consistent area.

When the viewport is Viewport::Inline, the area argument is treated as the new terminal size and the viewport origin is recomputed relative to the current cursor position. Ratatui attempts to keep the cursor at the same relative row within the viewport across resizes.

See also: Terminal::autoresize (automatic resizing during Terminal::draw / Terminal::try_draw).

For Viewport::Fixed and Viewport::Fullscreen, area becomes the new viewport area. For Viewport::Inline, area is interpreted as the backend’s new terminal size and the viewport origin may move to preserve the cursor’s relative row within the inline UI.

Source

pub fn autoresize(&mut self) -> Result<(), <B as Backend>::Error>

Queries the backend for size and resizes if it doesn’t match the previous size.

This is called automatically during Terminal::draw / Terminal::try_draw for fullscreen and inline viewports. Fixed viewports are not automatically resized.

If the size changed, this calls Terminal::resize and therefore clears the affected region before the next frame is rendered.

Trait Implementations§

Source§

impl Deref for Tui

Source§

type Target = Terminal<CrosstermBackend<Stdout>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Tui

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Drop for Tui

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 Freeze for Tui

§

impl RefUnwindSafe for Tui

§

impl Send for Tui

§

impl Sync for Tui

§

impl Unpin for Tui

§

impl UnsafeUnpin for Tui

§

impl UnwindSafe for Tui

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more