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]]
name = "lowfi"
version = "1.0.1"
version = "1.0.2"
dependencies = [
"Inflector",
"arc-swap",

View File

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

View File

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