Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore terminal if hwatch is killed #78

Merged
merged 15 commits into from
Dec 31, 2022
Merged

Conversation

ilyagr
Copy link
Contributor

@ilyagr ilyagr commented Dec 13, 2022

Currently, if hwatch is running in one terminal and
you run killall hwatch from another, the first terminal
ends up with an invisible cursor.

Aside: A workaround I found when this problem occurs
is to run tput reset in that terminal.

This commit uses the Ctrl-C crate to make hwatch
restore the terminal to a sane state even if it's killed
or otherwise interrupted (within limits, killall -9 hwatch
will not let hwatch do anything before being killed).

This PR currently depends on and includes #77, but this is easy to change if desired.

@ilyagr ilyagr changed the base branch from master to 0.3.8 December 13, 2022 05:03
@ilyagr ilyagr force-pushed the cleankill branch 12 times, most recently from eaf8e30 to 7a79712 Compare December 14, 2022 02:49
@ilyagr
Copy link
Contributor Author

ilyagr commented Dec 14, 2022

(Previous version of this was a bit too complicated and didn't work right on panics, so I simplified it a bit)

The mouse events are not used in this commit
Mouse wheel always scrolls the main window by 2 lines. I think
this might be preferable to scrolling different windows dependng
on mouse position. (Also, the latter is harder to implement)

Scrolling by 1 line feels too slow on my machine, thus
scrolling by 2 lines.
Currently, if `hwatch` is running in one terminal and 
you run `killall hwatch` from another, the first terminal
ends up with an invisible cursor. A workaround I found
is to run `tput reset` in that terminal.

This commit uses the [Ctrl-C crate] to make `hwatch`
restore the terminal to a sane state even if it's killed
or otherwise interrupted (within limits, `killall -9 hwatch`
will not let `hwatch` do anything before being killed).

[Ctrl-C crate]: https://crates.io/crates/ctrlc
Copy link
Owner

@blacknon blacknon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's working!
Thanks!

@blacknon blacknon merged commit cd48cf5 into blacknon:0.3.8 Dec 31, 2022
@blacknon blacknon added this to the 0.3.8 milestone Jan 1, 2023
@blacknon blacknon mentioned this pull request Jan 4, 2023
blacknon added a commit that referenced this pull request Jan 4, 2023
Version 0.3.8.

- Added a function to notify with a beep sound when updating result(add `-B` option) #22
- Added a function to execute the specified command when there is a change in the command output result(add `-A "command..."` option)
- Added a function to switch to display only lines with differences by <kbd>Shift</kbd> + <kbd>O</kbd> when line/word diff.
- Added option to hide header and history window(add `-t` option and <kbd>T</kbd> and <kbd>Backspace</kbd> key) #70 
- Added an option to hide the message "Display help with h key" (add `--no-help-banner` option) #76 
- Added a function that can be set by writing options in the environment variable "HWATCH" #76
- Mouse wheel support(add `--mouse` option) #77 
- Changed to restore the terminal cleanly when killed #78 
- Debug hwatch_log #64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants