Compare commits

...

2 Commits

2 changed files with 25 additions and 88 deletions

View File

@@ -270,6 +270,7 @@ main() {
fi
((fs_active == 0)) && tui_fs_set_overall "$idx" "$total" "${description:-$(basename "$module_path" .sh)}"
printf '\n'
log_step "$idx" "$total" "${description:-$(basename "$module_path" .sh)}"
module_run "$module_path" || {
@@ -284,7 +285,6 @@ main() {
fi
tui_warn "Module completed with warnings"
}
((fs_active == 0)) && tui_fs_set_progress 100
((idx++))
done

View File

@@ -3,11 +3,9 @@
TUI_FS_ACTIVE=0
TUI_FS_ROWS=0
TUI_FS_COLS=0
TUI_FS_LOG_AREA=4
TUI_FS_OVERALL_CURRENT=0
TUI_FS_OVERALL_TOTAL=0
TUI_FS_MODULE_LABEL=""
TUI_FS_MODULE_PROGRESS=0
TUI_FS_SAVED_STTY=""
tui_fs_init() {
@@ -16,27 +14,19 @@ tui_fs_init() {
TUI_FS_SAVED_STTY=$(stty -g 2>/dev/null || true)
TUI_FS_ROWS=$(tput lines 2>/dev/null || echo 24)
TUI_FS_COLS=$(tput cols 2>/dev/null || echo 80)
TUI_FS_LOG_AREA=4
tput smcup 2>/dev/null
tput civis 2>/dev/null
tput csr "$TUI_FS_LOG_AREA" $((TUI_FS_ROWS - 1)) 2>/dev/null
tput clear 2>/dev/null
tput smcup 2>/dev/null || true
tput civis 2>/dev/null || true
tput clear 2>/dev/null || true
_tui_fs_draw_frame
TUI_FS_ACTIVE=1
trap '_tui_fs_cleanup' EXIT INT TERM
tput cup "$TUI_FS_LOG_AREA" 0
}
tui_fs_exit() {
[[ "$TUI_FS_ACTIVE" -eq 0 ]] && return
TUI_FS_ACTIVE=0
trap - EXIT INT TERM
tput csr 0 $((TUI_FS_ROWS - 1)) 2>/dev/null
tput cnorm 2>/dev/null
tput rmcup 2>/dev/null
tput cnorm 2>/dev/null || true
tput rmcup 2>/dev/null || true
[[ -n "$TUI_FS_SAVED_STTY" ]] && stty "$TUI_FS_SAVED_STTY" 2>/dev/null || true
}
@@ -44,99 +34,46 @@ tui_fs_set_overall() {
TUI_FS_OVERALL_CURRENT=$1
TUI_FS_OVERALL_TOTAL=$2
TUI_FS_MODULE_LABEL="${3:-}"
TUI_FS_MODULE_PROGRESS=0
_tui_fs_draw_header
_tui_fs_draw_screen
}
tui_fs_set_progress() {
TUI_FS_MODULE_PROGRESS=$1
_tui_fs_draw_header
}
_tui_fs_draw_screen() {
[[ "$TUI_FS_ACTIVE" -eq 0 ]] && return
tput cup 0 0 2>/dev/null || true
tput clear 2>/dev/null || true
_tui_fs_cleanup() {
tui_fs_exit
}
_tui_fs_draw_frame() {
local cols=$TUI_FS_COLS
tput cup 0 0
printf "\033[7m %-*s\033[0m" $((cols - 2)) " Omeron — Modular System Setup"
tput cup 1 0
printf " %-*s" $((cols - 3)) ""
tput cup 2 0
printf " %-*s" $((cols - 3)) ""
tput cup 3 0
printf " "
printf '%*s' $((cols - 4)) '' | tr ' ' '─'
}
local cols_safe=$((cols > 60 ? cols : 60))
_tui_fs_draw_header() {
[[ "$TUI_FS_ACTIVE" -eq 0 ]] && return 0
tput sc
local cols=$TUI_FS_COLS
printf "\033[7m %-*s\033[0m\n" $((cols_safe - 2)) " Omeron — Modular System Setup"
# Row 1: module label + overall progress
tput cup 1 0
printf " "
if [[ -n "$TUI_FS_MODULE_LABEL" ]]; then
printf "Module: %-*s" $((cols - 35)) "$TUI_FS_MODULE_LABEL"
printf " Module: %-*s" $((cols_safe - 18)) "$TUI_FS_MODULE_LABEL"
if ((TUI_FS_OVERALL_TOTAL > 0)); then
printf " [%d/%d]" "$TUI_FS_OVERALL_CURRENT" "$TUI_FS_OVERALL_TOTAL"
fi
printf "\n"
else
printf "\n"
fi
tput el
# Row 2: progress bar
tput cup 2 0
printf " "
local bar_width=$((cols - 16))
local bar_width=$((cols_safe - 16))
((bar_width < 10)) && bar_width=10
local progress=0
if ((TUI_FS_OVERALL_TOTAL > 0)); then
local overall_pct=$((TUI_FS_OVERALL_CURRENT * 100 / TUI_FS_OVERALL_TOTAL))
if ((TUI_FS_OVERALL_TOTAL == TUI_FS_OVERALL_CURRENT)) && ((TUI_FS_MODULE_PROGRESS >= 100)); then
progress=100
else
local module_share=$((100 / TUI_FS_OVERALL_TOTAL))
local completed_pct=$(( (TUI_FS_OVERALL_CURRENT - 1) * 100 / TUI_FS_OVERALL_TOTAL ))
local current_pct=$(( TUI_FS_MODULE_PROGRESS * module_share / 100 ))
progress=$((completed_pct + current_pct))
progress=$(( TUI_FS_OVERALL_CURRENT * 100 / TUI_FS_OVERALL_TOTAL ))
((progress > 100)) && progress=100
fi
fi
printf " "
local filled=$(( progress * bar_width / 100 ))
local i
for ((i=0; i<filled && i<bar_width; i++)); do printf '▓'; done
for ((i=filled; i<bar_width; i++)); do printf '░'; done
printf " %3d%%" "$progress"
tput el
printf " %3d%%\n" "$progress"
tput rc
}
tui_fs_log_info() {
printf ' \033[1;34m▶\033[0m %s\n' "$1"
}
tui_fs_log_success() {
printf ' \033[1;32m✓\033[0m %s\n' "$1"
}
tui_fs_log_warn() {
printf ' \033[1;33m⚠\033[0m %s\n' "$1" >&2
}
tui_fs_log_error() {
printf ' \033[1;31m✗\033[0m %s\n' "$1" >&2
}
tui_fs_log_section() {
local msg="$1"
local line
printf -v line '%*s' "${#msg}" '' && line="${line// /─}"
printf ' %s\n' "$line"
printf ' %s\n' "$msg"
printf ' %s\n' "$line"
printf " "
printf '%*s' $((cols_safe - 3)) '' | tr ' ' '─'
printf "\n"
}