Skip to main content

resize_terminal

Function resize_terminal 

Source
pub fn resize_terminal(
    term: &mut Terminal<TerminalWasm>,
    width: u16,
    height: u16,
)
Expand description

Resizes term to (width, height) cells, doing everything a correct resize needs in one call.

That’s Terminal::resize (which itself resizes both grid buffers and calls Output::resize on the backend), plus queuing the matching Event::Resize so a driven App observes the new size through its own input handling too, exactly as it would from a native backend’s real resize event.

Calling term.resize(width, height) directly (skipping this function) leaves nothing in the input queue: an app that reacts to Event::Resize rather than re-checking term.backend().size() every frame silently keeps its old layout. app_entry! already calls this on every wasm_app_resize; reach for it directly only when driving a Terminal<TerminalWasm> by hand instead of through that macro. See retroglyph#684.

§Examples

use retroglyph_core::terminal::Terminal;
use retroglyph_core::backend::Output as _;
use retroglyph_core::event::Event;
use retroglyph_terminal_wasm::{TerminalWasm, resize_terminal};

let mut term = Terminal::new(TerminalWasm::new(10, 3));
resize_terminal(&mut term, 20, 6);

assert_eq!(term.backend().size(), retroglyph_core::grid::Size::new(20, 6));
assert_eq!(term.poll(std::time::Duration::ZERO), Some(Event::Resize(20, 6)));