mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
refactor: reindent
This commit is contained in:
parent
4831b1265f
commit
5cc43a2503
100
install.sh
100
install.sh
|
@ -24,63 +24,63 @@ clean_up_fail() {
|
||||||
# --- Displaying ---
|
# --- Displaying ---
|
||||||
|
|
||||||
print_menu() {
|
print_menu() {
|
||||||
local function_arguments=($@)
|
local function_arguments=($@)
|
||||||
|
|
||||||
local selected_item="$1"
|
local selected_item="$1"
|
||||||
local menu_items=(${function_arguments[@]:1})
|
local menu_items=(${function_arguments[@]:1})
|
||||||
local menu_size="${#menu_items[@]}"
|
local menu_size="${#menu_items[@]}"
|
||||||
|
|
||||||
for (( i = 0; i < $menu_size; ++i )) do
|
for (( i = 0; i < $menu_size; ++i )) do
|
||||||
if [ "$i" = "$selected_item" ]
|
if [ "$i" = "$selected_item" ]
|
||||||
then echo -e "\033[2K\e[1m>\e[0m \e[1;33m${menu_items[i]}\e[0m"
|
then echo -e "\033[2K\e[1m>\e[0m \e[1;33m${menu_items[i]}\e[0m"
|
||||||
else echo -e "\033[2K ${menu_items[i]}"
|
else echo -e "\033[2K ${menu_items[i]}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
run_menu() {
|
run_menu() {
|
||||||
local function_arguments=($@)
|
local function_arguments=($@)
|
||||||
|
|
||||||
local selected_item="$1"
|
local selected_item="$1"
|
||||||
local menu_items=(${function_arguments[@]:1})
|
local menu_items=(${function_arguments[@]:1})
|
||||||
local menu_size="${#menu_items[@]}"
|
local menu_size="${#menu_items[@]}"
|
||||||
local menu_limit=$((menu_size - 1))
|
local menu_limit=$((menu_size - 1))
|
||||||
|
|
||||||
clear
|
clear
|
||||||
print_menu "$selected_item" "${menu_items[@]}"
|
print_menu "$selected_item" "${menu_items[@]}"
|
||||||
|
|
||||||
while read -rsn1 input
|
while read -rsn1 input
|
||||||
do
|
do
|
||||||
case "$input" in
|
case "$input" in
|
||||||
$'\x1B')
|
$'\x1B')
|
||||||
read -rsn1 -t 0.1 input
|
read -rsn1 -t 0.1 input
|
||||||
if [ "$input" = "[" ]
|
if [ "$input" = "[" ]
|
||||||
then
|
then
|
||||||
read -rsn1 -t 0.1 input
|
read -rsn1 -t 0.1 input
|
||||||
case "$input"
|
case "$input"
|
||||||
in
|
in
|
||||||
A) # Arrow up
|
A) # Arrow up
|
||||||
if [ "$selected_item" -ge 1 ]
|
if [ "$selected_item" -ge 1 ]
|
||||||
then
|
then
|
||||||
selected_item=$((selected_item - 1))
|
selected_item=$((selected_item - 1))
|
||||||
clear
|
clear
|
||||||
print_menu "$selected_item" "${menu_items[@]}"
|
print_menu "$selected_item" "${menu_items[@]}"
|
||||||
fi;;
|
fi;;
|
||||||
B) # Arrow down
|
B) # Arrow down
|
||||||
if [ "$selected_item" -lt "$menu_limit" ]
|
if [ "$selected_item" -lt "$menu_limit" ]
|
||||||
then
|
then
|
||||||
selected_item=$((selected_item + 1))
|
selected_item=$((selected_item + 1))
|
||||||
clear
|
clear
|
||||||
print_menu "$selected_item" "${menu_items[@]}"
|
print_menu "$selected_item" "${menu_items[@]}"
|
||||||
fi;;
|
fi;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
# stdin flush
|
# stdin flush
|
||||||
read -rsn5 -t 0.1;;
|
read -rsn5 -t 0.1;;
|
||||||
"") # Enter
|
"") # Enter
|
||||||
return "$selected_item";;
|
return "$selected_item";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Installation ---
|
# --- Installation ---
|
||||||
|
@ -152,7 +152,7 @@ run_menu "$selected_item" "${menu_opts[@]}"
|
||||||
menu_chosen="$?"
|
menu_chosen="$?"
|
||||||
|
|
||||||
case "$menu_chosen" in
|
case "$menu_chosen" in
|
||||||
0) install;;
|
0) install;;
|
||||||
1) uninstall;;
|
1) uninstall;;
|
||||||
2) clean_up;;
|
2) clean_up;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue