mirror of
https://github.com/ratatui/ratatui.git
synced 2025-09-27 13:01:13 +00:00
docs(terminal): add disclaimer about panics to Terminal::new (#2088)
<!-- Please read CONTRIBUTING.md before submitting any pull request. --> part of #2087 cc @orhun --------- Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
This commit is contained in:
parent
881d2452e0
commit
b08b4cbd5e
@ -128,6 +128,15 @@ where
|
|||||||
{
|
{
|
||||||
/// Creates a new [`Terminal`] with the given [`Backend`] with a full screen viewport.
|
/// Creates a new [`Terminal`] with the given [`Backend`] with a full screen viewport.
|
||||||
///
|
///
|
||||||
|
/// Note that unlike `ratatui::init`, this does not install any panic hook,
|
||||||
|
/// so it is recommended to do that manually when using this function,
|
||||||
|
/// otherwise any panic messages will be printed to the alternate screen and
|
||||||
|
/// the terminal may be left in an unusable state.
|
||||||
|
///
|
||||||
|
/// See [how to set up panic hooks](https://ratatui.rs/recipes/apps/panic-hooks/)
|
||||||
|
/// and [`better-panic` example](https://ratatui.rs/recipes/apps/better-panic/)
|
||||||
|
/// for more information.
|
||||||
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust,ignore
|
||||||
@ -137,6 +146,13 @@ where
|
|||||||
///
|
///
|
||||||
/// let backend = CrosstermBackend::new(stdout());
|
/// let backend = CrosstermBackend::new(stdout());
|
||||||
/// let terminal = Terminal::new(backend)?;
|
/// let terminal = Terminal::new(backend)?;
|
||||||
|
///
|
||||||
|
/// // Optionally set up a panic hook to restore the terminal on panic.
|
||||||
|
/// let old_hook = std::panic::take_hook();
|
||||||
|
/// std::panic::set_hook(Box::new(move |info| {
|
||||||
|
/// ratatui::restore();
|
||||||
|
/// old_hook(info);
|
||||||
|
/// }));
|
||||||
/// # std::io::Result::Ok(())
|
/// # std::io::Result::Ok(())
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new(backend: B) -> Result<Self, B::Error> {
|
pub fn new(backend: B) -> Result<Self, B::Error> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user