Skip to main content

try_init

Function try_init 

Source
pub fn try_init() -> Result<DefaultTerminal>
Expand description

Initialize a fullscreen terminal over process stdio.

This uses try_init_with_options with [Viewport::Fullscreen] and ScreenOptions::default. Setup constructs an UncursesBackend over stdio, initializes its screen, enters the alternate screen, hides the cursor, records the fullscreen viewport, and builds the returned [Terminal].

§Returns

A ready-to-draw DefaultTerminal.

§Errors

Returns any error from opening or configuring stdio, entering raw mode, applying screen setup, entering the alternate screen, hiding the cursor, or constructing the [Terminal].

§Panics

Does not intentionally panic. A poisoned internal event-source lock inside lower-level input code would still panic if encountered during later use.

§Usage note

This function installs no panic hook. Teardown state lives inside the returned terminal, so install your own hook if the application needs best-effort restoration after panic. Pair normal exits with try_restore or restore.