Closed edgar-bonet closed 7 months ago
I mean this MR augments half of the program. Is it really necessary to have bells and whistles? Personally I prefer ^-C for termination and it's handled quite well by ttyplot.
@MIvanchev wrote:
I mean this MR augments half of the program.
What do you mean by “augments half of the program”? This pull request adds only 28 lines of code (+6 comment-only and blank lines).
Please, beware that this PR depends on PR #98. If you click on the “Files changed” tab on GitHub, you will see the total diff from the merge base. You have to manually select (with Shift-click) the three last commits in order to see this PR alone.
Rebased on top of the updated PR #98.
You have to manually select (with Shift-click) the three last commits in order to see this PR alone.
This compare view URL would also work (as longs as it remains to be exactly three commits and the branch exists): https://github.com/edgar-bonet/ttyplot/compare/keys~3...keys
The normal way to stop ttyplot is by typing Ctrl-C. This is unfortunate, as this key combination is normally only ever used for interrupting an unresponsive program: well behaved programs can be terminated by some regular (not signal) keyboard command.
This pull request makes ttyplot quit when the user hits q on the keyboard. This is the same key used to terminate more, less, htop, ncdu, and other full-screen terminal programs. Once we monitor keyboard input, adding extra keybindings is cheap. Then, as a bonus, the r key toggles rate mode on and off.
Keyboard commands only work when stdin is redirected (our most common use case), as otherwise keyboard input is interpreted as data. It works by reading the keystrokes from the controlling terminal (
/dev/tty
).This pull request depends on PR #98, which creates the required framework for concurrently watching multiple event sources.