1
0
Fork 0
forked from wry/wry

Merge pull request #755 from mahkoh/jorth/kbvm-keysym

toml-config: use KBVM keysym parsing
This commit is contained in:
mahkoh 2026-02-24 17:28:13 +01:00 committed by GitHub
commit e1be2fb463
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 11 additions and 2590 deletions

1
Cargo.lock generated
View file

@ -721,6 +721,7 @@ dependencies = [
"error_reporter", "error_reporter",
"indexmap", "indexmap",
"jay-config", "jay-config",
"kbvm",
"log", "log",
"phf", "phf",
"run-on-drop", "run-on-drop",

View file

@ -20,6 +20,7 @@ bstr = { version = "1.9.1", default-features = false }
ahash = "0.8.11" ahash = "0.8.11"
run-on-drop = "1.0.0" run-on-drop = "1.0.0"
uapi = "0.2.13" uapi = "0.2.13"
kbvm = "0.1.5"
[dev-dependencies] [dev-dependencies]
simplelog = { version = "0.12.2", features = ["test"] } simplelog = { version = "0.12.2", features = ["test"] }

View file

@ -2,7 +2,6 @@ mod context;
pub mod error; pub mod error;
mod extractor; mod extractor;
mod keycodes; mod keycodes;
mod keysyms;
mod parser; mod parser;
mod parsers; mod parsers;
mod spanned; mod spanned;

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,6 @@ use {
Action, Config, Libei, Theme, UiDrag, Action, Config, Libei, Theme, UiDrag,
context::Context, context::Context,
extractor::{Extractor, ExtractorError, arr, bol, int, opt, recover, str, val}, extractor::{Extractor, ExtractorError, arr, bol, int, opt, recover, str, val},
keysyms::KEYSYMS,
parser::{DataType, ParseResult, Parser, UnexpectedDataType}, parser::{DataType, ParseResult, Parser, UnexpectedDataType},
parsers::{ parsers::{
action::ActionParser, action::ActionParser,
@ -50,6 +49,8 @@ use {
}, },
ahash::AHashMap, ahash::AHashMap,
indexmap::IndexMap, indexmap::IndexMap,
jay_config::keyboard::syms::KeySym,
kbvm::Keysym,
std::collections::HashSet, std::collections::HashSet,
thiserror::Error, thiserror::Error,
}; };
@ -480,8 +481,8 @@ impl Parser for ConfigParser<'_> {
} }
let mut pointer_revert_key = None; let mut pointer_revert_key = None;
if let Some(value) = pointer_revert_key_str { if let Some(value) = pointer_revert_key_str {
match KEYSYMS.get(value.value) { match Keysym::from_str(value.value) {
Some(s) => pointer_revert_key = Some(*s), Some(s) => pointer_revert_key = Some(KeySym(s.0)),
None => log::warn!("Unknown keysym: {}", self.0.error3(value.span)), None => log::warn!("Unknown keysym: {}", self.0.error3(value.span)),
} }
} }

View file

@ -1,9 +1,6 @@
use { use {
crate::{ crate::{
config::{ config::parser::{DataType, ParseResult, Parser, UnexpectedDataType},
keysyms::KEYSYMS,
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
},
toml::toml_span::{Span, SpannedExt}, toml::toml_span::{Span, SpannedExt},
}, },
jay_config::keyboard::{ jay_config::keyboard::{
@ -12,7 +9,9 @@ use {
ALT, CAPS, CTRL, LOCK, LOGO, MOD1, MOD2, MOD3, MOD4, MOD5, Modifiers, NUM, RELEASE, ALT, CAPS, CTRL, LOCK, LOGO, MOD1, MOD2, MOD3, MOD4, MOD5, Modifiers, NUM, RELEASE,
SHIFT, SHIFT,
}, },
syms::KeySym,
}, },
kbvm::Keysym,
thiserror::Error, thiserror::Error,
}; };
@ -43,9 +42,9 @@ impl Parser for ModifiedKeysymParser {
for part in string.split("-") { for part in string.split("-") {
let modifier = match parse_mod(part) { let modifier = match parse_mod(part) {
Some(m) => m, Some(m) => m,
_ => match KEYSYMS.get(part) { _ => match Keysym::from_str(part) {
Some(new) if sym.is_none() => { Some(new) if sym.is_none() => {
sym = Some(*new); sym = Some(KeySym(new.0));
continue; continue;
} }
Some(_) => return Err(ModifiedKeysymParserError::MoreThanOneSym.spanned(span)), Some(_) => return Err(ModifiedKeysymParserError::MoreThanOneSym.spanned(span)),