mirror of
https://github.com/IlanCosman/tide.git
synced 2024-11-27 13:18:02 +03:00
95 lines
2.4 KiB
Fish
95 lines
2.4 KiB
Fish
function _tide_sub_configure
|
|
if test $COLUMNS -lt 55 || test $LINES -lt 21
|
|
printf '%s\n' 'Terminal size too small; must be at least 55 x 21'
|
|
return 1
|
|
end
|
|
|
|
set -g fake_columns $COLUMNS
|
|
test $fake_columns -gt 90 && set fake_columns 90
|
|
set -g fake_lines $LINES
|
|
|
|
# Create an empty fake function for each item
|
|
for func in _fake(functions --all | string match --entire _tide_item)
|
|
function $func
|
|
end
|
|
end
|
|
|
|
for file in $_tide_dir/configure/{functions, prompt_items}/*
|
|
source "$file"
|
|
end
|
|
|
|
_tide_begin
|
|
end
|
|
|
|
function _tide_begin
|
|
_next_choice 'all/style'
|
|
end
|
|
|
|
function _next_choice -a nextChoice
|
|
source "$_tide_dir/configure/choices/$nextChoice.fish"
|
|
set -l cmd (string split '/' $nextChoice)[2]
|
|
$cmd
|
|
end
|
|
|
|
function _tide_menu
|
|
set -l bold (set_color -o; or echo)
|
|
set -l norm (set_color normal; or echo)
|
|
|
|
set -l listWithSlashes (string join '/' $_tide_option_list)
|
|
|
|
while true
|
|
read -P $bold"Choice [$listWithSlashes] "$norm input
|
|
|
|
if contains $input $_tide_option_list
|
|
printf '%s\n' $input
|
|
set -e _tide_option_list
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
function _tide_title -a text
|
|
set -l midCols (math --scale=0 $fake_columns/2)
|
|
set -l midTitle (math --scale=0 (string length $text)/2)
|
|
|
|
clear
|
|
|
|
_tide_cursor_right (math $midCols-$midTitle)
|
|
set_color -o
|
|
printf '%s\n' $text
|
|
set_color normal
|
|
end
|
|
|
|
function _tide_option -a symbol text
|
|
set -ga _tide_option_list $symbol
|
|
|
|
set_color -o
|
|
printf '%s\n' "($symbol) $text"
|
|
set_color normal
|
|
end
|
|
|
|
function _tide_display_prompt -a var_name var_value
|
|
test -n "$var_name" && set -g $var_name $var_value
|
|
fake_prompt
|
|
printf '\n\n'
|
|
end
|
|
|
|
function _tide_display_restart_and_tide_quit
|
|
printf '%s\n' '(r) Restart from the beginning'
|
|
printf '%s\n' '(q) Quit and do nothing'
|
|
printf '%s\n' ''
|
|
|
|
set -ga _tide_option_list r q
|
|
end
|
|
|
|
function _tide_quit --on-signal INT
|
|
_tide_on_fish_exit
|
|
source "$__fish_config_dir/functions/fish_prompt.fish"
|
|
source "$__fish_config_dir/functions/_tide_left_prompt.fish"
|
|
source "$__fish_config_dir/functions/_tide_right_prompt.fish"
|
|
clear
|
|
end
|
|
|
|
function _find_and_remove -a name list --no-scope-shadowing
|
|
set -e "$list"[(contains --index $name $$list)] 2>/dev/null # Ignore error if $list doesn't contain $name
|
|
end |