xkbcli: Promote compose to xkbcli-compile-compose

Previously this tool was only used for internal testing and thus
not installed. But it is useful for debugging, much like
xkbcli-compile-keymap.
master
Pierre Le Marre 2023-11-07 12:58:20 +01:00 committed by Wismill
parent 79502700a6
commit bc330c00e6
7 changed files with 83 additions and 12 deletions

View File

@ -460,6 +460,7 @@ if build_tools
install: true, install: true,
install_dir: dir_libexec) install_dir: dir_libexec)
install_man('tools/xkbcli-compile-keymap.1') install_man('tools/xkbcli-compile-keymap.1')
configh_data.set10('HAVE_XKBCLI_COMPILE_KEYMAP', true)
# The same tool again, but with access to some private APIs. # The same tool again, but with access to some private APIs.
executable('compile-keymap', executable('compile-keymap',
'tools/compile-keymap.c', 'tools/compile-keymap.c',
@ -470,12 +471,13 @@ if build_tools
install: false) install: false)
# Tool: compose # Tool: compose
executable('compose', executable('xkbcli-compile-compose',
'tools/compose.c', 'tools/compile-compose.c',
dependencies: tools_dep, dependencies: tools_dep,
include_directories: [include_directories('src', 'include')], install: true,
install: false) install_dir: dir_libexec)
configh_data.set10('HAVE_XKBCLI_COMPILE_KEYMAP', true) install_man('tools/xkbcli-compile-compose.1')
configh_data.set10('HAVE_XKBCLI_COMPILE_COMPOSE', true)
# Tool: how-to-type # Tool: how-to-type
executable('xkbcli-how-to-type', executable('xkbcli-how-to-type',

View File

@ -152,6 +152,7 @@ class TestXkbcli(unittest.TestCase):
) )
cls.xkbcli_how_to_type = XkbcliTool("how-to-type") cls.xkbcli_how_to_type = XkbcliTool("how-to-type")
cls.xkbcli_compile_keymap = XkbcliTool("compile-keymap") cls.xkbcli_compile_keymap = XkbcliTool("compile-keymap")
cls.xkbcli_compile_compose = XkbcliTool("compile-compose")
cls.xkbcli_interactive_evdev = XkbcliTool( cls.xkbcli_interactive_evdev = XkbcliTool(
"interactive-evdev", "interactive-evdev",
skipIf=( skipIf=(
@ -197,6 +198,7 @@ class TestXkbcli(unittest.TestCase):
cls.xkbcli_list, cls.xkbcli_list,
cls.xkbcli_how_to_type, cls.xkbcli_how_to_type,
cls.xkbcli_compile_keymap, cls.xkbcli_compile_keymap,
cls.xkbcli_compile_compose,
cls.xkbcli_interactive_evdev, cls.xkbcli_interactive_evdev,
cls.xkbcli_interactive_x11, cls.xkbcli_interactive_x11,
cls.xkbcli_interactive_wayland, cls.xkbcli_interactive_wayland,

View File

@ -36,13 +36,23 @@ static void
usage(FILE *fp, char *progname) usage(FILE *fp, char *progname)
{ {
fprintf(fp, fprintf(fp,
"Usage: %s [--file FILE] [--locale LOCALE | --locale-from-env | --locale-from-setlocale]\n", "Usage: %s [--help] [--file FILE] [--locale LOCALE | --locale-from-env | --locale-from-setlocale]\n",
progname); progname);
fprintf(fp, fprintf(fp,
" --file - specify a file to load\n" "\n"
" --locale - specify the locale directly\n" "Compile a Compose file and print it\n"
" --locale-from-env - get the locale from the LC_ALL/LC_CTYPE/LANG environment variables (falling back to C)\n" "\n"
" --locale-from-setlocale - get the locale using setlocale(3)\n" "Options:\n"
" --help\n"
" Print this help and exit\n"
" --file FILE\n"
" Specify a Compose file to load\n"
" --locale LOCALE\n"
" Specify the locale directly\n"
" --locale-from-env\n"
" Get the locale from the LC_ALL/LC_CTYPE/LANG environment variables (falling back to C)\n"
" --locale-from-setlocale\n"
" Get the locale using setlocale(3)\n"
); );
} }
@ -88,6 +98,7 @@ main(int argc, char *argv[])
OPT_LOCALE_FROM_SETLOCALE, OPT_LOCALE_FROM_SETLOCALE,
}; };
static struct option opts[] = { static struct option opts[] = {
{"help", no_argument, 0, 'h'},
{"file", required_argument, 0, OPT_FILE}, {"file", required_argument, 0, OPT_FILE},
{"locale", required_argument, 0, OPT_LOCALE}, {"locale", required_argument, 0, OPT_LOCALE},
{"locale-from-env", no_argument, 0, OPT_LOCALE_FROM_ENV}, {"locale-from-env", no_argument, 0, OPT_LOCALE_FROM_ENV},
@ -162,7 +173,8 @@ main(int argc, char *argv[])
xkb_compose_table_new_from_locale(ctx, locale, xkb_compose_table_new_from_locale(ctx, locale,
XKB_COMPOSE_COMPILE_NO_FLAGS); XKB_COMPOSE_COMPILE_NO_FLAGS);
if (!compose_table) { if (!compose_table) {
fprintf(stderr, "Couldn't create compose from locale\n"); fprintf(stderr,
"Couldn't create compose from locale \"%s\"\n", locale);
goto out; goto out;
} }
} }

View File

@ -73,6 +73,13 @@ ___xkbcli_subcommand()
return;; return;;
esac esac
;; ;;
compile-compose)
case ${COMP_WORDS[COMP_CWORD-1]} in
--file)
_filedir
return;;
esac
;;
list) list)
if [[ ${COMP_WORDS[COMP_CWORD]} != -* ]]; then if [[ ${COMP_WORDS[COMP_CWORD]} != -* ]]; then
_filedir _filedir

