Skip to main content

Screen

Struct Screen 

Source
pub struct Screen<I, O>
where I: Input, O: Write,
{ /* private fields */ }
Expand description

A self-managing terminal application facade composing a Terminal, a cell-diff renderer, and an EventSource with the non-render terminal and input modes. See the module documentation for the lifecycle.

Screen is Send and Sync whenever its input and output handles are, so it can be moved onto another thread or held across an .await point in a multi-threaded async runtime.

Implementations§

Source§

impl<I: Input, O: Write> Screen<I, O>

Source

pub fn set_cursor_style( &mut self, shape: CursorShape, blinking: bool, ) -> Result<()>

Set the cursor shape and blinking state (DECSCUSR) and flush.

  • shape — the visual cursor shape (Block, Underline, or Bar).
  • blinking — whether the cursor blinks.
Source

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

Ring the terminal bell (BEL) and flush.

Source

pub fn set_pointer_shape(&mut self, shape: &str) -> Result<()>

Set the pointer (mouse cursor) shape (OSC 22) and flush.

shape is a pointer shape name such as "default", "text", or "pointer". The shape is recorded for save/restore.

Source

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

Reset the pointer (mouse cursor) shape to the terminal default (OSC 22 ; default) and flush.

Uses the explicit "default" shape name rather than an empty one: some terminals don’t treat an empty OSC 22 as a reset.

Source

pub fn enable_mouse(&mut self, tracking: MouseTracking) -> Result<()>

Enable mouse tracking and flush.

This emits exactly what is asked for and does not consult terminal capabilities. Unsupported modes are ignored by the terminal, and because the mode requests are mutually exclusive, each terminal settles on the most capable variant it understands:

  • Tracking: button (1000) and button-event (1002) are always requested, so a terminal reports drag where it can and plain clicks otherwise. With MouseTracking::MOTION, any-event tracking (1003) is added on top, so motion without a button held is reported where supported.
  • Encoding: SGR (1006) is always requested, since the legacy byte encoding caps coordinates at 223 and SGR is universally supported. With MouseTracking::PIXELS, SGR-pixel (1016) is added; terminals that support it report pixel coordinates, and the rest fall back to SGR cell coordinates.

Pass MouseTracking::empty() for basic button tracking with no extras. To turn mouse tracking off, call disable_mouse.

To learn which variant a terminal actually chose, read capabilities (for example mouse_sgr_pixel to tell whether pixels or cells will arrive). When pixel reporting is active, a Mouse event’s pixel coordinates can be converted to cells with mouse_pixels_to_cells.

The request is recorded for save/restore.

Source

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

Disable all mouse tracking modes and encodings, and flush.

Source

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

Enable bracketed paste mode (DEC private mode 2004) and flush.

Source

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

Disable bracketed paste mode (DEC private mode 2004) and flush.

Source

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

Enable focus in/out reporting (DEC private mode 1004) and flush.

Source

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

Disable focus in/out reporting (DEC private mode 1004) and flush.

Source

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

Enable color-scheme update notifications (DEC private mode 2031) and flush. The terminal then sends a CSI ? 997 ; {1|2} n report whenever the user or operating system switches between dark and light schemes; these surface as Event::ColorScheme. The report indicates only the dark/light preference, not the actual colors.

Source

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

Disable color-scheme update notifications (DEC private mode 2031) and flush.

Source

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

Enable in-band resize notifications (DEC private mode 2048) and flush. The terminal then reports every surface size change in-band as a CSI 48 ; height ; width ; ypixel ; xpixel t sequence, which the decoder surfaces as Event::Resize — no SIGWINCH handler required.

Source

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

Disable in-band resize notifications (DEC private mode 2048) and flush.

Source

pub fn set_title(&mut self, title: &str) -> Result<()>

Set both the window title and icon name (OSC 0) and flush.

An empty title clears both overrides, restoring the terminal’s defaults; the state is recorded as unset so teardown and resume skip them. To set just one, use set_window_title (OSC 2) or set_icon_title (OSC 1).

Source

pub fn set_window_title(&mut self, title: &str) -> Result<()>

Set the window title only (OSC 2) and flush.

An empty title clears the override, restoring the terminal’s default window title. Unlike set_title (OSC 0), this leaves the icon name untouched.

Source

pub fn set_icon_title(&mut self, title: &str) -> Result<()>

Set the icon name only (OSC 1) and flush.

An empty title clears the override, restoring the terminal’s default icon name. Unlike set_title (OSC 0), this leaves the window title untouched.

Source

pub fn set_modify_other_keys(&mut self, mode: ModifyOtherKeysMode) -> Result<()>

Set the xterm modifyOtherKeys mode (CSI > 4 ; n m) and flush. Passing ModifyOtherKeysMode::Disabled resets it (CSI > 4 m). The mode is recorded so Screen::finish can reset it and Screen::resume re-apply it.

Source

pub fn set_foreground_color(&mut self, color: Color) -> Result<()>

Set the default foreground color (OSC 10) and flush. The color is converted to 24-bit RGB and emitted as rgb:RRRR/GGGG/BBBB, and is recorded so Screen::finish can restore the terminal default and Screen::resume can re-apply it.

Source

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

Restore the terminal’s default foreground color (OSC 110) and flush.

Source

pub fn set_background_color(&mut self, color: Color) -> Result<()>

Set the default background color (OSC 11) and flush. See set_foreground_color for state-tracking semantics.

Source

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

Restore the terminal’s default background color (OSC 111) and flush.

Source

pub fn set_cursor_color(&mut self, color: Color) -> Result<()>

Set the cursor color (OSC 12) and flush. See set_foreground_color for state-tracking semantics.

Source

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

Restore the terminal’s default cursor color (OSC 112) and flush.

Source

pub fn set_palette_color(&mut self, index: u8, color: Color) -> Result<()>

Set a terminal palette color by index (OSC 4) and flush. The override is tracked so Screen::finish can restore it and Screen::resume re-apply it.

Source

pub fn reset_palette_color(&mut self, index: u8) -> Result<()>

Reset a single terminal palette color to its default (OSC 104 ; index) and flush.

Source

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

Reset the entire terminal palette to its defaults (OSC 104) and flush, clearing every tracked palette override.

Source

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

Request the window size in pixels (XTWINOPS CSI 14 t). Reply: Event::WindowPixelSize.

Source

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

Request the character cell size in pixels (XTWINOPS CSI 16 t). Reply: Event::CellPixelSize.

Source

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

Request the terminal’s active Kitty keyboard flags (CSI ? u). The reply is recorded in capabilities.

Source

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

Request the terminal’s modifyOtherKeys state (CSI ? 4 m). The reply is recorded in capabilities.

Source

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

Request the default foreground color (OSC 10 ; ? ST). Reply: Event::ForegroundColor.

Source

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

Request the default background color (OSC 11 ; ? ST). Reply: Event::BackgroundColor.

Source

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

Request the cursor color (OSC 12 ; ? ST). Reply: Event::CursorColor.

Source

pub fn request_palette_color(&mut self, index: u8) -> Result<()>

Request a terminal palette color by index (OSC 4 ; index ; ? ST). Reply: OSC 4 ; index ; rgb:... ST.

Source

pub fn request_mode(&mut self, mode: Mode) -> Result<()>

Request a terminal mode’s current setting (DECRQM). Reply: Event::ModeReport.

The reply’s ModeSetting reports whether the mode is set, reset, or permanently fixed. A permanently reset mode is recognized but can never be enabled, so check ModeSetting::is_available before relying on it.

Source

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

Request the cursor position (CSI 6 n). Reply: Event::CursorPosition.

Source

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

Request the current color scheme (CSI ? 996 n): whether the terminal’s scheme is dark or light. This reports only the dark/light preference, not the actual colors. Reply: Event::ColorScheme.

Source

pub fn set_system_clipboard(&mut self, data: &[u8]) -> Result<()>

Set the system clipboard contents (OSC 52 ; c). data is base64-encoded for transport.

Source

pub fn set_primary_clipboard(&mut self, data: &[u8]) -> Result<()>

