From d6041f53aa17402298fd05ac4309dafb34dd75e7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 10:18:19 +0200 Subject: [PATCH] wizard: make it look better on narrow screens --- internal/configure.zsh | 2 +- internal/wizard.zsh | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/internal/configure.zsh b/internal/configure.zsh index 2ed0cdb0..fd9e8593 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -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_zd=${${ZDOTDIR:-$HOME}:A} typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} diff --git a/internal/wizard.zsh b/internal/wizard.zsh index c9dc9e89..87d20823 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -129,9 +129,22 @@ function href() { } function centered() { - local n=$(prompt_length ${(g::)1}) - (( n < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - n) / 2)):: :)} - print -P -- $1 + local line word lines=() + for word in "$@"; do + 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() { @@ -170,9 +183,17 @@ function quit() { function ask_diamond() { while true; do 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 "" - 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)" print -P "" centered "---> \uE0B2\uE0B0 <---" @@ -253,7 +274,7 @@ function ask_debian() { while true; do clear 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 "" centered "---> \uF306 <---" print -P ""