keymap-dump: combine modifier_map's with the same modifier

A bit less efficient, but makes for shorter, nicer output.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-09-21 23:54:34 +03:00
parent 0224283fdf
commit 68962aa1f9
3 changed files with 26 additions and 35 deletions

View File

@ -598,6 +598,8 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
{
const struct xkb_key *key;
xkb_layout_index_t group;
xkb_mod_index_t i;
const struct xkb_mod *mod;
if (keymap->symbols_section_name)
write_buf(buf, "xkb_symbols \"%s\" {\n",
@ -617,18 +619,21 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf)
if (key->num_groups > 0)
write_key(keymap, buf, key);
xkb_keys_foreach(key, keymap) {
xkb_mod_index_t i;
const struct xkb_mod *mod;
if (key->modmap == 0)
continue;
xkb_mods_enumerate(i, mod, &keymap->mods)
if (key->modmap & (1u << i))
write_buf(buf, "\tmodifier_map %s { %s };\n",
xkb_atom_text(keymap->ctx, mod->name),
xkb_mods_enumerate(i, mod, &keymap->mods) {
bool had_any = false;
xkb_keys_foreach(key, keymap) {
if (key->modmap & (1u << i)) {
if (!had_any)
write_buf(buf, "\tmodifier_map %s { ",
xkb_atom_text(keymap->ctx, mod->name));
write_buf(buf, "%s%s",
had_any ? ", " : "",
KeyNameText(keymap->ctx, key->name));
had_any = true;
}
}
if (had_any)
write_buf(buf, " };\n");
}
write_buf(buf, "};\n\n");

View File

@ -1664,20 +1664,13 @@ xkb_symbols "pc_us_pt_2_us_3_inet(evdev)_group(shift_caps_toggle)_compose(ralt)"
key <I244> { [ XF86Battery ] };
key <I245> { [ XF86Bluetooth ] };
key <I246> { [ XF86WLAN ] };
modifier_map Control { <LCTL> };
modifier_map Shift { <LFSH> };
modifier_map Shift { <RTSH> };
modifier_map Mod1 { <LALT> };
modifier_map Shift { <LFSH>, <RTSH> };
modifier_map Lock { <CAPS> };
modifier_map Control { <LCTL>, <RCTL> };
modifier_map Mod1 { <LALT>, <META> };
modifier_map Mod2 { <NMLK> };
modifier_map Mod5 { <LVL3> };
modifier_map Control { <RCTL> };
modifier_map Mod4 { <LWIN> };
modifier_map Mod4 { <RWIN> };
modifier_map Mod5 { <MDSW> };
modifier_map Mod1 { <META> };
modifier_map Mod4 { <SUPR> };
modifier_map Mod4 { <HYPR> };
modifier_map Mod4 { <LWIN>, <RWIN>, <SUPR>, <HYPR> };
modifier_map Mod5 { <LVL3>, <MDSW> };
};
};

View File

@ -1900,21 +1900,14 @@ xkb_symbols "pc_us_ru_2_ca(multix)_3_de(neo)_4_inet(evdev)" {
key <I244> { [ XF86Battery ] };
key <I245> { [ XF86Bluetooth ] };
key <I246> { [ XF86WLAN ] };
modifier_map Control { <LCTL> };
modifier_map Shift { <LFSH> };
modifier_map Shift { <RTSH> };
modifier_map Mod1 { <LALT> };
modifier_map Shift { <LFSH>, <RTSH> };
modifier_map Lock { <CAPS> };
modifier_map Control { <LCTL> };
modifier_map Mod1 { <LALT>, <RALT>, <META> };
modifier_map Mod2 { <NMLK> };
modifier_map Mod5 { <LVL3> };
modifier_map Mod3 { <RCTL> };
modifier_map Mod1 { <RALT> };
modifier_map Mod4 { <LWIN> };
modifier_map Mod4 { <RWIN> };
modifier_map Mod5 { <MDSW> };
modifier_map Mod1 { <META> };
modifier_map Mod4 { <SUPR> };
modifier_map Mod4 { <HYPR> };
modifier_map Mod4 { <LWIN>, <RWIN>, <SUPR>, <HYPR> };
modifier_map Mod5 { <LVL3>, <MDSW> };
};
};