completions/zsh: add input commands

This commit is contained in:
novakane 2021-06-14 12:26:59 +02:00 committed by Isaac Freund
parent f3024d9198
commit db35f700a8

View file

@ -1,18 +1,12 @@
#compdef riverctl
#
# Completion script for riverctl, part of river <https://github.com/ifreund/river>
_riverctl_subcommands()
{
local -a riverctl_subcommands
_riverctl() {
_next_prev() { _alternative 'arguments:args:(next previous)' }
_orientations() { _alternative 'arguments:args:(up down left right)' }
_hor_ver() { _alternative 'arguments:args:(horizontal vertical)' }
_attach() { _alternative 'arguments:args:(top bottom)' }
_focus_cursor() { _alternative 'arguments:args:(disabled normal strict)' }
_river_opts() { _alternative 'arguments:args:(-output -focused-output)' }
local -a _cmds
_cmds=(
riverctl_subcommands=(
# Actions
'close:Close the focused view'
'csd-filter-add:Add app-id to the CSD filter list'
@ -56,35 +50,98 @@ _riverctl() {
'opacity:Configure server-side opacity of views'
'set-repeat:Set the keyboard repeat rate and repeat delay'
'xcursor-theme:Set the xcursor theme'
# Input
'input:Configure input devices'
'list-inputs:List all input devices'
'list-input-configs:List all input configurations'
)
local -A opt_args
_describe -t command 'command' riverctl_subcommands
}
_arguments -C '*:: :->_cmds'
_riverctl_input_subcommands()
{
local -a input_subcommands
if (( CURRENT == 1 )); then
_describe -t commands "commands" _cmds
return
fi
input_subcommands=(
'events:Configure whether the input devices events will be used by river'
'accel-profile:Set the pointer acceleration profile'
'pointer-accel:Set the pointer acceleration factor'
'click-method:Set the click method'
'drag:Enable or disable the tap-and-drag functionality'
'drag-lock:Enable or disable the drag lock functionality'
'disable-while-typing:Enable or disable the disable-while-typing functionality'
'middle-emulation:Enable or disable the middle click emulation functionality'
'natural-scroll:Enable or disable the natural scroll functionality'
'left-handed:Enable or disable the left handed mode'
'tap:Enable or disable the tap functionality'
'tap-button-map:Configure the button mapping for tapping'
'scroll-method:Set the scroll method'
'scroll-button:Set the scroll button'
)
_describe -t command 'command' input_subcommands
}
_riverctl_input()
{
local state
_arguments \
'1: :->commands' \
'*:: :->args'
case $state in
commands) _alternative 'common-commands:common:_riverctl_input_subcommands' ;;
args)
case "$words[1]" in
focus-output) _next_prev ;;
focus-view) _next_prev ;;
move) _orientations ;;
resize) _hor_ver ;;
snap) _orientations ;;
send-to-output) _next_prev ;;
swap) _next_prev ;;
map) _alternative 'arguments:optional:(-release)' ;;
unmap) _alternative 'arguments:optional:(-release)' ;;
attach-mode) _attach ;;
focus-follows-cursor) _focus_cursor ;;
get-option) _river_opts ;;
set-option) _river_opts ;;
unset-option) _river_opts ;;
mod-option) _river_opts ;;
events) _alternative 'input-cmds:args:(enabled disabled disabled-on-external-mouse)' ;;
accel-profile) _alternative 'input-cmds:args:(none flat adaptive)' ;;
click-method) _alternative 'input-cmds:args:(none button-area clickfinger)' ;;
drag) _alternative 'input-cmds:args:(enabled disabled)' ;;
drag-lock) _alternative 'input-cmds:args:(enabled disabled)' ;;
disable-while-typing) _alternative 'input-cmds:args:(enabled disabled)' ;;
middle-emulation) _alternative 'input-cmds:args:(enabled disabled)' ;;
natural-scroll) _alternative 'input-cmds:args:(enabled disabled)' ;;
left-handed) _alternative 'input-cmds:args:(enabled disabled)' ;;
tap) _alternative 'input-cmds:args:(enabled disabled)' ;;
tap-button-map) _alternative 'input-cmds:args:(left-right-middle left-middle-right)' ;;
scroll-method) _alternative 'input-cmds:args:(none two-finger edge button)' ;;
*) return 0 ;;
esac
return 1
;;
esac
}
_riverctl()
{
local state
_arguments \
'1: :->commands' \
'*:: :->args'
case $state in
commands) _alternative 'common-commands:common:_riverctl_subcommands' ;;
args)
case "$words[1]" in
focus-output) _alternative 'arguments:args:(next previous)' ;;
focus-view) _alternative 'arguments:args:(next previous)' ;;
input) _riverctl_input ;;
move) _alternative 'arguments:args:(up down left right)' ;;
resize) _alternative 'arguments:args:(horizontal vertical)' ;;
snap) _alternative 'arguments:args:(up down left right)' ;;
send-to-output) _alternative 'arguments:args:(next previous)' ;;
swap) _alternative 'arguments:args:(next previous)' ;;
map) _alternative 'arguments:optional:(-release)' ;;
unmap) _alternative 'arguments:optional:(-release)' ;;
attach-mode) _alternative 'arguments:args:(top bottom)' ;;
focus-follows-cursor) _alternative 'arguments:args:(disabled normal strict)' ;;
*) return 0 ;;
esac
;;
esac
}
_riverctl "$@"