Set the primary selection contents (OSC 52 ; p). data is base64-encoded for transport.

Source

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

Request the system clipboard contents (OSC 52 ; c ; ?). Reply: Event::Clipboard.

Source

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

Request the primary selection contents (OSC 52 ; p ; ?). Reply: Event::Clipboard.

Source§

impl<I, O> Screen<I, O>
where I: Input, O: Write,

Source

pub fn set_cell(&mut self, pos: impl Into<Position>, cell: &Cell)

Write cell at pos in the desired frame.

Source

pub fn cell_mut(&mut self, pos: impl Into<Position>) -> Option<&mut Cell>

Borrow the cell at pos mutably, marking its columns touched.

Source

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

Diff the staged frame against the tracked terminal, stage the minimal escape bytes, and flush them through the terminal.

When a declarative cursor rest position has been staged with set_cursor_position, the cursor is moved there at the end of the frame, inside the same hide/synchronized-output bracket as the cell diff, so it lands atomically and without flicker.

Source

pub fn invalidate(&mut self)

Force a full redraw on the next render.

Source

pub fn resize(&mut self, size: impl Into<Size>)

Resize the managed area. In fullscreen pass the terminal viewport size; inline, the terminal width and the application surface height.

Source

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

Insert content into the scrollback above the managed area and flush it to the terminal. In inline mode this pushes the lines into the terminal’s scrollback; in alternate-screen mode they go into the alt screen’s hidden scrollback. The managed area is preserved in place, so no redraw is needed and a following render sees no change. An empty string is a no-op.

§Errors

Returns any error from flushing the inserted lines to the terminal.

Source

pub fn size(&self) -> Size

The managed area size in cells.

Source

pub fn move_cursor_to(&mut self, pos: impl Into<Position>) -> Result<()>

Immediately move the terminal cursor to a buffer-relative position and flush. No-op when the renderer already reports the cursor there with both axes known.

This is imperative: the move is emitted and flushed now, independent of render. It does not affect the declarative resting position staged with set_cursor_position; a subsequent render will snap the cursor back to that sticky position if one is set. To change where frames leave the cursor, use set_cursor_position instead.

Source

pub fn move_cursor_by(&mut self, dx: i16, dy: i16) -> Result<()>

Immediately move the terminal cursor relative to the tracked cursor and flush.

Convenience over move_cursor_to: the target is the tracked cursor offset by (dx, dy), saturating at the buffer origin. Like move_cursor_to, it does not clamp to the right or bottom edge. An unknown tracked cursor is treated as the origin.

Source

pub fn set_cursor_position(&mut self, pos: impl Into<Position>)

Stage a declarative resting position for the cursor, applied at the end of every render.

This is the cursor analogue of set_cell: it stages intent rather than emitting now. render leaves the terminal cursor at the buffer-relative pos after each frame’s cell diff. Call clear_cursor_position to stop steering it and leave the cursor wherever the diff ended.

The position is sticky — it persists across frames and is re-applied on every render (cheaply, as a no-op when the cursor is already there) until you change or clear it. An app whose cursor follows content (e.g. a text field) should call this each time that content moves.

Cursor visibility is orthogonal: this never shows or hides the cursor. Use show_cursor / hide_cursor for that. A position outside the managed area is clamped to its edges.

The argument is anything that converts into a Position, so a bare (x, y) works:

let mut screen = uncurses::screen::Screen::open()?;
screen.set_cursor_position((4, 0)); // stage
screen.clear_cursor_position();      // stop steering it
Source

pub fn clear_cursor_position(&mut self)

Clear the staged cursor resting position, leaving the cursor wherever each frame’s cell diff ends.

Source

pub fn tracked_cursor(&self) -> Option<Position>

The renderer’s tracked cursor: the buffer-relative cell where the renderer believes the terminal cursor currently sits, or None when that position is unknown (initially, after a screen reset, or after invalidate_tracked_cursor). This is bookkeeping, not a live cursor-position query.

Source

pub fn invalidate_tracked_cursor(&mut self)

