feat: CTRL-C quits

This commit is contained in:
2024-05-21 22:43:24 +02:00
parent 47660ffe33
commit 557541ddd2

View File

@@ -3,10 +3,10 @@ use std::time::Duration;
use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher};
use sdl2::{
event::Event,
keyboard::Keycode,
keyboard::{Keycode, Mod},
rect::Rect,
render::Canvas,
ttf::{self},
ttf,
video::Window,
Sdl,
};
@@ -36,6 +36,7 @@ impl Runner {
let ttf = ttf::init().expect("Error creating SDL TTF context");
let window_height: u32;
{
let font_path = String::from("/usr/share/fonts/OTF/GeistMonoNerdFontMono-Regular.otf");
@@ -58,6 +59,7 @@ impl Runner {
.expect("Error creating window");
window.set_opacity(0.0).unwrap();
let window_size = window.size();
let canvas = window.into_canvas().build().expect("Error creating canvas");
@@ -110,6 +112,11 @@ impl Runner {
| Event::KeyDown {
keycode: Some(Keycode::Escape),
..
}
| Event::KeyDown {
keycode: Some(Keycode::C),
keymod: Mod::LCTRLMOD,
..
} => {
self.input = String::from("");
break 'run;