mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-23 13:45:12 +02:00
bug: fix incorrect disable mouse click condition on cleanup (#1713)
Looks like a bug slipped through in #1706 so when stopping the program click events would continue. I could just fix the condition but I think it's fine to just unconditionally disable click events on cleanup.
This commit is contained in:
parent
69a4b59573
commit
c68b190388
11
src/lib.rs
11
src/lib.rs
@ -62,7 +62,7 @@ fn try_drawing(
|
||||
painter: &mut canvas::Painter,
|
||||
) -> anyhow::Result<()> {
|
||||
if let Err(err) = painter.draw_data(terminal, app) {
|
||||
cleanup_terminal(terminal, &app.app_config_fields)?;
|
||||
cleanup_terminal(terminal)?;
|
||||
Err(err.into())
|
||||
} else {
|
||||
Ok(())
|
||||
@ -71,14 +71,13 @@ fn try_drawing(
|
||||
|
||||
/// Clean up the terminal before returning it to the user.
|
||||
fn cleanup_terminal(
|
||||
terminal: &mut Terminal<CrosstermBackend<std::io::Stdout>>, app_config_fields: &AppConfigFields,
|
||||
terminal: &mut Terminal<CrosstermBackend<std::io::Stdout>>,
|
||||
) -> anyhow::Result<()> {
|
||||
disable_raw_mode()?;
|
||||
if app_config_fields.disable_click {
|
||||
execute!(terminal.backend_mut(), DisableMouseCapture)?;
|
||||
}
|
||||
|
||||
execute!(
|
||||
terminal.backend_mut(),
|
||||
DisableMouseCapture,
|
||||
DisableBracketedPaste,
|
||||
LeaveAlternateScreen,
|
||||
Show,
|
||||
@ -457,7 +456,7 @@ pub fn start_bottom(enable_error_hook: &mut bool) -> anyhow::Result<()> {
|
||||
// I think doing it in this order is safe...
|
||||
// TODO: maybe move the cancellation token to the ctrl-c handler?
|
||||
cancellation_token.cancel();
|
||||
cleanup_terminal(&mut terminal, &app.app_config_fields)?;
|
||||
cleanup_terminal(&mut terminal)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user