[go: up one dir, main page]

Function restore

Source
pub fn restore()
Available on crate feature crossterm only.
Expand description

Restores the terminal to its original state.

This function should be called before the program exits to ensure that the terminal is restored to its original state.

This function will attempt to restore the terminal to its original state by performing the following steps:

  1. Raw mode is disabled.
  2. The alternate screen buffer is left.

If either of these steps fail, the error is printed to stderr and ignored.

Use this function over try_restore when you don’t need to handle the error yourself, as ignoring the error is generally the correct behavior when cleaning up before exiting. If you need to handle the error yourself, use try_restore instead.

§Examples

ratatui::restore();
Examples found in repository?
examples/block.rs (line 30)
26fn main() -> Result<()> {
27    color_eyre::install()?;
28    let terminal = ratatui::init();
29    let result = run(terminal);
30    ratatui::restore();
31    result
32}
More examples
Hide additional examples
examples/calendar.rs (line 30)
26fn main() -> Result<()> {
27    color_eyre::install()?;
28    let terminal = ratatui::init();
29    let result = run(terminal);
30    ratatui::restore();
31    result
32}
examples/widget_impl.rs (line 35)
31fn main() -> Result<()> {
32    color_eyre::install()?;
33    let terminal = ratatui::init();
34    let result = App::default().run(terminal);
35    ratatui::restore();
36    result
37}
examples/barchart-grouped.rs (line 32)
28fn main() -> Result<()> {
29    color_eyre::install()?;
30    let terminal = ratatui::init();
31    let app_result = App::new().run(terminal);
32    ratatui::restore();
33    app_result
34}
examples/barchart.rs (line 31)
27fn main() -> Result<()> {
28    color_eyre::install()?;
29    let terminal = ratatui::init();
30    let app_result = App::new().run(terminal);
31    ratatui::restore();
32    app_result
33}
examples/chart.rs (line 33)
29fn main() -> Result<()> {
30    color_eyre::install()?;
31    let terminal = ratatui::init();
32    let app_result = App::new().run(terminal);
33    ratatui::restore();
34    app_result
35}