From 0bc58b66a4850cdb8458a86c3d9a2fc81de82aa3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:14:42 +0200 Subject: Adding upstream version 1:2.11. Signed-off-by: Daniel Baumann --- completions/povray | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 completions/povray (limited to 'completions/povray') diff --git a/completions/povray b/completions/povray new file mode 100644 index 0000000..56dfd94 --- /dev/null +++ b/completions/povray @@ -0,0 +1,64 @@ +# povray completion -*- shell-script -*- +# by "David Necas (Yeti)" + +_povray() +{ + local cur prev words cword + _init_completion || return + + local povcur=$cur pfx oext defoext + defoext=png # default output extension, if cannot be determined FIXME + + _expand || return + + case $povcur in + [-+]I*) + cur="${povcur#[-+]I}" # to confuse _filedir + pfx="${povcur%"$cur"}" + _filedir pov + COMPREPLY=(${COMPREPLY[@]/#/$pfx}) + return + ;; + [-+]O*) + # guess what output file type user may want + case $( + IFS=$'\n' + command grep '^[-+]F' <<<"${words[*]}" + ) in + [-+]FN) oext=png ;; + [-+]FP) oext=ppm ;; + [-+]F[CT]) oext=tga ;; + *) oext=$defoext ;; + esac + # complete filename corresponding to previously specified +I + COMPREPLY=($( + IFS=$'\n' + command grep '^[-+]I' <<<"${words[*]}" + )) + COMPREPLY=(${COMPREPLY[@]#[-+]I}) + COMPREPLY=(${COMPREPLY[@]/%.pov/.$oext}) + cur="${povcur#[-+]O}" # to confuse _filedir + pfx="${povcur%"$cur"}" + _filedir $oext + COMPREPLY=(${COMPREPLY[@]/#/$pfx}) + return + ;; + *.ini\[ | *.ini\[*[^]]) # sections in .ini files + cur="${povcur#*\[}" + pfx="${povcur%\["$cur"}" # prefix == filename + [[ -r $pfx ]] || return + COMPREPLY=($(command sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \ + -e 't' -e 'd' -- "$pfx")) + # to prevent [bar] expand to nothing. can be done more easily? + COMPREPLY=("${COMPREPLY[@]/#/${pfx}[}") + return + ;; + *) + _filedir '@(ini|pov)' + return + ;; + esac +} && + complete -F _povray povray xpovray spovray + +# ex: filetype=sh -- cgit v1.2.3