Remove _tide_style_menu, generalize _tide_menu

This commit is contained in:
Ilan Cosman 2023-07-31 10:33:19 -07:00
parent 198c17e902
commit 8bc67b570a
2 changed files with 9 additions and 32 deletions

View File

@ -52,18 +52,19 @@ function _tide_option -a symbol text
end
function _tide_menu
set -l list_with_slashes (string join '/' $_tide_option_list)
argparse no-restart -- $argv # Add no-restart option for first menu
echo '(r) Restart from the beginning'
if not set -q _flag_no_restart
set -f r r
echo '(r) Restart from the beginning'
end
echo '(q) Quit and do nothing'\n
while true
set_color -o
read --nchars 1 --prompt-str "Choice [$list_with_slashes/r/q] " input
set_color normal
while read --nchars 1 --prompt-str \
"$(set_color -o)Choice [$(string join '/' $_tide_option_list $r q)] $(set_color normal)" input
switch $input
case r
set -q _flag_no_restart && continue
set -e _tide_option_list
_next_choice all/style
break

View File

@ -13,7 +13,7 @@ function style
_load_config rainbow
_tide_display_prompt
_tide_style_menu
_tide_menu --no-restart
switch $_tide_selected_option
case 1
_load_config lean
@ -32,27 +32,3 @@ function _load_config -a name
string replace -r '^' 'set -g fake_' <(status dirname)/../../icons.fish | source
string replace -r '^' 'set -g fake_' <(status dirname)/../../configs/$name.fish | source
end
function _tide_style_menu # Exactly like _tide_menu except that it doesn't have (r) option
set -l list_with_slashes (string join '/' $_tide_option_list)
echo '(q) Quit and do nothing'\n
while true
set_color -o
read --nchars 1 --prompt-str "Choice [$list_with_slashes/q] " input
set_color normal
switch $input
case q
set -e _tide_selected_option # Skip through all the _next_choices
set -e _tide_option_list
command -q clear && clear
break
case $_tide_option_list
set -e _tide_option_list
set -g _tide_selected_option $input
break
end
end
end