pub fn init() -> DefaultTerminal
Expand description
Initialize a terminal with reasonable defaults for most applications.
This will create a new DefaultTerminal
and initialize it with the following defaults:
- Backend:
CrosstermBackend
writing toStdout
- Raw mode is enabled
- Alternate screen buffer enabled
- A panic hook is installed that restores the terminal before panicking. Ensure that this method is called after any other panic hooks that may be installed to ensure that the terminal is restored before those hooks are called.
For more control over the terminal initialization, use Terminal::new
or
Terminal::with_options
.
Ensure that this method is called after your app installs any other panic hooks to ensure the terminal is restored before the other hooks are called.
Generally, use this function instead of try_init
to ensure that the terminal is restored
correctly if any of the initialization steps fail. If you need to handle the error yourself, use
try_init
instead.
§Panics
This function will panic if any of the following steps fail:
- Enabling raw mode
- Entering the alternate screen buffer
- Creating the terminal fails due to being unable to calculate the terminal size
§Examples
let terminal = ratatui::init();