feat: handle ctrl+c

This commit is contained in:
Tal 2024-09-28 01:06:39 +02:00
parent 4ee86ec4f2
commit 672b0c5c98
3 changed files with 10 additions and 4 deletions

2
Cargo.lock generated
View File

@ -982,7 +982,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]] [[package]]
name = "lowfi" name = "lowfi"
version = "1.0.1" version = "1.0.2"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"arc-swap", "arc-swap",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lowfi" name = "lowfi"
version = "1.0.1" version = "1.0.2"
edition = "2021" edition = "2021"
description = "An extremely simple lofi player." description = "An extremely simple lofi player."
license = "MIT" license = "MIT"

View File

@ -7,7 +7,7 @@ use crate::tracks::TrackInfo;
use super::Player; use super::Player;
use crossterm::{ use crossterm::{
cursor::{Hide, MoveToColumn, MoveUp, Show}, cursor::{Hide, MoveToColumn, MoveUp, Show},
event, event::{self, KeyCode, KeyModifiers},
style::{Print, Stylize}, style::{Print, Stylize},
terminal::{self, Clear, ClearType}, terminal::{self, Clear, ClearType},
}; };
@ -143,11 +143,17 @@ pub async fn start(queue: Arc<Player>, sender: Sender<Messages>) -> eyre::Result
continue; continue;
}; };
let event::KeyCode::Char(code) = event.code else { let KeyCode::Char(code) = event.code else {
continue; continue;
}; };
match code { match code {
'c' => {
// Handles Ctrl+C.
if event.modifiers == KeyModifiers::CONTROL {
break;
}
}
'q' => { 'q' => {
break; break;
} }