Mark the tracked cursor position unknown, so the next staged move always emits rather than short-circuiting on a matching tracked position. Use after moving the terminal cursor by a means the renderer cannot see (e.g. a raw escape written directly).

Source

pub fn set_tracked_cursor(&mut self, pos: impl Into<Position>)

Set the tracked cursor to buffer-relative pos, with both axes known, without emitting any move. This only updates the renderer’s belief; the caller must have already placed the terminal cursor there (e.g. with a raw escape the renderer cannot see). For an actual cursor move use move_cursor_to.

Source

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

Enter the alternate screen and flush.

Source

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

Leave the alternate screen and flush.

Source

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

Show the cursor and flush.

Source

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

Hide the cursor and flush.

Source

pub fn set_synchronized_output(&mut self, enabled: bool)

Enable or disable synchronized-output frame wrapping.

When enabled, each non-empty render is wrapped in begin/end synchronized-output sequences (DEC mode 2026) so terminals that support it present the frame atomically, with no mid-frame repaint. Terminals that don’t support 2026 ignore the markers.

This is your switch to flip: uncurses does not second-guess it against detected capabilities. It is enabled automatically when the terminal reports 2026 support during init, and you can override that here at any time.

Enabling it also changes how the cursor is handled per frame. With sync off, a visible cursor is hidden around the cell diff so it doesn’t dance across cells as the renderer repositions it. With sync on, the frame is presented in one step, so that hide/show pair is dropped: it is redundant, and toggling the cursor every frame resets its blink phase, which reads as flicker.

This only sets state; the markers are emitted on the next render.

Source

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

Enable Unicode core / grapheme-cluster mode (DECSET 2027) and flush: set_str and insert_above measure cell widths per extended grapheme cluster (UTS-29 plus emoji presentation rules).

Source

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

Disable grapheme-cluster mode (DECRST 2027) and flush, falling back to per-code-point wcwidth-style measurement.

Source

pub fn set_kitty_keyboard( &mut self, flags: Option<KittyKeyboardFlags>, ) -> Result<()>

Set the per-screen kitty keyboard enhancements and flush. Some(flags) enables the selected progressive-enhancement bits; None disables every enhancement.

Source

pub fn set_color_profile(&mut self, profile: Profile)

Set the color profile used when emitting styled cells.

Source

pub fn color_profile(&self) -> Profile

Return the color profile used when emitting styled cells.

This is the profile the renderer downsamples colors to, set by set_color_profile or detected from the environment when the screen was constructed. Pass it to Encode::encode_with to serialize a surface the same way this screen renders it.

Source

pub fn set_optimizations(&mut self, optimizations: Optimizations)

Set the renderer optimization flags.

Source

pub fn optimizations(&self) -> Optimizations

Return the renderer optimization flags currently in effect.

Source

pub fn grapheme_clusters(&self) -> bool

Return whether Unicode core / grapheme-cluster mode (DEC 2027) is active. When true, text is measured per extended grapheme cluster; when false, per code point (wcwidth-style).

Source

pub fn poll_event(&self, timeout: Option<Duration>) -> Result<bool>

Drive the input source for up to timeout, returning whether any event became available. A pure readiness wait: no capability tracking. See EventSource::poll.

Source

pub fn try_read_event(&self) -> Option<Event>

Take the next queued event without doing I/O. A pure read: pass the event to observe_event to keep capability tracking alive. See EventSource::try_read.

Source

pub fn read_event(&self) -> Result<Event>

Block until the next event. A pure read: pass the event to observe_event to keep capability tracking alive. See EventSource::read.

Source

pub fn unread_event(&self, event: Event)

Return an event to the front of the input queue, so the next read_event / try_read_event yields it before anything already queued. See EventSource::unread.

Source

pub fn event_source(&self) -> Arc<Mutex<EventSource<I>>>

A shared handle to the input source behind read_event and friends, for driving input from a separate reader over the same decoder rather than a second one racing the same file descriptor.

The main use is async input: build an EventStream with EventStream::from_shared from this handle and poll it on your executor. Like every read path, it is pure — feed each event back through observe_event to keep capability tracking alive.

Sharing one source between a live reader and the screen’s own read_event is best-effort: an event goes to whichever consumer drains it first, so pick one reader in steady state.

Source

pub fn event_stream(&self) -> EventStream<I>
where I: 'static,

Build an async EventStream over this screen’s input, for reading events with events.next().await inside a select! on any executor. The stream shares the screen’s decoder, so it does not race a second reader on the same file descriptor.

Reads are pure: feed each event to observe_event to keep capability tracking alive, exactly as the sync path does. Read through the stream or through read_event in steady state, not both at once: a shared source hands each event to whichever consumer drains it first.

Source

pub fn capabilities(&self) -> Capabilities

Terminal capabilities detected so far from intercepted query replies. Populated as the relevant reports arrive through the event delegates after Self::init.

Source

pub fn window_cells(&self) -> Option<Size>

Last observed full terminal size in cells, cached from resize and WindowCellSize reports as they flow through the event delegates. None until one has been observed.

Source

pub fn window_pixels(&self) -> Option<Size>

Last observed full terminal size in pixels, cached from resize (when it carries pixel dimensions) and from request_window_pixel_size replies. None until one has been observed.

Source

pub fn terminal_name(&self) -> Option<&str>

The raw XTVERSION reply identifying the terminal (e.g. "XTerm(380)"). None until the reply has been observed.

Source

pub fn mouse_pixels_to_cells(&self, mouse: Mouse) -> Option<Mouse>

Convert a Mouse event reported in pixel coordinates (SGR-pixel encoding) to cell coordinates using the cached terminal size. Returns None when the window pixel size has not been observed yet, so no conversion is possible — request it with request_window_pixel_size, or rely on an in-band resize report to populate it.

Source

pub fn observe_event(&mut self, event: &Event) -> Result<()>

Apply an event to the screen’s capability tracking. The event is inspected, never consumed.

Reads are pure: read_event, try_read_event, and the async event_stream all hand back events without tracking capabilities. Pass every event you receive here — on both the sync and async paths — so capability detection stays alive.

Capability-report replies to the queries init fires are recorded into capabilities, window-size reports update window_cells / window_pixels, and the render-affecting reports are applied. On the terminating Primary DA reply, the discovery-driven defaults from the active ScreenOptions are applied once (enabling mouse, keyboard enhancements, and in-band resize as configured), which may emit escapes to the terminal.

// Sync loop: read, observe, handle, render.
loop {
    let ev = screen.read_event()?;
    screen.observe_event(&ev)?; // keep capability tracking alive
    // ... handle ev ...
    screen.render()?;
}
// Async loop: same contract over an EventStream.
use tokio_stream::StreamExt;

let mut events = screen.event_stream();
while let Some(ev) = events.next().await {
    let ev = ev?;
    screen.observe_event(&ev)?; // keep capability tracking alive
    // ... handle ev ...
    screen.render()?;
}
Source§

impl<I, O> Screen<I, O>
where I: Input + Copy + AsFd, O: Write + Copy + AsFd,

Source

pub fn new(terminal: Terminal<I, O>) -> Result<Self>

Construct a screen over terminal without touching the terminal: size the renderer to it and create an EventSource on its input half. The terminal is left as-is; call Self::init to enter raw mode and begin a session.

Source

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

Begin a session with the default ScreenOptions. See Self::init_with.

Source

pub fn init_with(&mut self, options: ScreenOptions) -> Result<()>

Begin a session: enter raw mode, apply the always-on defaults from options, and send the capability queries whose replies the event loop consumes. Discovery-driven defaults are applied later, once the terminating Primary DA reply confirms the detected capabilities (see Self::capabilities). Call once after Self::new, before rendering.

Source

pub fn get_window_size(&self) -> Result<Winsize>

Query the current terminal window size (output half first, input as fallback). This is a live query; the cached window_cells / window_pixels accessors return the last-observed values without I/O.

Source

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

Re-query the terminal size and resize the managed area to fit: the full terminal size in fullscreen (alternate screen on), or the terminal width with the current managed height preserved inline (alternate screen off). Refreshes the cached window_cells / window_pixels; on platforms whose size query reports no pixel size (e.g. the Windows console) the pixel size is requested over the wire.

