mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-26 07:04:51 +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,
|
painter: &mut canvas::Painter,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
if let Err(err) = painter.draw_data(terminal, app) {
|
if let Err(err) = painter.draw_data(terminal, app) {
|
||||||
cleanup_terminal(terminal, &app.app_config_fields)?;
|
cleanup_terminal(terminal)?;
|
||||||
Err(err.into())
|
Err(err.into())
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -71,14 +71,13 @@ fn try_drawing(
|
|||||||
|
|
||||||
/// Clean up the terminal before returning it to the user.
|
/// Clean up the terminal before returning it to the user.
|
||||||
fn cleanup_terminal(
|
fn cleanup_terminal(
|
||||||
terminal: &mut Terminal<CrosstermBackend<std::io::Stdout>>, app_config_fields: &AppConfigFields,
|
terminal: &mut Terminal<CrosstermBackend<std::io::Stdout>>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
disable_raw_mode()?;
|
disable_raw_mode()?;
|
||||||
if app_config_fields.disable_click {
|
|
||||||
execute!(terminal.backend_mut(), DisableMouseCapture)?;
|
|
||||||
}
|
|
||||||
execute!(
|
execute!(
|
||||||
terminal.backend_mut(),
|
terminal.backend_mut(),
|
||||||
|
DisableMouseCapture,
|
||||||
DisableBracketedPaste,
|
DisableBracketedPaste,
|
||||||
LeaveAlternateScreen,
|
LeaveAlternateScreen,
|
||||||
Show,
|
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...
|
// I think doing it in this order is safe...
|
||||||
// TODO: maybe move the cancellation token to the ctrl-c handler?
|
// TODO: maybe move the cancellation token to the ctrl-c handler?
|
||||||
cancellation_token.cancel();
|
cancellation_token.cancel();
|
||||||
cleanup_terminal(&mut terminal, &app.app_config_fields)?;
|
cleanup_terminal(&mut terminal)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user