File tree Expand file tree Collapse file tree 6 files changed +115
-5
lines changed
Expand file tree Collapse file tree 6 files changed +115
-5
lines changed Original file line number Diff line number Diff line change @@ -570,6 +570,18 @@ if build_tools
570570 install_data (' tools/xkbcli-zsh-completion.zsh' ,
571571 rename : ' _xkbcli' ,
572572 install_dir : zsh_completion_path)
573+ install_data (' tools/xkb-model-zsh-completion.zsh' ,
574+ rename : ' _xkb_model' ,
575+ install_dir : zsh_completion_path)
576+ install_data (' tools/xkb-layout-zsh-completion.zsh' ,
577+ rename : ' _xkb_layout' ,
578+ install_dir : zsh_completion_path)
579+ install_data (' tools/xkb-variant-zsh-completion.zsh' ,
580+ rename : ' _xkb_variant' ,
581+ install_dir : zsh_completion_path)
582+ install_data (' tools/xkb-options-zsh-completion.zsh' ,
583+ rename : ' _xkb_options' ,
584+ install_dir : zsh_completion_path)
573585 endif
574586
575587 # Tool: compile-keymap
Original file line number Diff line number Diff line change 1+ # compdef -value-,XKB_DEFAULT_LAYOUT,-default-
2+
3+ local layouts_yaml
4+ layouts_yaml=" $( _call_program -l xkb-yaml xkbcli list) "
5+
6+ case $status in
7+ 127 ) _message " xkb layout completion requires xkbcli" && return 127 ;;
8+ <1->) _message " error listing xkb layouts" && return 1 ;;
9+ esac
10+
11+ local yq_prog=' .layouts[] | select(.variant == "") | "\(.layout):\(.description)"'
12+ local -a layouts
13+ layouts=( ${(@ f)" $( printf ' %s\n' $layouts_yaml | _call_program -l xkb-parse-yaml yq ${(q)yq_prog} ) " } )
14+
15+ case $status in
16+ 127 ) _message " xkb layout completion requires yq" && return 127 ;;
17+ <1->) _message " error completing xkb layouts" && return 1 ;;
18+ esac
19+
20+ _describe -t xkb-layout ' xkb layout' layouts " $@ "
Original file line number Diff line number Diff line change 1+ # compdef -value-,XKB_DEFAULT_MODEL,-default-
2+
3+ local models_yaml
4+ models_yaml=" $( _call_program -l xkb-yaml xkbcli list) "
5+
6+ case $status in
7+ 127 ) _message " xkb model completion requires xkbcli" && return 127 ;;
8+ <1->) _message " error listing xkb models" && return 1 ;;
9+ esac
10+
11+ local yq_prog=' .models[] | "\(.name):\(.description)"'
12+ local -a models
13+ models=( ${(@ f)" $( printf ' %s\n' $models_yaml | _call_program -l xkb-parse-yaml yq ${(q)yq_prog} ) " } )
14+ case $status in
15+ 127)
16+ local sed_models=' /^models:/,/^$/p' sed_names=' s/- name: //p' sed_descriptions=' s/ description: //p'
17+ local models_sed=" $( printf ' %s\n' $models_yaml | _call_program -l sed sed -n ${(q)sed_models} ) "
18+ local -a model_names=( ${(@ f)" $( printf ' %s\n' $models_sed | _call_program -l sed-names sed -n ${(q)sed_names} ) " } )
19+ local -a model_descriptions=( ${(@ f)" $( printf ' %s\n' $models_sed | _call_program -l sed-models sed -n ${(q)sed_descriptions} ) " } )
20+ printf -v models ' %s:%s' ${model_names: ^model_descriptions}
21+ ;;
22+
23+ <1->) _message " error completing xkb models" && return 1 ;;
24+ esac
25+
26+ _describe -t xkb-model ' xkb model' models " $@ "
Original file line number Diff line number Diff line change 1+ # compdef -value-,XKB_DEFAULT_OPTIONS,-default-
2+
3+ local options_yaml
4+ options_yaml=" $( _call_program -l xkb-yaml xkbcli list) "
5+
6+ case $status in
7+ 127 ) _message " xkb option completion requires xkbcli" && return 127 ;;
8+ <1->) _message " error listing xkb options" && return 1 ;;
9+ esac
10+
11+ local yq_prog=' .option_groups[] | "\(.name)[\(.description)]: :->option-\(.name)"'
12+ local -a option_groups
13+ option_groups=( ${(@ f)" $( printf ' %s\n' $options_yaml | _call_program -l xkb-parse-yaml yq ${(q)yq_prog} ) " } )
14+
15+ case $status in
16+ 127 ) _message " xkb option completion requires yq" && return 127 ;;
17+ <1->) _message " error completing xkb options" && return 1 ;;
18+ esac
19+
20+ local context state state_descr line
21+ typeset -A val_args
22+
23+ _values -S: ' xkb option' ${option_groups: s/ Compose key/ compose}
24+ if [[ $state == option-* ]]; then
25+ local -a xkb_options
26+ yq_prog=' .option_groups[] | select(.name == "' ${state# option-} ' ").options[] | "\(.name):\(.description)"'
27+ xkb_options=( ${(@ f)" $( printf ' %s\n' $options_yaml | _call_program -l xkb-parse-yaml yq ${(q)yq_prog} ) " } )
28+ xkb_options=( ${xkb_options#*: } )
29+ _describe -t xkb-option ' xkb option' xkb_options
30+ fi
Original file line number Diff line number Diff line change 1+ # compdef -value-,XKB_DEFAULT_VARIANT,-default-
2+
3+ local variants_yaml
4+ variants_yaml=" $( _call_program -l xkb-yaml xkbcli list) "
5+
6+ case $status in
7+ 127 ) _message " xkb model completion requires xkbcli" && return 127 ;;
8+ <1->) _message " error listing xkb variants" && return 1 ;;
9+ esac
10+
11+ local yq_prog1=' .layouts[] | select(.variant != "") | "\(.layout)(\(.variant)):\(.description)"'
12+ local yq_prog2=' .layouts[] | select(.variant != "") | "\(.variant):\(.description)"'
13+ local -a variants1 variants2
14+ variants1=( ${(@ f)" $( printf ' %s\n' $variants_yaml | _call_program -l xkb-parse-yaml yq ${(q)yq_prog1} ) " } )
15+ variants2=( ${(@ f)" $( printf ' %s\n' $variants_yaml | _call_program -l xkb-parse-yaml yq ${(q)yq_prog2} ) " } )
16+
17+ case $status in
18+ 127 ) _message " xkb model completion requires yq" && return 127 ;;
19+ <1->) _message " error completing xkb variants" && return 1 ;;
20+ esac
21+
22+ _describe -t xkb-model ' xkb model' variants1 variants2 " $@ "
Original file line number Diff line number Diff line change @@ -23,11 +23,11 @@ _xkbcli_commands() {
2323}
2424
2525local -a rmlvo_opts_common=(
26- ' --rules=[the XKB ruleset]:rules:()'
27- ' --model=[the XKB model]:model:() '
28- ' --layout=[the XKB layout]:layout:() '
29- ' --variant=[the XKB variant]:variant:() '
30- ' --options=[the XKB options]:options:() '
26+ ' --rules=[the XKB ruleset]:rules:(base evdev )'
27+ ' --model=[the XKB model]:model:_xkb_model '
28+ ' --layout=[the XKB layout]:layout:_xkb_layout '
29+ ' --variant=[the XKB variant]:variant:_xkb_variant '
30+ ' --options=[the XKB options]:options:_xkb_options '
3131 ' --enable-environment-names[set the default RMLVO values from the environment]'
3232)
3333
You can’t perform that action at this time.
0 commit comments