Skip to content

Commit

Permalink
wizard bug fixes: screen redraws, spurious errors, frame selection
Browse files Browse the repository at this point in the history
fixes #668
  • Loading branch information
romkatv committed Apr 28, 2020
1 parent d3e5aeb commit 1b6c24e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions internal/wizard.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,17 @@ function render_screen_pass() {
done
}

function get_columns() { return 'COLUMNS > 88 ? 88 : COLUMNS' }
functions -M get_columns 0 0

function render_screen() {
{
hide_cursor
stty -echo 2>/dev/null
while true; do
while true; do
local -i wizard_columns=$((COLUMNS > 88 ? 88 : COLUMNS))
local -i wizard_lines=LINES
typeset -gi wizard_columns='get_columns()'
typeset -gi wizard_lines=LINES
if (( wizard_columns < __p9k_wizard_columns )); then
clear
flowing -c %1FNot enough horizontal space.%f
Expand Down Expand Up @@ -362,7 +365,7 @@ function add_prompt_n() {
add_widget 0 "$@" print_prompt
local var
for var; do
eval "local $var"
eval "local ${(q)var}"
done
if (( num_lines == 2 )); then
add_widget $(( 100 - ++prompt_idx )) print -P ' [%3Fnot enough vertical space to display this%f]'
Expand All @@ -379,13 +382,13 @@ function add_prompt() {

function ask() {
local choices=$1
local -i lines columns
local -i lines columns wizard_lines wizard_columns
add_widget 0 print -P "(q) Quit and do nothing."
add_widget 0 print
add_widget 0 print -P "%BChoice [${choices}q]: %b"
while true; do
=true
if (( LINES != lines || COLUMNS != columns )); then
if (( LINES != lines || get_columns() != columns )); then
render_screen
lines=wizard_lines
columns=wizard_columns
Expand Down Expand Up @@ -1364,7 +1367,7 @@ function ask_frame() {
add_prompt left_frame=1 right_frame=1
add_widget 0 print -P "(r) Restart from the beginning."
ask 1234r
case $key in
case $choice in
r) return 1;;
1) left_frame=0; right_frame=0; options+='no frame';;
2) left_frame=1; right_frame=0; options+='left frame';;
Expand Down

0 comments on commit 1b6c24e

Please sign in to comment.