Update core.func

This commit is contained in:
CanbiZ 2025-06-30 12:49:27 +02:00
parent 14c99239cb
commit d60f0ebd72

View File

@ -138,6 +138,13 @@ color() {
CL=$(echo "\033[m") CL=$(echo "\033[m")
} }
# Special for spinner and colorized output via printf
color_spinner() {
CS_YW=$'\033[33m'
CS_YWB=$'\033[93m'
CS_CL=$'\033[m'
}
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Defines formatting helpers like tab, bold, and line reset sequences. # Defines formatting helpers like tab, bold, and line reset sequences.
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -438,10 +445,11 @@ fatal() {
# } # }
spinner() { spinner() {
local chars="⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏" local chars=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
local i=0 local i=0
while true; do while true; do
printf "\r\e[2K%s %b" "${YWB}${chars:i++%${#chars}:1}${CL}" "${YWB}${SPINNER_MSG:-}${CL}" local index=$((i++ % ${#chars[@]}))
printf "\r\033[2K%s %b" "${CS_YWB}${chars[$index]}${CS_CL}" "${CS_YWB}${SPINNER_MSG:-}${CS_CL}"
sleep 0.1 sleep 0.1
done done
} }
@ -467,6 +475,7 @@ stop_spinner() {
msg_info() { msg_info() {
local msg="$1" local msg="$1"
SPINNER_MSG="$msg" SPINNER_MSG="$msg"
color_spinner
spinner & spinner &
SPINNER_PID=$! SPINNER_PID=$!
echo "$SPINNER_PID" >/tmp/.spinner.pid echo "$SPINNER_PID" >/tmp/.spinner.pid
@ -498,7 +507,7 @@ msg_custom() {
[[ -z "$msg" ]] && return [[ -z "$msg" ]] && return
stop_spinner stop_spinner
echo -e "${BFR:-} ${symbol} ${color}${msg}${CL:-\e[0m}" echo -e "${BFR:-} ${symbol} ${color}${msg}${CL:-\e[0m}"
printf "\r\033[K\e[?25h\n" # Zeile räumen, Cursor wiederherstellen und Zeilenumbruch! printf "\r\033[K\e[?25h\n"
} }
# msg_ok() { # msg_ok() {