cli: Handle ctrl+c interrupts during an active spinner thread
This is in response to issue# d2aeb57, where the cursor is not shown when
interrupting rad when a progress spinner thread is present.
This is mainly achieved by adding signal handling for spinners now using radicle-signals and
crossbeam-channel. When a SIGINT signal fires off while a spinner is active, it will drop its
respective HideCursor object and exit the process entirely.
Some other somewhat related changes to this patch:
- to better pass on handling to the OS/another CLI element,
radicle-signals::uninstall()is implemented and used for the spinners.- the CLI pager also used
radicle-signals, so that was also modified to use the above
- the CLI pager also used
- doc changes to the spinner/pager to include the tidbits on signal handling
3 files changed
+92
-14
a831e18a
→
1848c2b8
modified radicle-signals/src/lib.rs
@@ -33,6 +33,9 @@ impl TryFrom<i32> for Signal {
|
|
|
|
|
|
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -54,23 +57,51 @@ pub fn install(notify: chan::Sender<Signal>) -> io::Result<()> {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
|
|
|
|
|
|
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
|
|
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
modified radicle-term/src/pager.rs
@@ -24,6 +24,12 @@ pub enum Error {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -35,9 +41,13 @@ pub fn page<E: Element + Send + 'static>(element: E) -> Result<(), Error> {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
modified radicle-term/src/spinner.rs
@@ -3,6 +3,11 @@ use std::mem::ManuallyDrop;
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -103,10 +108,10 @@ impl Spinner {
|
|
|
|
|
|
| - | |
| + | |
| + | |
|
|
|
|
| - | |
|
|
|
|
|
@@ -115,6 +120,12 @@ pub fn spinner(message: impl ToString) -> Spinner {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -122,6 +133,10 @@ pub fn spinner_to(
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -134,6 +149,25 @@ pub fn spinner_to(
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -192,6 +226,9 @@ pub fn spinner_to(
|
|
|
|
|
|
| + | |
| + | |
| + | |
|
|
|
|
|