orhun / systeroid

A more powerful alternative to sysctl(8) with a terminal user interface 🐧
https://systeroid.cli.rs
Apache License 2.0
1.28k stars 23 forks source link

Add a panic hook to reset terminal upon panic #112

Closed orhun closed 1 year ago

orhun commented 1 year ago

Is your feature request related to a problem? Please describe.

When an unexpected error happens, the terminal is messed up.

Describe the solution you'd like

Add a custom panic hook. See: https://github.com/ratatui-org/rust-tui-template/pull/13

The code changes on this PR will add a panic hook, so if a problem happens and the program panics, before the program closes it will run the code inside the panic hook that will leave alternate screen and disable raw mode. This way, you won't have your terminal messed up if an unexpected error happens.

Describe alternatives you've considered

None.

Additional context

The implementation might be the same as the linked pull request above.