Don't use escape codes to undo newline, just don't print it

This commit is contained in:
Ilan Cosman 2023-09-20 12:05:22 -07:00
parent ecb00e28ae
commit 2652ed78a0
2 changed files with 11 additions and 2 deletions

View File

@ -52,6 +52,8 @@ function _tide_title -a text
set_color -o
string pad --width (math --scale=0 "$fake_columns/2" + (string length $text)/2) $text
set_color normal
set -g _tide_configure_first_option_after_title
end
function _tide_option -a symbol text
@ -59,7 +61,10 @@ function _tide_option -a symbol text
set -ga _tide_option_list $text
if not set -q _flag_auto
set -g _tide_configure_first_prompt_after_option
set_color -o
set -e _tide_configure_first_option_after_title || echo
echo "($symbol) $text"
set_color normal
end
@ -85,6 +90,7 @@ function _tide_menu -a func
argparse no-restart -- $argv # Add no-restart option for first menu
echo
if not set -q _flag_no_restart
set -f r r
echo '(r) Restart from the beginning'
@ -128,9 +134,11 @@ function _tide_display_prompt -a var_name var_value
set -l right_prompt_string (string pad --width (math $fake_columns-$bottom_left_prompt_string_length) $prompt[1])
set -l prompt[-1] "$prompt[-1]$right_prompt_string"
if not set -e _tide_configure_first_prompt_after_option
test "$fake_tide_prompt_add_newline_before" = true && echo
end
string unescape $prompt[2..]
set_color normal
echo
end
function _tide_exit_configure

View File

@ -2,11 +2,12 @@ function prompt_spacing
_tide_title 'Prompt Spacing'
_tide_option 1 Compact
set -g fake_tide_prompt_add_newline_before false
_tide_display_prompt
printf \e\[1A # Move cursor up 1 row
_tide_display_prompt
_tide_option 2 Sparse
set -g fake_tide_prompt_add_newline_before true
_tide_display_prompt
_tide_display_prompt