From 557541ddd2dfe9119abb346eda29c7d0842cac70 Mon Sep 17 00:00:00 2001 From: 409 Date: Tue, 21 May 2024 22:43:24 +0200 Subject: [PATCH] feat: CTRL-C quits --- src/runner/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/runner/mod.rs b/src/runner/mod.rs index defdb36..9f82a1c 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -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;