Skip to main content

try_init_with_options

Function try_init_with_options 

Source
pub fn try_init_with_options(
    options: TerminalOptions,
    screen_options: ScreenOptions,
) -> Result<DefaultTerminal>
Expand description

Initialize a terminal with explicit terminal and screen options.

Setup creates an UncursesBackend over process stdio, calls UncursesBackend::init_with with screen_options, conditionally enters the alternate screen, hides the cursor, records options.viewport in the backend, and finally calls [Terminal::with_options].

§Parameters

  • options - terminal options from the widget library. The viewport is cloned before constructing the [Terminal] so the backend can mirror the same viewport behavior.
  • screen_options - screen defaults controlling bracketed paste, keyboard enhancements, mouse tracking, in-band resize preference, and pixel-size behavior.

§Returns

A ready-to-draw DefaultTerminal.

§Errors

Returns any error from opening stdio, screen initialization, alternate screen entry, cursor hiding, or [Terminal::with_options].

§Panics

Does not intentionally panic.

§Usage note

[Viewport::Inline] stays on the main screen; all other viewports enter the alternate screen before the terminal is returned. Always restore with try_restore or restore after a successful setup.