From e6282df1155e8d9b08b2e518a452c1997973f1ce Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 12 Nov 1999 15:28:24 +0000 Subject: manual/8630 --- Completion/Core/_style | 55 +++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'Completion/Core/_style') diff --git a/Completion/Core/_style b/Completion/Core/_style index b0cbd7b00..a3b54686f 100644 --- a/Completion/Core/_style +++ b/Completion/Core/_style @@ -1,45 +1,50 @@ #autoload -local tags get i +local all get val i + +# Should we return the value? if [[ "$1" = -g ]]; then get=yes shift fi -if (( ${+_cur_tags[${funcstack[2,-1]}]} )); then - tags="${_cur_tags[${funcstack[2,-1]}]}" -else - tags="${_cur_tags[${funcstack[3,-1]}]}" -fi +# Get all styles defined for this context. -if [[ "$tags" = *:${1}\[*\]:* ]]; then +all=() +for i in "${(s.:.)_cur_contexts}"; do + all=("$all[@]" "${(@)_compstyles[(K)${i},${1}]}" ) +done +all=":${(j.:.)${(@o)all:#}##??}:" - tags="${${tags#*:${1}\[}%%\]*}" +if [[ "$all" = *:${2}[:\=]* ]]; then - if [[ $# -eq 2 ]]; then - if [[ -n "$get" ]]; then - eval "${2}=\"$tags\"" - return 0 - fi + # We have a definition for the style. - [[ "$tags" = (|*,)${2}(|,*) ]] - return - fi + if [[ $# -eq 3 ]]; then + if [[ -n "$get" ]]; then - [[ "$tags" = (|*,)${2}(|(\=|,)*) ]] || return 1 + # We have to return the value. - if [[ -n "$get" ]]; then - if [[ "$tags" = (|*,)${2}\=* ]]; then - eval "${3}=\"${${tags#(|*,)${2}\=}%%,*}\"" + if [[ "$all" = *,${2}\=* ]]; then + eval "${3}=\"${${all#*:${2}\=}%%:*}\"" + else + eval "${3}=''" + fi else - eval "${3}=''" + + # We have to test the value. + + if [[ "$all" = *:${2}\=* ]]; then + [[ "${${all#*:${2}\=}%%:*}" = ${~3} ]] + else + [[ '' -eq ${~3} ]] + fi + + return fi - return 0 fi - - [[ "$tags" = (|*,)${2}\=(|[^,]#,)${3}(|,*) ]] - return + return 0 fi return 1 -- cgit 1.4.1