1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 12:20:07 +00:00

make frame hidable

This commit is contained in:
romkatv 2019-11-03 13:14:16 +01:00
parent 5262ddc07e
commit a2657e339a
2 changed files with 34 additions and 30 deletions

View file

@ -74,14 +74,10 @@ function p10k-on-post-prompt() {
p10k display line1=hide right=hide segment:time=show p10k display line1=hide right=hide segment:time=show
} }
TODO: hiding gap kills right prompt; this is bad; implement it like ruler, with 3 values in _p9k_t?
TODO: add 1/right_frame
TODO: 2/left should kill the trailing space.
empty_line empty_line
ruler ruler
1 1
1/gap 1/left_frame
1/left 1/left
1/right 1/left/time
1/right/time 1/gap

View file

@ -4775,14 +4775,16 @@ _p9k_build_gap_post() {
local exp=POWERLEVEL9K_MULTILINE_${(U)kind}_PROMPT_GAP_EXPANSION local exp=POWERLEVEL9K_MULTILINE_${(U)kind}_PROMPT_GAP_EXPANSION
(( $+parameters[$exp] )) && exp=${(P)exp} || exp='${P9K_GAP}' (( $+parameters[$exp] )) && exp=${(P)exp} || exp='${P9K_GAP}'
[[ $char == '.' ]] && local s=',' || local s='.' [[ $char == '.' ]] && local s=',' || local s='.'
_p9k_ret='${${_p9k__'$1$'g+\n}:-'$style'${${${_p9k_m:#-*}:+' _p9k_ret=$'${${_p9k__g+\n}:-'$style'${${${_p9k_m:#-*}:+'
_p9k_ret+='${${_p9k__'$1'g+${(pl.$((_p9k_m+1)).. .)}}:-'
if [[ $exp == '${P9K_GAP}' ]]; then if [[ $exp == '${P9K_GAP}' ]]; then
_p9k_ret+='${(pl'$s'$((_p9k_m+1))'$s$s$char$s$')}' _p9k_ret+='${(pl'$s'$((_p9k_m+1))'$s$s$char$s')}'
else else
_p9k_ret+='${${P9K_GAP::=${(pl'$s'$((_p9k_m+1))'$s$s$char$s$')}}+}' _p9k_ret+='${${P9K_GAP::=${(pl'$s'$((_p9k_m+1))'$s$s$char$s')}}+}'
_p9k_ret+='${:-"'$exp'"}' _p9k_ret+='${:-"'$exp'"}'
style=1 style=1
fi fi
_p9k_ret+='}'
if (( __p9k_ksh_arrays )); then if (( __p9k_ksh_arrays )); then
_p9k_ret+=$'$_p9k_rprompt${_p9k_t[$((!_p9k_ind))]}}:-\n}' _p9k_ret+=$'$_p9k_rprompt${_p9k_t[$((!_p9k_ind))]}}:-\n}'
else else
@ -4828,7 +4830,7 @@ _p9k_init_lines() {
_p9k_get_icon 'prompt_empty_line' LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL $_p9k_ret _p9k_get_icon 'prompt_empty_line' LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL $_p9k_ret
_p9k_escape $_p9k_ret _p9k_escape $_p9k_ret
_p9k_line_prefix_left+='${_p9k__'$i'l-${${:-${_p9k_bg::=NONE}${_p9k_i::=0}${_p9k_sss::=%f'$_p9k_ret'}}+}' _p9k_line_prefix_left+='${_p9k__'$i'l-${${:-${_p9k_bg::=NONE}${_p9k_i::=0}${_p9k_sss::=%f'$_p9k_ret'}}+}'
_p9k_line_suffix_left+='%b%k$_p9k_sss%b%k%f}' _p9k_line_suffix_left+='%b%k$_p9k_sss%b%k%f'
_p9k_escape ${(g::)POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL} _p9k_escape ${(g::)POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL}
[[ -n $_p9k_ret ]] && _p9k_line_never_empty_right+=1 || _p9k_line_never_empty_right+=0 [[ -n $_p9k_ret ]] && _p9k_line_never_empty_right+=1 || _p9k_line_never_empty_right+=0
@ -4848,6 +4850,8 @@ _p9k_init_lines() {
fi fi
fi fi
for i in {1..$num_lines}; do _p9k_line_suffix_left[i]+='}'; done
if (( num_lines > 1 )); then if (( num_lines > 1 )); then
for i in {1..$((num_lines-1))}; do for i in {1..$((num_lines-1))}; do
_p9k_build_gap_post $i _p9k_build_gap_post $i
@ -4858,7 +4862,7 @@ _p9k_init_lines() {
_p9k_get_icon '' MULTILINE_FIRST_PROMPT_PREFIX _p9k_get_icon '' MULTILINE_FIRST_PROMPT_PREFIX
[[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f [[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f
# Not escaped for historical reasons. # Not escaped for historical reasons.
_p9k_ret='${:-"'$_p9k_ret'"}' _p9k_ret='${_p9k__1l_frame-"'$_p9k_ret'"}'
_p9k_line_prefix_left[1]=$_p9k_ret$_p9k_line_prefix_left[1] _p9k_line_prefix_left[1]=$_p9k_ret$_p9k_line_prefix_left[1]
fi fi
@ -4866,23 +4870,21 @@ _p9k_init_lines() {
_p9k_get_icon '' MULTILINE_LAST_PROMPT_PREFIX _p9k_get_icon '' MULTILINE_LAST_PROMPT_PREFIX
[[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f [[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f
# Not escaped for historical reasons. # Not escaped for historical reasons.
_p9k_ret='${:-"'$_p9k_ret'"}' _p9k_ret='${_p9k__'$num_lines'l_frame-"'$_p9k_ret'"}'
_p9k_line_prefix_left[-1]=$_p9k_ret$_p9k_line_prefix_left[-1] _p9k_line_prefix_left[-1]=$_p9k_ret$_p9k_line_prefix_left[-1]
fi fi
_p9k_get_icon '' MULTILINE_FIRST_PROMPT_SUFFIX _p9k_get_icon '' MULTILINE_FIRST_PROMPT_SUFFIX
if [[ -n $_p9k_ret ]]; then if [[ -n $_p9k_ret ]]; then
[[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f [[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f
_p9k_escape $_p9k_ret _p9k_line_suffix_right[1]+='${_p9k__1r_frame-'${(qqq)_p9k_ret}'}'
_p9k_line_suffix_right[1]+=$_p9k_ret
_p9k_line_never_empty_right[1]=1 _p9k_line_never_empty_right[1]=1
fi fi
_p9k_get_icon '' MULTILINE_LAST_PROMPT_SUFFIX _p9k_get_icon '' MULTILINE_LAST_PROMPT_SUFFIX
if [[ -n $_p9k_ret ]]; then if [[ -n $_p9k_ret ]]; then
[[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f [[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f
_p9k_escape $_p9k_ret _p9k_line_suffix_right[-1]+='${_p9k__'$num_lines'r_frame-'${(qqq)_p9k_ret}'}'
_p9k_line_suffix_right[-1]+=$_p9k_ret
_p9k_line_never_empty_right[-1]=1 _p9k_line_never_empty_right[-1]=1
fi fi
@ -4890,16 +4892,18 @@ _p9k_init_lines() {
if [[ $+POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX == 1 || $_POWERLEVEL9K_PROMPT_ON_NEWLINE == 1 ]]; then if [[ $+POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX == 1 || $_POWERLEVEL9K_PROMPT_ON_NEWLINE == 1 ]]; then
_p9k_get_icon '' MULTILINE_NEWLINE_PROMPT_PREFIX _p9k_get_icon '' MULTILINE_NEWLINE_PROMPT_PREFIX
[[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f [[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f
for i in {2..$((num_lines-1))}; do
# Not escaped for historical reasons. # Not escaped for historical reasons.
_p9k_ret='${:-"'$_p9k_ret'"}' _p9k_line_prefix_left[i]='${_p9k__'$i'l_frame-"'$_p9k_ret'"}'$_p9k_line_prefix_left[i]
_p9k_line_prefix_left[2,-2]=$_p9k_ret${^_p9k_line_prefix_left[2,-2]} done
fi fi
_p9k_get_icon '' MULTILINE_NEWLINE_PROMPT_SUFFIX _p9k_get_icon '' MULTILINE_NEWLINE_PROMPT_SUFFIX
if [[ -n $_p9k_ret ]]; then if [[ -n $_p9k_ret ]]; then
[[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f [[ _p9k_ret == *%* ]] && _p9k_ret+=%b%k%f
_p9k_escape $_p9k_ret for i in {2..$((num_lines-1))}; do
_p9k_line_suffix_right[2,-2]=${^_p9k_line_suffix_right[2,-2]}$_p9k_ret _p9k_line_suffix_right[i]+='${_p9k__'$i'r_frame-'${(qqq)_p9k_ret}'}'
done
_p9k_line_never_empty_right[2,-2]=${(@)_p9k_line_never_empty_right[2,-2]/0/1} _p9k_line_never_empty_right[2,-2]=${(@)_p9k_line_never_empty_right[2,-2]/0/1}
fi fi
fi fi
@ -4922,11 +4926,15 @@ _p9k_init_display() {
local -i j=$((-$#_p9k_line_segments_left+i-1)) local -i j=$((-$#_p9k_line_segments_left+i-1))
_p9k__display_k+=( _p9k__display_k+=(
$i $((n+=2)) $j $n $i $((n+=2)) $j $n
$i/left_frame $((n+=2)) $j/left_frame $n
$i/right_frame $((n+=2)) $j/right_frame $n
$i/left $((n+=2)) $j/left $n $i/left $((n+=2)) $j/left $n
$i/right $((n+=2)) $j/right $n $i/right $((n+=2)) $j/right $n
$i/gap $((n+=2)) $j/gap $n) $i/gap $((n+=2)) $j/gap $n)
_p9k__display_v+=( _p9k__display_v+=(
$i show $i show
$i/left_frame show
$i/right_frame show
$i/left show $i/left show
$i/right show $i/right show
$i/gap show) $i/gap show)