aboutsummaryrefslogtreecommitdiff
path: root/src/utils.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-03-17 12:22:40 +0000
committerAkshay <[email protected]>2021-03-17 12:22:40 +0000
commit7615546fb0157c3ec9d2f25ec9837ee0b6cb7e9a (patch)
treeb197326f7812ec20e2207b0e444f2a50569c5b74 /src/utils.rs
parent83732aed1a41a713cd8790fcebae90aabe78b789 (diff)
feat: basic command mode, add text box primitives
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/utils.rs b/src/utils.rs
index a1b3624..71a9eea 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,5 +1,11 @@
1use crate::consts::FONT_PATH; 1use crate::consts::FONT_PATH;
2use sdl2::{pixels::Color, render::Canvas, ttf::Sdl2TtfContext, video::Window}; 2use sdl2::{
3 keyboard::{Keycode, Mod},
4 pixels::Color,
5 render::Canvas,
6 ttf::Sdl2TtfContext,
7 video::Window,
8};
3 9
4#[macro_export] 10#[macro_export]
5macro_rules! rect( 11macro_rules! rect(
@@ -27,4 +33,13 @@ pub fn draw_text<S: AsRef<str>>(
27 let (width, height) = font.size_of_latin1(text.as_bytes()).unwrap(); 33 let (width, height) = font.size_of_latin1(text.as_bytes()).unwrap();
28 let area = rect!(x, y, width, height); 34 let area = rect!(x, y, width, height);
29 canvas.copy(&texture, None, area).unwrap(); 35 canvas.copy(&texture, None, area).unwrap();
36 width
37}
38
39pub fn is_copy_event(keycode: Option<Keycode>, keymod: Mod) -> bool {
40 keycode == Some(Keycode::C) && (keymod == Mod::LCTRLMOD || keymod == Mod::RCTRLMOD)
41}
42
43pub fn is_paste_event(keycode: Option<Keycode>, keymod: Mod) -> bool {
44 keycode == Some(Keycode::V) && (keymod == Mod::LCTRLMOD || keymod == Mod::RCTRLMOD)
30} 45}