summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2013-02-25 12:17:27 +0200
committerDaniel Stone <daniel@fooishbar.org>2013-03-18 22:20:03 +0000
commit98ccbf9aff0b99e75d05d89c9b8b711a20669b46 (patch)
treec0f88a5eec4a1ca0756fff7c5ae81fb2de1c7ece /src
parent4a59c84e43116f4a05922c273b037fe91df9d0f6 (diff)
keymap-dump: move writing 'key {}' in symbols to its own function
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/keymap-dump.c207
1 files changed, 107 insertions, 100 deletions
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 256b036..9be65d0 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -489,130 +489,137 @@ write_keysyms(struct xkb_keymap *keymap, struct buf *buf,
}
static bool
-write_symbols(struct xkb_keymap *keymap, struct buf *buf)
+write_key(struct xkb_keymap *keymap, struct buf *buf,
+ const struct xkb_key *key)
{
- const struct xkb_key *key;
xkb_layout_index_t group;
+ bool simple = true;
+ bool explicit_types = false;
+ bool multi_type = false;
+ bool show_actions;
- if (keymap->symbols_section_name)
- write_buf(buf, "xkb_symbols \"%s\" {\n",
- keymap->symbols_section_name);
- else
- write_buf(buf, "xkb_symbols {\n");
-
- for (group = 0; group < keymap->num_group_names; group++)
- if (keymap->group_names[group])
- write_buf(buf,
- "\tname[group%d]=\"%s\";\n", group + 1,
- xkb_atom_text(keymap->ctx, keymap->group_names[group]));
- if (group > 0)
- write_buf(buf, "\n");
-
- xkb_foreach_key(key, keymap) {
- bool simple = true;
- bool explicit_types = false;
- bool multi_type = false;
- bool show_actions;
-
- if (key->num_groups == 0)
- continue;
-
- write_buf(buf, "\tkey %-20s {", KeyNameText(keymap->ctx, key->name));
+ write_buf(buf, "\tkey %-20s {", KeyNameText(keymap->ctx, key->name));
- for (group = 0; group < key->num_groups; group++) {
- if (key->groups[group].explicit_type)
- explicit_types = true;
+ for (group = 0; group < key->num_groups; group++) {
+ if (key->groups[group].explicit_type)
+ explicit_types = true;
- if (group != 0 && key->groups[group].type != key->groups[0].type)
- multi_type = true;
- }
+ if (group != 0 && key->groups[group].type != key->groups[0].type)
+ multi_type = true;
+ }
- if (explicit_types) {
- const struct xkb_key_type *type;
- simple = false;
+ if (explicit_types) {
+ const struct xkb_key_type *type;
+ simple = false;
- if (multi_type) {
- for (group = 0; group < key->num_groups; group++) {
- if (!key->groups[group].explicit_type)
- continue;
+ if (multi_type) {
+ for (group = 0; group < key->num_groups; group++) {
+ if (!key->groups[group].explicit_type)
+ continue;
- type = key->groups[group].type;
- write_buf(buf, "\n\t\ttype[group%u]= \"%s\",",
- group + 1,
- xkb_atom_text(keymap->ctx, type->name));
- }
- }
- else {
- type = key->groups[0].type;
- write_buf(buf, "\n\t\ttype= \"%s\",",
- xkb_atom_text(keymap->ctx, type->name));
+ type = key->groups[group].type;
+ write_buf(buf, "\n\t\ttype[group%u]= \"%s\",",
+ group + 1,
+ xkb_atom_text(keymap->ctx, type->name));
}
}
-
- if (key->explicit & EXPLICIT_REPEAT) {
- if (key->repeats)
- write_buf(buf, "\n\t\trepeat= Yes,");
- else
- write_buf(buf, "\n\t\trepeat= No,");
- simple = false;
+ else {
+ type = key->groups[0].type;
+ write_buf(buf, "\n\t\ttype= \"%s\",",
+ xkb_atom_text(keymap->ctx, type->name));
}
+ }
- if (key->vmodmap && (key->explicit & EXPLICIT_VMODMAP))
- write_buf(buf, "\n\t\tvirtualMods= %s,",
- ModMaskText(keymap, key->vmodmap));
+ if (key->explicit & EXPLICIT_REPEAT) {
+ if (key->repeats)
+ write_buf(buf, "\n\t\trepeat= Yes,");
+ else
+ write_buf(buf, "\n\t\trepeat= No,");
+ simple = false;
+ }
- switch (key->out_of_range_group_action) {
- case RANGE_SATURATE:
- write_buf(buf, "\n\t\tgroupsClamp,");
- break;
+ if (key->vmodmap && (key->explicit & EXPLICIT_VMODMAP))
+ write_buf(buf, "\n\t\tvirtualMods= %s,",
+ ModMaskText(keymap, key->vmodmap));
- case RANGE_REDIRECT:
- write_buf(buf, "\n\t\tgroupsRedirect= Group%u,",
- key->out_of_range_group_number + 1);
- break;
+ switch (key->out_of_range_group_action) {
+ case RANGE_SATURATE:
+ write_buf(buf, "\n\t\tgroupsClamp,");
+ break;
- default:
- break;
- }
+ case RANGE_REDIRECT:
+ write_buf(buf, "\n\t\tgroupsRedirect= Group%u,",
+ key->out_of_range_group_number + 1);
+ break;
- show_actions = !!(key->explicit & EXPLICIT_INTERP);
+ default:
+ break;
+ }
- if (key->num_groups > 1 || show_actions)
- simple = false;
+ show_actions = !!(key->explicit & EXPLICIT_INTERP);
- if (simple) {
- write_buf(buf, "\t[ ");
- if (!write_keysyms(keymap, buf, key, 0))
- return false;
- write_buf(buf, " ] };\n");
- }
- else {
- xkb_level_index_t level;
+ if (key->num_groups > 1 || show_actions)
+ simple = false;
- for (group = 0; group < key->num_groups; group++) {
- if (group != 0)
- write_buf(buf, ",");
- write_buf(buf, "\n\t\tsymbols[Group%u]= [ ", group + 1);
- if (!write_keysyms(keymap, buf, key, group))
- return false;
- write_buf(buf, " ]");
- if (show_actions) {
- write_buf(buf, ",\n\t\tactions[Group%u]= [ ", group + 1);
- for (level = 0;
- level < XkbKeyGroupWidth(key, group); level++) {
- if (level != 0)
- write_buf(buf, ", ");
- write_action(keymap, buf,
- &key->groups[group].levels[level].action,
- NULL, NULL);
- }
- write_buf(buf, " ]");
+ if (simple) {
+ write_buf(buf, "\t[ ");
+ if (!write_keysyms(keymap, buf, key, 0))
+ return false;
+ write_buf(buf, " ] };\n");
+ }
+ else {
+ xkb_level_index_t level;
+
+ for (group = 0; group < key->num_groups; group++) {
+ if (group != 0)
+ write_buf(buf, ",");
+ write_buf(buf, "\n\t\tsymbols[Group%u]= [ ", group + 1);
+ if (!write_keysyms(keymap, buf, key, group))
+ return false;
+ write_buf(buf, " ]");
+ if (show_actions) {
+ write_buf(buf, ",\n\t\tactions[Group%u]= [ ", group + 1);
+ for (level = 0;
+ level < XkbKeyGroupWidth(key, group); level++) {
+ if (level != 0)
+ write_buf(buf, ", ");
+ write_action(keymap, buf,
+ &key->groups[group].levels[level].action,
+ NULL, NULL);
}
+ write_buf(buf, " ]");
}
- write_buf(buf, "\n\t};\n");
}
+ write_buf(buf, "\n\t};\n");
}
+ return true;
+}
+
+static bool
+write_symbols(struct xkb_keymap *keymap, struct buf *buf)
+{
+ const struct xkb_key *key;
+ xkb_layout_index_t group;
+
+ if (keymap->symbols_section_name)
+ write_buf(buf, "xkb_symbols \"%s\" {\n",
+ keymap->symbols_section_name);
+ else
+ write_buf(buf, "xkb_symbols {\n");
+
+ for (group = 0; group < keymap->num_group_names; group++)
+ if (keymap->group_names[group])
+ write_buf(buf,
+ "\tname[group%d]=\"%s\";\n", group + 1,
+ xkb_atom_text(keymap->ctx, keymap->group_names[group]));
+ if (group > 0)
+ write_buf(buf, "\n");
+
+ xkb_foreach_key(key, keymap)
+ if (key->num_groups > 0)
+ write_key(keymap, buf, key);
+
xkb_foreach_key(key, keymap) {
xkb_mod_index_t i;
const struct xkb_mod *mod;