diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-12 15:28:24 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-12 15:28:24 +0000 |
commit | e6282df1155e8d9b08b2e518a452c1997973f1ce (patch) | |
tree | b0c8ed7e8512cc4397ae7df6d138ea66147565b3 /Completion/Base/_subscript | |
parent | 167b0ae3b98938f75287dcf2e112d41a03532c5f (diff) | |
download | zsh-e6282df1155e8d9b08b2e518a452c1997973f1ce.tar.gz zsh-e6282df1155e8d9b08b2e518a452c1997973f1ce.tar.xz zsh-e6282df1155e8d9b08b2e518a452c1997973f1ce.zip |
manual/8630
Diffstat (limited to 'Completion/Base/_subscript')
-rw-r--r-- | Completion/Base/_subscript | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/Completion/Base/_subscript b/Completion/Base/_subscript index 803893912..c5c6ca7e9 100644 --- a/Completion/Base/_subscript +++ b/Completion/Base/_subscript @@ -3,10 +3,14 @@ local expl if [[ "$PREFIX" = :* ]]; then + _tags any char-classes || return 1 + _description expl 'character class' compadd "$expl[@]" -p: -S ':]' alnum alpha blank cntrl digit graph \ lower print punct space upper xdigit elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then + _tags any association-keys || return 1 + _description expl 'association key' if [[ "$RBUFFER" = \]* ]]; then compadd "$expl[@]" -S '' - "${(@kP)${compstate[parameter]}}" @@ -14,22 +18,39 @@ elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then compadd "$expl[@]" -S ']' - "${(@kP)${compstate[parameter]}}" fi elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then - local list i j - - _description expl 'array index' - ind=( {1..${#${(P)${compstate[parameter]}}}} ) - list=() - for i in "$ind[@]"; do - [[ "$i" = ${PREFIX}*${SUFFIX} ]] && - list=( "$list[@]" - "${(r:4:: ::):)i} $(print -D ${(P)${compstate[parameter]}[$i]})" ) + local list i j ret=1 disp + + _tags any indexes parameters + + while _tags; do + if _requested indexes; then + _description -V expl 'array index' + ind=( {1..${#${(P)${compstate[parameter]}}}} ) + if _style indexes description yes; then + list=() + for i in "$ind[@]"; do + [[ "$i" = ${PREFIX}*${SUFFIX} ]] && + list=( "$list[@]" + "${i}:$(print -D ${(P)${compstate[parameter]}[$i]})" ) + done + compdisplay list ' -- ' "$list[@]" + disp=( -d list) + else + disp=() + fi + + if [[ "$RBUFFER" = \]* ]]; then + compadd "$expl[@]" -S '' "$disp[@]" - "$ind[@]" && ret=0 + else + compadd "$expl[@]" -S ']' "$disp[@]" - "$ind[@]" && ret=0 + fi + fi + _requested parameters && _parameters && ret=0 + + (( ret )) || return 0 done - if [[ "$RBUFFER" = \]* ]]; then - compadd "$expl[@]" -S '' -V default -d list - "$ind[@]" - else - compadd "$expl[@]" -S ']' -V default -d list - "$ind[@]" - fi + return 1 else _compalso -math- fi |