Source

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

Consume the screen and hand the terminal back to the shell: tear down every staged mode, reset the managed area, flush, and restore the terminal’s prior state.

Source

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

Hand the terminal back to the shell without consuming the screen, e.g. to run a child process. Re-enter with Self::resume. Like Self::finish but keeps the screen so the session can continue.

Source

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

Re-acquire the terminal after a Self::pause or Self::suspend: re-enter raw mode, refit the managed area to the current viewport, re-apply the saved render state and modes, and force a full repaint.

Source

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

Suspend the process: pause the screen, then stop the process with SIGTSTP. Returns once the process is foregrounded again; the caller should then call Self::resume.

Source§

impl Screen<Stdin, Stdout>

Source

pub fn stdio() -> Result<Self>

Build a screen over the process stdio (stdin + stdout).

Source§

impl Screen<TtyInput, TtyOutput>

Source

pub fn open() -> Result<Self>

Build a screen over the controlling terminal (/dev/tty, or CONIN$/CONOUT$ on Windows), useful when stdio is redirected.

Trait Implementations§

Source§

impl<I, O> Bounded for Screen<I, O>
where I: Input, O: Write,

Source§

fn bounds(&self) -> Rect

Return the valid region in this value’s own coordinate space. Read more
Source§

fn width(&self) -> u16

Return the width of Self::bounds in terminal cell columns. Read more
Source§

fn height(&self) -> u16

Return the height of Self::bounds in terminal cell rows. Read more
Source§

fn contains(&self, pos: Position) -> bool

Test whether a position lies inside Self::bounds. Read more
Source§

impl<I, O> Surface for Screen<I, O>
where I: Input, O: Write,

Source§

fn cell(&self, pos: Position) -> Option<&Cell>

Read the cell at a position. Read more
Source§

fn draw<T: SurfaceMut + ?Sized>(&self, target: &mut T, at: Position)

Copy self’s cells into target, mapping the top-left of self.bounds() to at in target coordinates. Read more
Source§

impl<I, O> SurfaceMut for Screen<I, O>
where I: Input, O: Write,

Source§

fn set_cell(&mut self, pos: Position, cell: &Cell)

Place cell at pos. Implementations are responsible for wide-cell semantics (continuation markers, blanking covered cells) and any dirty tracking they care to do. Taking &Cell lets implementations skip the clone when the destination already matches. Read more
Source§

fn cell_mut(&mut self, pos: Position) -> Option<&mut Cell>

Mutable handle to the cell at pos. Returns None for out-of-bounds positions. Read more
Source§

fn insert_lines(&mut self, y: u16, n: u16, bounds_bottom: u16, fill: &Cell)

Insert n blank rows at y, pushing existing rows down within [y, bounds_bottom). Rows pushed past bounds_bottom are lost. Freed top rows are filled with fill. Read more
Source§

fn delete_lines(&mut self, y: u16, n: u16, bounds_bottom: u16, fill: &Cell)

Delete n rows at y, pulling existing rows up within [y, bounds_bottom). The bottom n rows of the window are filled with fill. Read more
Source§

fn insert_cells( &mut self, pos: Position, n: u16, bounds_right: u16, fill: &Cell, )

Insert n blank cells at pos, pushing cells in [pos.x, bounds_right) right within row pos.y. Cells pushed past bounds_right are lost. The freed slots [pos.x, pos.x + n) are filled with fill. Read more
Source§

fn delete_cells( &mut self, pos: Position, n: u16, bounds_right: u16, fill: &Cell, )

Delete n cells at pos, pulling cells in [pos.x + n, bounds_right) left within row pos.y. The freed slots [bounds_right - n, bounds_right) are filled with fill. Read more
Source§

fn fill(&mut self, cell: &Cell)

Fill the entire surface bounds with cell. Read more
Source§

fn fill_rect(&mut self, rect: Rect, cell: &Cell)

Fill the intersection of rect and Bounded::bounds with cell. Read more
Source§

