prompt_length cleanup

pull/1125/head
Roman Perepelitsa 4 years ago
parent 685682da90
commit 98a8ec6f31

@ -300,20 +300,19 @@ function _p9k_upglob() {
# _p9k_prompt_length '%F{red}abc' => 3 # _p9k_prompt_length '%F{red}abc' => 3
# _p9k_prompt_length $'%{a\b%Gb%}' => 1 # _p9k_prompt_length $'%{a\b%Gb%}' => 1
function _p9k_prompt_length() { function _p9k_prompt_length() {
local COLUMNS=1024 local -i COLUMNS=1024
local -i x y=$#1 m local -i x y=$#1 m
if (( y )); then if (( y )); then
while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do
x=y x=y
(( y *= 2 )); (( y *= 2 ))
done done
local xy
while (( y > x + 1 )); do while (( y > x + 1 )); do
m=$(( x + (y - x) / 2 )) (( m = x + (y - x) / 2 ))
typeset ${${(%):-$1%$m(l.x.y)}[-1]}=$m (( ${${(%):-$1%$m(l.x.y)}[-1]} = m ))
done done
fi fi
_p9k__ret=$x typeset -g _p9k__ret=$x
} }
typeset -gr __p9k_byte_suffix=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y') typeset -gr __p9k_byte_suffix=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y')
@ -6005,20 +6004,19 @@ _p9k_dump_instant_prompt() {
(( height += ${#${__p9k_used_instant_prompt[1]//[^$lf]}} )) (( height += ${#${__p9k_used_instant_prompt[1]//[^$lf]}} ))
local _p9k__ret local _p9k__ret
function _p9k_prompt_length() { function _p9k_prompt_length() {
local COLUMNS=1024 local -i COLUMNS=1024
local -i x y=$#1 m local -i x y=$#1 m
if (( y )); then if (( y )); then
while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do
x=y x=y
(( y *= 2 )); (( y *= 2 ))
done done
local xy
while (( y > x + 1 )); do while (( y > x + 1 )); do
m=$(( x + (y - x) / 2 )) (( m = x + (y - x) / 2 ))
typeset ${${(%):-$1%$m(l.x.y)}[-1]}=$m (( ${${(%):-$1%$m(l.x.y)}[-1]} = m ))
done done
fi fi
_p9k__ret=$x typeset -g _p9k__ret=$x
} }
local out local out
if [[ $+VTE_VERSION == 0 && $TERM_PROGRAM != Hyper ]] || (( ! $+_p9k__g )); then if [[ $+VTE_VERSION == 0 && $TERM_PROGRAM != Hyper ]] || (( ! $+_p9k__g )); then

@ -110,20 +110,19 @@ local -ra rainbow_right=(
) )
function prompt_length() { function prompt_length() {
local COLUMNS=1024 local -i COLUMNS=1024
local -i x y=$#1 m local -i x y=$#1 m
if (( y )); then if (( y )); then
while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do
x=y x=y
(( y *= 2 )); (( y *= 2 ))
done done
local xy
while (( y > x + 1 )); do while (( y > x + 1 )); do
m=$(( x + (y - x) / 2 )) (( m = x + (y - x) / 2 ))
typeset ${${(%):-$1%$m(l.x.y)}[-1]}=$m (( ${${(%):-$1%$m(l.x.y)}[-1]} = m ))
done done
fi fi
REPLY=$x typeset -g REPLY=$x
} }
function print_prompt() { function print_prompt() {

Loading…
Cancel
Save