wizard: make it look better on narrow screens

This commit is contained in:
romkatv 2019-09-03 10:18:19 +02:00
parent 8797ecd8e4
commit d6041f53aa
2 changed files with 28 additions and 7 deletions

View file

@ -1,4 +1,4 @@
typeset -gr __p9k_wizard_columns=51 typeset -gr __p9k_wizard_columns=55
typeset -gr __p9k_wizard_lines=21 typeset -gr __p9k_wizard_lines=21
typeset -gr __p9k_zd=${${ZDOTDIR:-$HOME}:A} typeset -gr __p9k_zd=${${ZDOTDIR:-$HOME}:A}
typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%}

View file

@ -129,9 +129,22 @@ function href() {
} }
function centered() { function centered() {
local n=$(prompt_length ${(g::)1}) local line word lines=()
(( n < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - n) / 2)):: :)} for word in "$@"; do
print -P -- $1 local n=$(prompt_length ${(g::):-"$line $word"})
if (( n > wizard_columns )); then
[[ -z $line ]] || lines+=$line
line=
fi
[[ -z $line ]] || line+=' '
line+=$word
done
[[ -z $line ]] || lines+=$line
for line in $lines; do
local n=$(prompt_length ${(g::)line})
(( n < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - n) / 2)):: :)}
print -P -- $line
done
} }
function clear() { function clear() {
@ -170,9 +183,17 @@ function quit() {
function ask_diamond() { function ask_diamond() {
while true; do while true; do
clear clear
centered "%4FPowerlevel10k configuration wizard%f." if (( force )); then
centered This is %4FPowerlevel10k configuration wizard%f. \
It will ask you a few questions and configure your prompt.
else
centered This is %4FPowerlevel10k configuration wizard%f. \
You are seeing it because you haven\'t defined any \
Powerlevel10k configuration options. It will ask \
you a few questions and configure your prompt.
fi
print -P "" print -P ""
centered "%BDoes this look like a %b%2Fdiamond%f%B (square rotated 45 degrees)?%b" centered "%BDoes this look like a %b%2Fdiamond%f%B (rotated square)?%b"
centered "reference: $(href https://graphemica.com/%E2%97%86)" centered "reference: $(href https://graphemica.com/%E2%97%86)"
print -P "" print -P ""
centered "---> \uE0B2\uE0B0 <---" centered "---> \uE0B2\uE0B0 <---"
@ -253,7 +274,7 @@ function ask_debian() {
while true; do while true; do
clear clear
centered "%BDoes this look like a %b%2FDebian logo%f%B (swirl/spiral)?%b" centered "%BDoes this look like a %b%2FDebian logo%f%B (swirl/spiral)?%b"
centered "reference: $(href https://www.debian.org/logos/openlogo-nd-100.jpg)" centered "reference: $(href https://debian.org/logos/openlogo-nd.svg)"
print -P "" print -P ""
centered "---> \uF306 <---" centered "---> \uF306 <---"
print -P "" print -P ""