fn clear(&mut self)

Clear the entire surface bounds to Cell::BLANK. Read more
Source§

fn clear_rect(&mut self, rect: Rect)

Clear a rectangle to Cell::BLANK. Read more
Source§

impl<I, O> TextSurface for Screen<I, O>
where I: Input, O: Write,

Source§

fn width_mode(&self) -> WidthMode

Return the width-measurement mode used when shaping strings. Read more
Source§

fn eaw_wide(&self) -> bool

Return the East-Asian Ambiguous width policy for this surface. Read more
Source§

fn set_str( &mut self, pos: impl Into<Position>, s: &str, style: impl Into<Style>, ) -> Position

Paint s at pos, clipped to the surface bounds. Read more
Source§

fn set_str_wrap( &mut self, pos: impl Into<Position>, s: &str, wrap: WrapMode, style: impl Into<Style>, ) -> Position

Paint s at pos with an explicit right-edge behavior. Read more
Source§

fn set_str_rect( &mut self, rect: impl Into<Rect>, s: &str, style: impl Into<Style>, ) -> Position

Paint s inside rect, clipped to the surface bounds. Read more
Source§

fn set_str_rect_wrap( &mut self, rect: impl Into<Rect>, s: &str, wrap: WrapMode, style: impl Into<Style>, ) -> Position

Paint s inside rect with an explicit right-edge behavior. Read more
Source§

fn set_str_truncate( &mut self, pos: impl Into<Position>, s: &str, tail: &str, tail_style: impl Into<Style>, ) -> Position

Paint s at pos, truncating with a tail indicator on overflow. Read more
Source§

fn set_str_rect_truncate( &mut self, rect: impl Into<Rect>, s: &str, tail: &str, tail_style: impl Into<Style>, ) -> Position

Paint s inside rect, truncating with a tail indicator on overflow. Read more
Source§

fn str_width(&self, s: &str) -> u16

Measure the display width of s in terminal columns. Read more
Source§

fn grapheme_width(&self, g: &str) -> u8

Measure one extended grapheme cluster in cells under this surface’s width mode and East-Asian Ambiguous policy. Read more
Source§

fn grapheme_cells<'a>(&self, s: &'a str) -> impl Iterator<Item = (&'a str, u8)>

Iterate s as (cluster, width) pairs under this surface’s width mode and East-Asian Ambiguous policy. Read more
Source§

impl<I, O> Write for Screen<I, O>
where I: Input, O: Write,

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Append raw bytes to the staging buffer, ordered with any staged mode or frame bytes. They reach the terminal on the next flush.

Source§

fn flush(&mut self) -> Result<()>

Drain the staging buffer through the terminal and flush it.

1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

§

impl<I, O> Freeze for Screen<I, O>
where I: Freeze, O: Freeze,

§

impl<I, O> RefUnwindSafe for Screen<I, O>

§

impl<I, O> Send for Screen<I, O>
where O: Send,

§

impl<I, O> Sync for Screen<I, O>
where I: Sync, O: Sync,

§

impl<I, O> Unpin for Screen<I, O>
where I: Unpin, O: Unpin,

§

impl<I, O> UnsafeUnpin for Screen<I, O>
where I: UnsafeUnpin, O: UnsafeUnpin,

§

impl<I, O> UnwindSafe for Screen<I, O>
where I: UnwindSafe, O: UnwindSafe,

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<S> Encode for S
where S: Surface + ?Sized,

Source§

fn encode<W: Write>(&self, w: &mut W) -> Result<()>

Write the surface to w as escape sequences and text. Read more
Source§

fn encode_with<W: Write>(&self, w: &mut W, profile: Profile) -> Result<()>

Write the surface to w, downsampling colors to profile. Read more
Source§

fn display(&self) -> SurfaceDisplay<'_, Self>

Borrow the surface as a Display adapter. Read more
Source§

fn display_with(&self, profile: Profile) -> SurfaceDisplay<'_, Self>

Borrow the surface as a Display adapter that downsamples colors to profile. 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.
§

impl<T> ErasedDestructor for T
where T: 'static,