1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-10-03 17:31:33 +02:00
zsh/Completion/Base/_subscript

57 lines
1.5 KiB
Plaintext
Raw Normal View History

2000-04-01 22:43:43 +02:00
#compdef -subscript-
1999-04-15 20:05:38 +02:00
2000-04-01 22:43:43 +02:00
local expl
if [[ "$PREFIX" = :* ]]; then
_wanted characters expl 'character class' \
compadd -p: -S ':]' alnum alpha blank cntrl digit graph \
lower print punct space upper xdigit
elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
local suf
[[ "$RBUFFER" != \]* ]] && suf=']'
_wanted association-keys expl 'association key' \
2000-05-31 11:38:25 +02:00
compadd -S "$suf" -k "$compstate[parameter]"
2000-04-01 22:43:43 +02:00
elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
local list i j ret=1 disp
_tags indexes parameters
while _tags; do
if _requested indexes; then
ind=( {1..${#${(P)${compstate[parameter]}}}} )
if zstyle -T ":completion:${curcontext}:indexes" verbose; then
list=()
for i in "$ind[@]"; do
if [[ "$i" = ${PREFIX}*${SUFFIX} ]]; then
list=( "$list[@]"
"${i}:$(print -D ${(P)${compstate[parameter]}[$i]})" )
else
list=( "$list[@]" '' )
fi
done
zformat -a list ' -- ' "$list[@]"
disp=( -d list)
else
disp=()
fi
if [[ "$RBUFFER" = \]* ]]; then
_all_labels -V indexes expl 'array index' \
2000-05-31 11:38:25 +02:00
compadd -S '' "$disp[@]" -a ind && ret=0
2000-04-01 22:43:43 +02:00
else
_all_labels -V indexes expl 'array index' \
2000-05-31 11:38:25 +02:00
compadd -S ']' "$disp[@]" -a ind && ret=0
2000-04-01 22:43:43 +02:00
fi
fi
_requested parameters && _parameters && ret=0
(( ret )) || return 0
done
return 1
else
_compalso -math-
fi