Expand description
Screen — the cell-diff renderer you draw into.
Screen<W> owns a desired cell grid, a diff renderer, and a writer. You
paint cells into it and call render; it works out the
minimal escape sequence that turns what the terminal is showing into what
you asked for, and writes it.
That is the whole job. Screen reads no input, tracks no capabilities,
and manages no session — Program does all of
that and owns a Screen to render with. A Screen on its own is enough
for output-only programs, tests, and offscreen rendering, since W is any
Write: a terminal handle, a Vec<u8>, a file.
use uncurses::screen::Screen;
use uncurses::style::Style;
use uncurses::text::TextSurface;
let mut screen = Screen::new(Vec::new(), (20, 3));
screen.set_str((0, 0), "hello", Style::default());
screen.render()?;
assert!(!screen.writer().is_empty());§Render properties
A Screen holds only the state that changes how a frame is drawn:
fullscreen— whether the managed area is the whole viewport (the alternate screen buffer, addressed with absolute moves) or a band in the normal buffer (the default, addressed relatively so scrollback above and the shell prompt below survive).- Cursor visibility and the declarative resting position.
- Synchronized output, grapheme-cluster width mode, the color profile, and the renderer optimizations.
Every one of these is a plain setter: it cannot fail and it writes nothing.
A Screen never persists a terminal mode: the only modes it emits are
the synchronized-output and cursor-visibility markers it wraps a single
frame in, and it closes both before render returns.
Leaving a mode on is
Program’s job, and it pushes the render
consequence down here with the matching setter — so
Program::enter_alt_screen
emits DECSET 1049 and calls set_fullscreen, and
Program::hide_cursor emits DECTCEM
and calls set_cursor_visible. Drive a
Screen yourself and you own both halves.
Inline (default): the surface lives in the normal buffer, only as
many rows as you draw; scrollback and the shell prompt stay intact.
$ earlier shell output
$ ... scrollback ...
┌─────────────────────────┐
│ managed surface │ <- only the rows you draw, full width
└─────────────────────────┘
$ shell prompt resumes
Fullscreen: the whole viewport is the surface, addressed with
absolute moves, and restored on exit.
┌─────────────────────────────┐
│ │
│ the whole terminal │
│ viewport is the surface │
│ │
└─────────────────────────────┘Structs§
- Optimizations
- Cell-diff capability flags controlling which optimized escape
sequences the screen’s renderer may emit. Re-exported from the
renderer so applications can configure rendering with
Screen::set_optimizationswithout depending on renderer internals. Terminal capabilities the renderer may use for shorter output. - Screen
- A cell-diff renderer over a writer. See the module documentation.