View File

@ -0,0 +1,39 @@
.Dd November 7, 2023
.Dt XKBCLI\-COMPILE\-COMPOSE 1
.Os
.
.Sh NAME
.Nm "xkbcli compile-compose"
.Nd compile a Compose file
.
.Sh SYNOPSIS
.Nm
.Op Ar options
.
.Sh DESCRIPTION
.Nm
compile and print a Compose file based on the given options
.
.Bl -tag -width Ds
.It Fl \-help
Print help and exit
.
.It Fl \-file Ar FILE
Specify a Compose file to load
.
.It Fl \-locale Ar LOCALE
Specify a locale
.
.It Fl \-locale-from-env
Get the locale from the LC_ALL/LC_CTYPE/LANG environment variables
(falling back to C)
.
.It Fl \-locale\-from\-setlocale
Get the locale using
.Xr setlocale 3
.El
.
.Sh SEE ALSO
.Xr xkbcli 1 ,
.Xr Compose 5 ,
.Lk https://xkbcommon.org "The libxkbcommon online documentation"

View File

@ -30,7 +30,11 @@ Print the version and exit
.It Ic compile\-keymap .It Ic compile\-keymap
Compile an XKB keymap, see Compile an XKB keymap, see
.Xr xkbcli\-compile\-keymap 1 .Xr xkbcli\-compile\-keymap 1
.
.It Ic compile\-compose
Compile a compose file, see
.Xr xkbcli\-compile\-compose 1
.
.It Ic how\-to\-type .It Ic how\-to\-type
Show how to type a given Unicode codepoint, see Show how to type a given Unicode codepoint, see
.Xr xkbcli\-how\-to\-type 1 .Xr xkbcli\-how\-to\-type 1

View File

@ -66,6 +66,11 @@ usage(void)
" Compile an XKB keymap\n" " Compile an XKB keymap\n"
"\n" "\n"
#endif #endif
#if HAVE_XKBCLI_COMPILE_COMPOSE
" compile-compose\n"
" Compile a Compose file\n"
"\n"
#endif
#if HAVE_XKBCLI_HOW_TO_TYPE #if HAVE_XKBCLI_HOW_TO_TYPE
" how-to-type\n" " how-to-type\n"
" Print key sequences to type a Unicode codepoint\n" " Print key sequences to type a Unicode codepoint\n"