From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 27727 invoked from network); 23 Jun 2020 21:51:59 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 23 Jun 2020 21:51:59 -0000 Received: (qmail 25784 invoked by alias); 23 Jun 2020 21:51:53 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: Sender: zsh-workers@zsh.org X-Seq: 46105 Received: (qmail 29728 invoked by uid 1010); 23 Jun 2020 21:51:52 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25850. spamassassin: 3.4.4. Clear:RC:0(205.235.26.22):SA:0(-2.6/5.0):. Processed in 0.789412 secs); 23 Jun 2020 21:51:52 -0000 X-Envelope-From: SRS0=9ziK=AE=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at bounces.park01.gkg.net designates 205.235.26.22 as permitted sender) X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 X-YMail-OSG: xPNv61EVM1nVZbPmDOWl3dSKApKPo7IxVEy8pENWyV1F9lfbqmWHxYrkHsHvcWn zz6DBdDl9wKET81q0UrBXbB8igihKwMuEarn.nCLolIwnB1q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KmUmFlgoh6PJ.xUF EvRbq_5WV.QmKKYdbuCna845Z0PjoZlYh_6wiZksZ5hOPJ8ai_fic8fWr1o5xEURj0jlihC3dA_A hj2.v33A9P1Tk5nI_DzuZIAFVejMd1G5Y94EQKdCJvq31vxO2aHAmT9TnknNr.MRWfnPfmD8FCWc YPKZQbZH4B8VEV.P94T7njy2qcgrbLksbAilwA4QY2wqnT0h7dxs5fT83dbWDcDDYtdcXhi5xSGq KLw-- From: Oliver Kiddle To: Zsh workers Subject: PATCH: new xinput completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <93725.1592949068.1@hydra> Date: Tue, 23 Jun 2020 23:51:08 +0200 Message-ID: <93726-1592949068.225836@YntL.qgxH.BU1M> References: <93726-1592949068.225836.ref@YntL.qgxH.BU1M> X-Mailer: WebService/1.1.16138 hermes_yahoo Apache-HttpAsyncClient/4.1.4 (Java/11.0.7) The display strings are somewhat unconventional with this for the input device list. The output is taken as-is which should be less fragile than trying to parse it and will work provided the output is one line per device. For device numbers, it will match strings similarly to process IDs. Oliver diff --git a/Completion/X/Command/_xinput b/Completion/X/Command/_xinput new file mode 100644 index 000000000..00a976d5d --- /dev/null +++ b/Completion/X/Command/_xinput @@ -0,0 +1,140 @@ +#compdef xinput + +local curcontext="$curcontext" xinput=${words[1]} desc subcmd out ret=1 +local match mbegin mend +local -a state state_descr line args cmds ids names disp expl +local -A opt_args + +cmds=( + 'get-feedbacks:display device feedbacks' + 'set-ptr-feedback:change pointer acceleration (or feedback) parameters ' + 'set-integer-feedback:change value of an integer device feedback' + 'get-button-map:get the button mapping of a device' + 'set-button-map:change the button mapping of a device' + set-pointer + "set-mode:set a device's mode" + 'list:list input devices or device features' + "query-state:query a device's state" + 'test:perpetual display of extended events from a device' + 'create-master:create a new pair of master devices on an XI2-enabled server' + 'remove-master:remove a master and its paired master device' + 'reattach:reattach a slave to a master' + 'float:remove a slave from its current master device' + 'set-cp:set the ClientPointer for the client owning window to master' + 'test-xi2:perpetual display of XI2 events' + 'map-to-output:restrict movements of the absolute device to an RandR crtc' + 'list-props:list properties that can be set for a device' + set-int-prop set-float-prop set-atom-prop + 'watch-props:perpetual display of property changes' + 'delete-prop:delete a property from a device' + 'set-prop:set a property to a given value' + 'disable:disable a device' + 'enable:enable a device' + 'help:display usage information' + 'version:display version information for program and server' +) + +if (( CURRENT == 2 )); then + if [[ -prefix - ]]; then + cmds=( --$^cmds ) + desc=option + else + desc=command + fi + _describe -t ${desc}s $desc cmds -M 'r:|-=* r:|=*' + return +fi + +subcmd=${words[2]#--} +curcontext="${curcontext%:*}-$subcmd:" + +args=( '1:device:->devices' ) +case $subcmd in + (set|delete)-*prop) args+=( '2:property:->properties' ) ;| + set-*prop) args+=( '*:value' ) ;| + set-ptr-feedback) args+=( '2:threshold' '3:num' '4:denom' ) ;; + set-integer-feedback) args+=( '2:feedback id' '3:value' ) ;; + set-button-map) + args+=( '*:::button mapping:compadd -F words -o numeric {1..12}' ) + ;; + set-pointer) args+=( '2:x index' '3:y index' ) ;; + set-mode) args+=( '2:mode:(ABSOLUTE RELATIVE)' ) ;; + list) args+=( '(-)--short' '(-)--long' '(-)--name-only' '(-)--id-only' ) ;; + test) args+=( '-proximity' ) ;; + create-master) + args=( + '1:prefix' + '2:send core events [1]:((0\:false 1\:true))' + '3:enable [1]:((0\:false 1\:true))' + ) + ;; + remove-master) + args=( + '1:master:->devices' + '2:slave setting:(Floating AttachToMaster)' + '3:pointer master:->devices' + '4:keyboard master:->devices' + ) + ;; + reattach) args=( '1:slave:->devices' '2:master:->devices' ) ;; + float) args=( '1:slave:->devices' ) ;; + set-cp) args=( '1:window:_x_window' '2:device:->devices' ) ;; + test-xi2) args+=( '--root[select events on the root window only]' ) ;; + map-to-output) args+=( '2:output:->outputs' ) ;; + list-props) args=( '*:device:->devices' ) ;; + set-int-prop) args+=( '3:format:compadd -o numeric 8 16 32' ) ;; + set-prop) + args+=( + '--type=-:type:(atom float int)' + '--format=-:format:compadd -o numeric 8 16 32' + ) + ;; + help|version) _message 'no more arguments'; return 1 ;; +esac + +shift words +(( CURRENT-- )) +_arguments -C -A "-*" $args && ret=0 + +case $state in + devices) + _description input-devices expl $state_descr + + ids=( ${${(f)"$(_call_program input-devices $xinput list --id-only)"}#? } ) + names=( ${${(f)"$(_call_program input-devices $xinput list --name-only)"}#? } ) + disp=( ${(f)"$(_call_program input-devices $xinput list --short)"} ) + + if [[ $PREFIX$SUFFIX = [^-]*[^0-9]* ]]; then + # match based on the names but insert IDs + compadd "$expl[@]" -M 'b:=* m:{[:lower:]}={[:upper:]}' -D ids -a names + compadd "$expl[@]" -M 'b:=* m:{[:lower:]}={[:upper:]}' -D disp -a names + compadd "$expl[@]" -U -ld disp -a ids && ret=0 + + zstyle -s ":completion:${curcontext}:input-devices" insert-ids out || out=menu + case "$out" in + menu) compstate[insert]=menu ;; + single) [[ $#ids -ne 1 && $compstate[insert] != menu ]] && + compstate[insert]= ;; + *) [[ ${#:-$PREFIX$SUFFIX} -gt ${#compstate[unambiguous]} ]] && + compstate[insert]=menu ;; + esac + else + compadd "$expl[@]" -M 'B:0=' -o nosort -ld disp -a ids && ret=0 + fi + ;; + properties) + _description input-properties expl 'property' + disp=( ${${${${(M)${(f)"$(_call_program input-properties + $xinput list-props $line[1] + )"}:#[[:blank:]]*}##[[:blank:]]#}%%:*}:/(#b)(*) \((<->)\)/$match[2]:$match[1]} + ) + _describe -t input-properties $state_descr disp -o numeric && ret=0 + ;; + outputs) + _description outputs expl 'output' + compadd "$expl[@]" - ${${(M)${(f)"$(_call_program outputs + xrandr)"}:#* connected*}%% *} && ret=0 + ;; +esac + +return ret