release.sh: select_arrow con printf+ANSI directo, fix syntax

This commit is contained in:
Super User
2026-06-17 21:10:59 -04:00
parent 575e8e8bef
commit 40b4e2bd99

View File

@@ -21,56 +21,52 @@ cursor_off() { tput civis; }
cursor_on() { tput cnorm; }
# ── arrow selector ──
# usage: select_arrow "opt1" "opt2" ... → prints chosen, returns 0
select_arrow() {
local opts=("$@")
local sel=0
local row
row=$(tput lines)
row=$(( row - ${#opts[@]} - 1 ))
local col=4
local key
local sel=0 key i n=${#opts[@]}
cursor_off
while true; do
for i in "${!opts[@]}"; do
tput cup "$(( row + i ))" "$col"
if [ "$i" -eq "$sel" ]; then
printf "${C} ${opts[$i]}${N} \033[K"
printf " ${C} ${opts[$i]}${N}\n"
else
printf " ${opts[$i]} \033[K"
printf " ${opts[$i]}\n"
fi
done
printf '\033[%dA' "$n"
cursor_off
while true; do
IFS= read -rsn1 key
if [[ $key == $'\x1b' ]]; then
read -rsn2 key
read -rsn2 -t 0.01 key || key=''
case "$key" in
'[A') (( sel > 0 )) && (( sel-- )) ;;
'[B') (( sel < ${#opts[@]} - 1 )) && (( sel++ )) ;;
'[B') (( sel < n - 1 )) && (( sel++ )) ;;
esac
elif [[ $key == "" ]]; then
# clear selection lines
for i in "${!opts[@]}"; do
tput cup "$(( row + i ))" "$col"
printf " \033[K"
done
elif [[ -z "$key" || "$key" == $'\n' || "$key" == $'\r' ]]; then
printf '\033[%dA\033[J' "$n"
cursor_on
echo "${opts[$sel]}"
printf '%s\n' "${opts[$sel]}"
return 0
fi
for i in "${!opts[@]}"; do
if [ "$i" -eq "$sel" ]; then
printf "\033[2K\r ${C} ${opts[$i]}${N}\n"
else
printf "\033[2K\r ${opts[$i]}\n"
fi
done
printf '\033[%dA' "$n"
done
}
# ── progress bar (fixed position) ──
PROGRESS_ROW=0
set_progress_row() { PROGRESS_ROW=$(tput lines); }
# ── progress bar ──
progress() {
local pct=$1 msg=$2
local filled=$(( pct * blen / 100 ))
local empty=$(( blen - filled ))
local offset=$(( PROGRESS_ROW - 2 ))
tput cup "$offset" 0
printf "${C}[${bar:0:filled}${N}${bar:0:empty}${C}]${N} %3d%% %s\033[K" "$pct" "$msg"
printf "\r${C}[${bar:0:filled}${N}${bar:0:empty}${C}]${N} %3d%% %s\033[K" "$pct" "$msg"
}
# ── ── ── ── ── ── ── ── ──
@@ -104,7 +100,6 @@ if [ "$CHOICE" != "Yes" ]; then
exit 0
fi
set_progress_row
export JAVA_HOME="$JAVA_HOME"
# ── clean ──
@@ -120,9 +115,7 @@ progress 12 "Dependencies... done"
# ── build AAB ──
progress 12 "Building release AAB..."
BUILD_OUTPUT=$("$FLUTTER" build appbundle --release 2>&1) || {
echo
tput cup "$(( PROGRESS_ROW - 1 ))" 0
echo -e "${R}✗ Build failed:${N}"
echo -e "\n${R}✗ Build failed:${N}"
echo "$BUILD_OUTPUT"
exit 1
}
@@ -138,9 +131,7 @@ if [ -d "$SYMBOLS_DIR" ]; then
cd "$ROOT"
progress 95 "Symbols packaged"
else
echo
tput cup "$(( PROGRESS_ROW - 1 ))" 0
echo -e "${Y}⚠ No native libs found${N}"
echo -e "\n${Y}⚠ No native libs found${N}"
fi
# ── verify ──