x11_keysymdef/
lib.rs

1//! The "X11 Window System Protocol" standard defines in Appendix A the keysym
2//! codes. These 29-bit integer values identify characters or functions
3//! associated with each key (e.g., via the visible engraving) of a keyboard
4//! layout.
5//!
6//! This library contains mappings between mnemonic macro names and these keysym
7//! codes.
8
9#![allow(clippy::unreadable_literal)]
10
11include!(concat!(env!("OUT_DIR"), "/mapping.rs"));
12
13/// Look up a record by the mnemonic macro name
14pub fn lookup_by_name(name: &str) -> Option<&'static Record> {
15    BY_NAMES.get(&name).copied()
16}
17
18/// Look up a record by unicode char (unicode code point)
19pub fn lookup_by_codepoint(codepoint: char) -> Option<&'static Record> {
20    BY_CODEPOINT.get(&codepoint).copied()
21}
22
23/// Look up a mnemonic macro name by the keysym code
24pub fn lookup_by_keysym(keysym: u32) -> Option<&'static Record> {
25    BY_KEYSYM.get(&keysym).copied()
26}
27
28#[test]
29fn access_works() {
30    assert!(lookup_by_name("Uhorngrave").is_some());
31    assert!(lookup_by_codepoint('\u{1EEA}').is_some());
32    assert!(lookup_by_keysym(0x1eea).is_some());
33}