2020-07-15 04:30:58 +03:00
|
|
|
function _tide_sub_configure
|
2020-04-20 19:38:41 +03:00
|
|
|
if test $COLUMNS -lt 55 || test $LINES -lt 21
|
2020-05-20 00:10:19 +03:00
|
|
|
printf '%s\n' 'Terminal size too small; must be at least 55 x 21'
|
2020-04-20 19:38:41 +03:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2020-05-19 02:17:50 +03:00
|
|
|
set -g fake_columns $COLUMNS
|
2020-11-25 01:39:56 +03:00
|
|
|
test $fake_columns -gt 90 && set fake_columns 90
|
2020-05-19 02:17:50 +03:00
|
|
|
set -g fake_lines $LINES
|
2020-04-28 01:37:08 +03:00
|
|
|
|
2020-09-20 05:30:12 +03:00
|
|
|
# Create an empty fake function for each item
|
|
|
|
for func in _fake(functions --all | string match --entire _tide_item)
|
|
|
|
function $func
|
|
|
|
end
|
2020-05-19 02:17:50 +03:00
|
|
|
end
|
2020-09-20 05:30:12 +03:00
|
|
|
|
|
|
|
for file in $_tide_dir/configure/{functions, prompt_items}/*
|
|
|
|
source "$file"
|
2020-04-28 01:37:08 +03:00
|
|
|
end
|
2020-04-20 19:38:41 +03:00
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
_tide_begin
|
2020-07-13 06:40:11 +03:00
|
|
|
end
|
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
function _tide_begin
|
2020-06-18 20:36:59 +03:00
|
|
|
_next_choice 'all/style'
|
2020-04-20 19:38:41 +03:00
|
|
|
end
|
|
|
|
|
2020-05-19 02:17:50 +03:00
|
|
|
function _next_choice -a nextChoice
|
2020-05-20 20:39:44 +03:00
|
|
|
source "$_tide_dir/configure/choices/$nextChoice.fish"
|
2020-06-18 20:36:59 +03:00
|
|
|
set -l cmd (string split '/' $nextChoice)[2]
|
|
|
|
$cmd
|
2020-04-20 19:38:41 +03:00
|
|
|
end
|
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
function _tide_menu
|
2020-09-06 00:48:27 +03:00
|
|
|
set -l bold (set_color -o; or echo)
|
|
|
|
set -l norm (set_color normal; or echo)
|
2020-04-21 06:35:56 +03:00
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
set -l listWithSlashes (string join '/' $_tide_option_list)
|
2020-07-15 05:10:59 +03:00
|
|
|
|
2020-05-19 02:17:50 +03:00
|
|
|
while true
|
2020-07-15 05:10:59 +03:00
|
|
|
read -P $bold"Choice [$listWithSlashes] "$norm input
|
2020-04-20 19:38:41 +03:00
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
if contains $input $_tide_option_list
|
2020-05-20 00:10:19 +03:00
|
|
|
printf '%s\n' $input
|
2020-07-19 23:35:19 +03:00
|
|
|
set -e _tide_option_list
|
2020-05-19 02:17:50 +03:00
|
|
|
break
|
|
|
|
end
|
2020-04-21 21:52:24 +03:00
|
|
|
end
|
2020-04-20 19:38:41 +03:00
|
|
|
end
|
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
function _tide_title -a text
|
2020-07-21 00:11:59 +03:00
|
|
|
set -l midCols (math --scale=0 $fake_columns/2)
|
|
|
|
set -l midTitle (math --scale=0 (string length $text)/2)
|
|
|
|
|
2020-04-28 02:12:12 +03:00
|
|
|
clear
|
2020-04-20 19:38:41 +03:00
|
|
|
|
2020-07-06 19:40:46 +03:00
|
|
|
_tide_cursor_right (math $midCols-$midTitle)
|
2020-04-21 21:52:24 +03:00
|
|
|
set_color -o
|
2020-05-20 00:10:19 +03:00
|
|
|
printf '%s\n' $text
|
2020-04-21 21:52:24 +03:00
|
|
|
set_color normal
|
|
|
|
end
|
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
function _tide_option -a symbol text
|
|
|
|
set -ga _tide_option_list $symbol
|
2020-07-15 05:10:59 +03:00
|
|
|
|
2020-04-21 21:52:24 +03:00
|
|
|
set_color -o
|
2020-05-20 00:10:19 +03:00
|
|
|
printf '%s\n' "($symbol) $text"
|
2020-04-21 21:52:24 +03:00
|
|
|
set_color normal
|
2020-04-20 19:38:41 +03:00
|
|
|
end
|
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
function _tide_display_prompt -a var_name var_value
|
2020-11-25 01:39:56 +03:00
|
|
|
test -n "$var_name" && set -g $var_name $var_value
|
2020-04-21 06:35:56 +03:00
|
|
|
fake_prompt
|
2020-04-30 00:52:58 +03:00
|
|
|
printf '\n\n'
|
2020-04-20 19:38:41 +03:00
|
|
|
end
|
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
function _tide_display_restart_and_tide_quit
|
2020-07-08 05:21:35 +03:00
|
|
|
printf '%s\n' '(r) Restart from the beginning'
|
2020-07-15 05:10:59 +03:00
|
|
|
printf '%s\n' '(q) Quit and do nothing'
|
|
|
|
printf '%s\n' ''
|
2020-07-19 23:35:19 +03:00
|
|
|
|
|
|
|
set -ga _tide_option_list r q
|
2020-04-20 19:38:41 +03:00
|
|
|
end
|
|
|
|
|
2020-07-19 23:35:19 +03:00
|
|
|
function _tide_quit --on-signal INT
|
2020-06-16 22:07:35 +03:00
|
|
|
clear
|
2020-05-19 02:17:50 +03:00
|
|
|
source "$__fish_config_dir/functions/fish_prompt.fish"
|
2020-05-20 20:05:33 +03:00
|
|
|
source "$__fish_config_dir/functions/_tide_left_prompt.fish"
|
|
|
|
source "$__fish_config_dir/functions/_tide_right_prompt.fish"
|
2020-11-20 03:23:54 +03:00
|
|
|
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
|
2020-04-20 19:38:41 +03:00
|
|
|
end
|