summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-07-08 09:55:20 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2020-07-08 15:21:19 +1000
commit2cb90c958f7efa36b00fe845c38bbe0d00e15b1e (patch)
tree69b276959ead0e5c9b005c749422f4ae620e40e2 /tools
parentfc2d4fa2aba307e5c2a3c86b1879b05c2c738dba (diff)
downloadxorg-lib-libxkbcommon-2cb90c958f7efa36b00fe845c38bbe0d00e15b1e.tar.gz
tools: add option to print full RMLVO elements to rmlvo-to-keymap
Since the most common use-case is to provide only some elements of RMLVO, this makes it possible to show what is actually being used in the background based on the built-in defaults. Print this in a format that's mostly JSON-compatible or at least easy to parse, just in case. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/rmlvo-to-keymap.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/rmlvo-to-keymap.c b/tools/rmlvo-to-keymap.c
index 4783be7..e090de1 100644
--- a/tools/rmlvo-to-keymap.c
+++ b/tools/rmlvo-to-keymap.c
@@ -39,6 +39,7 @@
static bool verbose = false;
static enum output_format {
+ FORMAT_RMLVO,
FORMAT_KEYMAP,
FORMAT_KCCGST,
FORMAT_KEYMAP_FROM_XKB,
@@ -57,6 +58,8 @@ usage(char **argv)
" Enable verbose debugging output\n"
" --kccgst\n"
" Print a keymap which only includes the KcCGST component names instead of the full keymap\n"
+ " --rmlvo\n"
+ " Print the full RMLVO with the defaults filled in for missing elements\n"
" --from-xkb\n"
" Load the XKB file from stdin, ignore RMLVO options. This option\n"
" must not be used with --kccgst.\n"
@@ -95,6 +98,7 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
enum options {
OPT_VERBOSE,
OPT_KCCGST,
+ OPT_RMLVO,
OPT_FROM_XKB,
OPT_INCLUDE,
OPT_INCLUDE_DEFAULTS,
@@ -108,6 +112,7 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, OPT_VERBOSE},
{"kccgst", no_argument, 0, OPT_KCCGST},
+ {"rmlvo", no_argument, 0, OPT_RMLVO},
{"from-xkb", no_argument, 0, OPT_FROM_XKB},
{"include", required_argument, 0, OPT_INCLUDE},
{"include-defaults", no_argument, 0, OPT_INCLUDE_DEFAULTS},
@@ -136,6 +141,9 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
case OPT_KCCGST:
output_format = FORMAT_KCCGST;
break;
+ case OPT_RMLVO:
+ output_format = FORMAT_RMLVO;
+ break;
case OPT_FROM_XKB:
output_format = FORMAT_KEYMAP_FROM_XKB;
break;
@@ -171,6 +179,16 @@ parse_options(int argc, char **argv, struct xkb_rule_names *names)
}
static bool
+print_rmlvo(struct xkb_context *ctx, const struct xkb_rule_names *rmlvo)
+{
+ printf("rules: \"%s\"\nmodel: \"%s\"\nlayout: \"%s\"\nvariant: \"%s\"\noptions: \"%s\"\n",
+ rmlvo->rules, rmlvo->model, rmlvo->layout,
+ rmlvo->variant ? rmlvo->variant : "",
+ rmlvo->options ? rmlvo->options : "");
+ return true;
+}
+
+static bool
print_kccgst(struct xkb_context *ctx, const struct xkb_rule_names *rmlvo)
{
struct xkb_component_names kccgst;
@@ -308,7 +326,9 @@ main(int argc, char **argv)
xkb_context_include_path_append(ctx, *path);
}
- if (output_format == FORMAT_KEYMAP) {
+ if (output_format == FORMAT_RMLVO) {
+ rc = print_rmlvo(ctx, &names) ? EXIT_SUCCESS : EXIT_FAILURE;
+ } else if (output_format == FORMAT_KEYMAP) {
rc = print_keymap(ctx, &names) ? EXIT_SUCCESS : EXIT_FAILURE;
} else if (output_format == FORMAT_KCCGST) {
rc = print_kccgst(ctx, &names) ? EXIT_SUCCESS : EXIT_FAILURE;