Repository: alexpasmantier/television (language: rust)

Issue:
sigint should exit television
**Problem**
ctrl-c does not exit television

**Feature**
exit television on ctrl-c

**Additional context**
escape is good, but also I'm used to ctrl-c exiting programs and find it irritating that it doesn't exit television

I can't think of an interactive command that doesn't exit on ctrl-c except for REPLs like python, etc, where ctrl-c is handled as part of the programming environment; fzf exits on ctrl-c, and many others as well



Discussion / hints:
I'm not certain this won't cause other problems, but I was able to get Ctrl-C to quit on Ubuntu by changing the `config.toml` file:

```toml
# ...
[keybindings.Channel]
# Quit the application
quit = ["esc", "ctrl-c"]
# ...
```
👍  this feature request would be to make that behavior the default

(And to handle sigint by quitting, generally - there are other ways of sending the signal besides ctrl+c)

Fix patch:
diff --git a/.config/config.toml b/.config/config.toml
index 2038a5e..c8675d7 100644
--- a/.config/config.toml
+++ b/.config/config.toml
@@ -74,7 +74,7 @@ theme = "TwoDark"
 # ------------------------
 [keybindings.Channel]
 # Quit the application
-quit = "esc"
+quit = ["esc", "ctrl-c"]
 # Scrolling through entries
 select_next_entry = ["down", "ctrl-n", "ctrl-j"]
 select_prev_entry = ["up", "ctrl-p", "ctrl-k"]
diff --git a/crates/television/event.rs b/crates/television/event.rs
index 1e7a333..faa2858 100644
--- a/crates/television/event.rs
+++ b/crates/television/event.rs
@@ -14,7 +14,7 @@ use crossterm::event::{
     KeyEvent, KeyEventKind, KeyModifiers,
 };
 use serde::{Deserialize, Serialize};
-use tokio::sync::mpsc;
+use tokio::{signal, sync::mpsc};
 use tracing::{debug, warn};
 
 #[derive(Debug, Clone, Copy)]
@@ -160,7 +160,6 @@ impl EventLoop {
             //let mut reader = crossterm::event::EventStream::new();
             tokio::spawn(async move {
                 loop {
-                    //let event = reader.next();
                     let delay = tokio::time::sleep(tick_interval);
                     let event_available = poll_event(tick_interval);
 
@@ -171,6 +170,10 @@ impl EventLoop {
                             tx.send(Event::Tick).unwrap_or_else(|_| warn!("Unable to send Tick event"));
                             break;
                         },
+                        _ = signal::ctrl_c() => {
+                            debug!("Received SIGINT");
+                            tx.send(Event::Input(Key::Ctrl('c'))).unwrap_or_else(|_| warn!("Unable to send Ctrl-C event"));
+                        },
                         // if `delay` completes, pass to the next event "frame"
                         () = delay => {
                             tx.send(Event::Tick).unwrap_or_else(|_| warn!("Unable to send Tick event"));


Test patch: