keyboard: Use xkb_common::keysyms

This commit is contained in:
Kenny Levinsen
2023-11-10 14:00:06 +01:00
parent 921938cc0d
commit 84c241a90e
3 changed files with 17 additions and 37 deletions
-21
View File
@@ -1,21 +0,0 @@
#![allow(missing_docs, non_upper_case_globals, unused_parens, clippy::all)]
pub const XKB_KEY_BackSpace: u32 = 0xff08; /* Back space, back char */
//pub const XKB_KEY_Tab: u32 = 0xff09;
pub const XKB_KEY_Return: u32 = 0xff0d; /* Return, enter */
pub const XKB_KEY_Escape: u32 = 0xff1b;
pub const XKB_KEY_Delete: u32 = 0xffff; /* Delete, rubout */
pub const XKB_KEY_Home: u32 = 0xff50;
pub const XKB_KEY_Left: u32 = 0xff51; /* Move left, left arrow */
pub const XKB_KEY_Up: u32 = 0xff52; /* Move up, up arrow */
pub const XKB_KEY_Right: u32 = 0xff53; /* Move right, right arrow */
pub const XKB_KEY_Down: u32 = 0xff54; /* Move down, down arrow */
pub const XKB_KEY_End: u32 = 0xff57; /* EOL */
//pub const XKB_KEY_ISO_Left_Tab: u32 = 0xfe20;
pub const XKB_KEY_a: u32 = 0x0061; /* U+0061 LATIN SMALL LETTER A */
pub const XKB_KEY_e: u32 = 0x0065; /* U+0065 LATIN SMALL LETTER E */
//pub const XKB_KEY_c: u32 = 0x0063; /* U+0063 LATIN SMALL LETTER C */
pub const XKB_KEY_k: u32 = 0x006b; /* U+006B LATIN SMALL LETTER K */
pub const XKB_KEY_r: u32 = 0x0072; /* U+0072 LATIN SMALL LETTER R */
pub const XKB_KEY_u: u32 = 0x0075; /* U+0075 LATIN SMALL LETTER U */
+2 -1
View File
@@ -20,7 +20,8 @@ use std::{
use wayland_client::{protocol::wl_keyboard, WEnum}; use wayland_client::{protocol::wl_keyboard, WEnum};
use xkbcommon::xkb; use xkbcommon::xkb;
pub mod keysyms; pub use xkbcommon::xkb::keysyms;
mod repeat; mod repeat;
mod state; mod state;
+15 -15
View File
@@ -675,43 +675,43 @@ impl Interface {
PromptMode::Calc => &mut self.calc as &mut dyn InterfaceWidget, PromptMode::Calc => &mut self.calc as &mut dyn InterfaceWidget,
}; };
match event.keysym { match event.keysym {
keysyms::XKB_KEY_a if event.modifiers.ctrl => self.inner.prompt.home(), keysyms::KEY_a if event.modifiers.ctrl => self.inner.prompt.home(),
keysyms::XKB_KEY_e if event.modifiers.ctrl => self.inner.prompt.end(), keysyms::KEY_e if event.modifiers.ctrl => self.inner.prompt.end(),
keysyms::XKB_KEY_u if event.modifiers.ctrl => { keysyms::KEY_u if event.modifiers.ctrl => {
self.inner.prompt.clear_left(); self.inner.prompt.clear_left();
self.inner.selection = 0; self.inner.selection = 0;
widget.update(&self.inner); widget.update(&self.inner);
} }
keysyms::XKB_KEY_k if event.modifiers.ctrl => { keysyms::KEY_k if event.modifiers.ctrl => {
self.inner.prompt.clear_right(); self.inner.prompt.clear_right();
self.inner.selection = 0; self.inner.selection = 0;
widget.update(&self.inner); widget.update(&self.inner);
} }
keysyms::XKB_KEY_r if event.modifiers.ctrl => { keysyms::KEY_r if event.modifiers.ctrl => {
if let Ok(s) = read_to_string(format!("{}/wldash/prompt", xdg::cache_folder())) { if let Ok(s) = read_to_string(format!("{}/wldash/prompt", xdg::cache_folder())) {
self.inner.prompt.set(&s); self.inner.prompt.set(&s);
} }
} }
keysyms::XKB_KEY_Home => self.inner.prompt.home(), keysyms::KEY_Home => self.inner.prompt.home(),
keysyms::XKB_KEY_End => self.inner.prompt.end(), keysyms::KEY_End => self.inner.prompt.end(),
keysyms::XKB_KEY_BackSpace => { keysyms::KEY_BackSpace => {
self.inner.prompt.backspace(); self.inner.prompt.backspace();
self.inner.selection = 0; self.inner.selection = 0;
widget.update(&self.inner); widget.update(&self.inner);
} }
keysyms::XKB_KEY_Delete => { keysyms::KEY_Delete => {
self.inner.prompt.delete(); self.inner.prompt.delete();
self.inner.selection = 0; self.inner.selection = 0;
widget.update(&self.inner); widget.update(&self.inner);
} }
keysyms::XKB_KEY_Escape => self.exit(), keysyms::KEY_Escape => self.exit(),
keysyms::XKB_KEY_Return => widget.trigger(&mut self.inner), keysyms::KEY_Return => widget.trigger(&mut self.inner),
keysyms::XKB_KEY_Left => self.inner.prompt.move_cursor(-1), keysyms::KEY_Left => self.inner.prompt.move_cursor(-1),
keysyms::XKB_KEY_Right => self.inner.prompt.move_cursor(1), keysyms::KEY_Right => self.inner.prompt.move_cursor(1),
keysyms::XKB_KEY_Up => { keysyms::KEY_Up => {
self.inner.selection += 1; self.inner.selection += 1;
} }
keysyms::XKB_KEY_Down => { keysyms::KEY_Down => {
if self.inner.selection > 0 { if self.inner.selection > 0 {
self.inner.selection -= 1; self.inner.selection -= 1;
} }