denise-layout
Keyboard layouts for Denise: what a key position types, once you know which layout the user is on.
A backend answers where a key is — KeyCode is a position, and each platform
maps its own scancodes onto it. This crate answers what that position produces:
shift levels, dead keys and their composition, and which layout the machine is
already configured for.
use ;
use ;
// Whatever the machine is set to, with no configuration of our own.
let = from_system;
println!;
let mut composer = new;
let typed = composer.feed;
assert_eq!;
Dead keys compose across two presses, and a mark that cannot combine with what follows emits both characters rather than swallowing one:
# use ;
# use ;
let mut composer = new;
let press = ;
assert!; // ¨, held
assert_eq!;
US and NORWEGIAN ship with the crate; BUILT_IN lists them and by_name
looks one up. Adding a layout is a table of positions and about thirty lines.
Where the layout comes from
from_system reads the machine's choice — DENISE_KEYMAP, then
XKB_DEFAULT_LAYOUT, then the console keymap files distributions actually
write — and LayoutSource says which of them answered, or that nothing did and
US was assumed. The layout data comes from this crate rather than the system,
because the two ways to read the system's tables are KDGKBENT on a VT, which
needs root, and libxkbcommon, which is a C library with a runtime data
directory. Denise runs unprivileged as one static binary, and gives up neither.