diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-01-31 15:42:17 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-01-31 15:42:17 +0100 |
commit | 6060db32b949d62757b668f972648465f1e302c7 (patch) | |
tree | 53fcc624d250a7d42d15cfcae4909ed6c21dd3be /make_keysym_table.sh |
Initial
Diffstat (limited to 'make_keysym_table.sh')
-rwxr-xr-x | make_keysym_table.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/make_keysym_table.sh b/make_keysym_table.sh new file mode 100755 index 0000000..5b0c325 --- /dev/null +++ b/make_keysym_table.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +output=$(sed -n 's/^#define XKB_KEY_\([a-zA-Z_0-9]\+\)\s\+\(0x[0-9a-f]\+\).*/\t{"\1", {\2}},/p' /usr/include/xkbcommon/xkbcommon-keysyms.h) + +len=$(wc -l <<<"$output") + +if [[ $1 = --source ]]; then + cat <<EOF +#include "keysym_table.h" + +const std::array<std::pair<const char*, x::Keysym>, $len> keysym_table{{ +$output +}}; +EOF +elif [[ $1 = --header ]]; then + cat <<EOF +#pragma once + +#include <array> +#include <utility> +#include "xutil.h" + + +extern const std::array<std::pair<const char*, x::Keysym>, $len> keysym_table; +EOF +else + echo >&2 "$0: invalid flags" + exit 1 +fi |