iron out bugs in the new rendered; rename TRANSFORMER to EXPANSION

pull/145/head
romkatv 6 years ago
parent 0891841e75
commit 996316a6fc

@ -129,7 +129,7 @@ _p9k_escape_rcurly() {
} }
_p9k_escape() { _p9k_escape() {
_P9K_RETVAL="\${(Q)\${:-${(qqq)${(q)1}}}}" [[ $1 == *["~!#\$^&*()\\\"'<>?{}[]"]* ]] && _P9K_RETVAL="\${(Q)\${:-${(qqq)${(q)1}}}}" || _P9K_RETVAL=$1
} }
# Begin a left prompt segment. # Begin a left prompt segment.
@ -160,13 +160,25 @@ left_prompt_segment() {
_p9k_get_icon LEFT_SUBSEGMENT_SEPARATOR _p9k_get_icon LEFT_SUBSEGMENT_SEPARATOR
local subsep=$_P9K_RETVAL local subsep=$_P9K_RETVAL
local icon_
if [[ -n $5 ]]; then
_p9k_get_icon $5
_p9k_escape $_P9K_RETVAL
icon_=$_P9K_RETVAL
fi
local line_start=$POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL local line_start=$POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL
[[ -n $line_start ]] && line_start="%b%k%F{$bg_color}$line_start" [[ -n $line_start ]] && line_start="%k%F{$bg_color}$line_start"
local style=%b$bg$fg local style=%b$bg$fg
_p9k_escape_rcurly $style _p9k_escape_rcurly $style
local style_=$_P9K_RETVAL local style_=$_P9K_RETVAL
local space=$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS
[[ $space == *%* ]] && space+=$style
_p9k_escape $space
local space_=$_P9K_RETVAL
local state=${(U)${1}#prompt_} local state=${(U)${1}#prompt_}
# Segment separator logic: # Segment separator logic:
@ -175,79 +187,78 @@ left_prompt_segment() {
# 1 # 1
# elif (( joined )); then # elif (( joined )); then
# 2 # 2
# elif [[ $bg_color == $_P9K_BG ]]; then # elif [[ $bg_color == (${_P9K_BG}|${_P9K_BG:-0}) ]]; then
# 3 # 3
# else # else
# 4 # 4
# fi # fi
local t=$#_P9K_T local t=$#_P9K_T
_P9K_T+=$line_start # 1 _P9K_T+=$line_start$style$space # 1
_P9K_T+='' # 2 _P9K_T+=$style # 2
if [[ -z $fg_color ]]; then if [[ -z $fg_color ]]; then
_p9k_foreground $DEFAULT_COLOR _p9k_foreground $DEFAULT_COLOR
_P9K_T+=%b$bg$_P9K_RETVAL$subsep # 3 _P9K_T+=$bg$_P9K_RETVAL$subsep$style$space # 3
else else
_P9K_T+=$style$subsep # 3 _P9K_T+=$bg$fg$subsep$style$space # 3
fi fi
_p9k_get_icon LEFT_SEGMENT_SEPARATOR _p9k_get_icon LEFT_SEGMENT_SEPARATOR
_P9K_T+=%b$bg%F{\$_P9K_BG}$_P9K_RETVAL # 4 _P9K_T+=$bg$_P9K_RETVAL$style$space # 4
local p= local p=
p+="\${_P9K_N::=}\${_P9K_F::=}"
local p='${P9K_VISUAL_IDENTIFIER::=' p+="\${\${\${_P9K_BG:-0}:#NONE}:-\${_P9K_N::=$((t+1))}}" # 1
if [[ -n $5 ]]; then p+="\${_P9K_N:=\${\${\$((_P9K_I>=$_P9K_LEFT_JOIN[$2])):#0}:+$((t+2))}}" # 2
_p9k_get_icon $5 p+="\${_P9K_N:=\${\${(M)\${:-x$bg_color}:#x(\$_P9K_BG|\${_P9K_BG:-0})}:+$((t+3))}}" # 3
[[ -n $_P9K_RETVAL ]] && p+="\${(Q)\${:-${(qqq)${(q)_P9K_RETVAL}}}}" p+="\${_P9K_N:=\${\${_P9K_F::=%F{\$_P9K_BG\}}:+$((t+4))}}" # 4
p+="\${_P9K_I::=$2}\${_P9K_BG::=$bg_color}"
local icon_exp=POWERLEVEL9K_${state}_VISUAL_IDENTIFIER_EXPANSION
(( $+parameters[$icon_exp] )) && icon_exp=${(P)icon_exp} || icon_exp='${P9K_VISUAL_IDENTIFIER}'
local content_exp=POWERLEVEL9K_${state}_CONTENT_EXPANSION
(( $+parameters[$content_exp] )) && content_exp=${(P)content_exp} || content_exp='${P9K_CONTENT}'
if [[ $icon_exp == '${P9K_VISUAL_IDENTIFIER}' && $content_exp == '${P9K_CONTENT}' ]]; then
p+="\${_P9K_V::=$icon_"
[[ $icon_ == *%* ]] && p+=$style_
p+="}"
else
p+="\${P9K_VISUAL_IDENTIFIER::=$icon}\${_P9K_V::=$icon_exp$style_}"
fi fi
p+='}'
p+="\${_P9K_N::=}" p+="\${_P9K_C::=$content_exp}"
p+="\${\${\${_P9K_BG:-0}:#NONE}:-\${_P9K_N::=$((t+1))}}" # 1
p+="\${_P9K_N:=\${\${\$((_P9K_I>=$_P9K_LEFT_JOIN[$2])):#0}:+$((t+2))}}" # 2
p+="\${_P9K_N:=\${\${\$((!\${#\${:-0\$_P9K_BG}:#0$bg_color})):#0}:+$((t+3))}}" # 3
p+="\${_P9K_N:=$((t+4))}" # 4
p+="\${_P9K_I::=$2}"
p+='${_P9K_C::='
local var=POWERLEVEL9K_${state}_CONTENT_TRANSFORMER
(( $+parameters[$var] )) && p+=${(P)var} || p+='${P9K_CONTENT}'
p+='}'
p+='${_P9K_V::='
local var=POWERLEVEL9K_${state}_VISUAL_IDENTIFIER_TRANSFORMER
(( $+parameters[$var] )) && p+=${(P)var} || p+='${P9K_P9K_VISUAL_IDENTIFIER}'
p+='}'
_p9k_escape $POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS
local space_=$_P9K_RETVAL
p+='}+}' p+='}+}'
_p9k_get_icon ${state}_PREFIX _p9k_get_icon ${state}_PREFIX
_p9k_escape $_P9K_RETVAL _p9k_escape $_P9K_RETVAL
p+="\${_P9K_T[\$_P9K_N]}$style_$space_$style_$_P9K_RETVAL" p+="%b\${_P9K_F}\${_P9K_T[\$_P9K_N]}$_P9K_RETVAL"
[[ $_P9K_RETVAL == *%* ]] && local -i need_style=1 || local -i need_style=0
_p9k_color $fg_color $1 VISUAL_IDENTIFIER_COLOR _p9k_color $fg_color $1 VISUAL_IDENTIFIER_COLOR
_p9k_foreground $_P9K_RETVAL _p9k_foreground $_P9K_RETVAL
_p9k_escape %b$bg$_P9K_RETVAL _p9k_escape_rcurly %b$bg$_P9K_RETVAL
p+="$_P9K_RETVAL\$_P9K_V$style_" [[ $_P9K_RETVAL != $style_ || $need_style == 1 ]] && p+=$_P9K_RETVAL
p+="\$_P9K_V"
# TODO: Fix this. Output space only if _P9K_V and _P9K_C are both non-empty. p+='${${(%):-$_P9K_V%1(l.${(%):-$_P9K_C%1(l. .x)}.x)}[-1]:#x}'
p+='${${(%):-$_P9K_V%1(l. .x)}[-1]:#x}'
_p9k_get_icon ${state}_SUFFIX _p9k_get_icon ${state}_SUFFIX
_p9k_escape $_P9K_RETVAL _p9k_escape $_P9K_RETVAL
p+="\${_P9K_C}$style_$_P9K_RETVAL$style_$space_\${\${_P9K_BG::=$bg_color}+}" p+="\${_P9K_C}$style_$_P9K_RETVAL"
[[ $_P9K_RETVAL == *%* ]] && p+=$style_
p+='}' p+=$space_
_p9k_cache_set "$p" _p9k_cache_set "$p"
fi fi
(( $6 )) && local content=$8 || local content="\${(Q)\${:-${(qqq)${(q)8}}}}" (( $6 )) && _P9K_RETVAL=$8 || _p9k_escape $8
_P9K_PROMPT+="\${\${:-${7:-1}}:+\${\${:-\${P9K_CONTENT::=$content}$_P9K_CACHE_VAL[1]" if [[ -z $7 ]]; then
_P9K_PROMPT+="\${\${:-\${P9K_CONTENT::=$_P9K_RETVAL}$_P9K_CACHE_VAL[1]"
else
_P9K_PROMPT+="\${\${:-$7}:+\${\${:-\${P9K_CONTENT::=$_P9K_RETVAL}$_P9K_CACHE_VAL[1]}"
fi
} }
# The same as left_prompt_segment above but for the right prompt. # The same as left_prompt_segment above but for the right prompt.
@ -320,7 +331,7 @@ right_prompt_segment() {
local space=$_P9K_RETVAL local space=$_P9K_RETVAL
fi fi
local tr=POWERLEVEL9K_${state}_CONTENT_TRANSFORMER local tr=POWERLEVEL9K_${state}_CONTENT_EXPANSION
(( $+parameters[$tr] )) && tr=${(P)tr} || tr='${P9K_CONTENT}' (( $+parameters[$tr] )) && tr=${(P)tr} || tr='${P9K_CONTENT}'
_p9k_get_icon ${state}_SUFFIX _p9k_get_icon ${state}_SUFFIX

Loading…
Cancel
Save