Fix flashing cursor

This commit is contained in:
Manuele Sarfatti 2025-05-11 14:08:24 +02:00
parent 4334716ff3
commit 5eed38d418
3 changed files with 16 additions and 17 deletions

View file

@ -39,7 +39,7 @@ release:
sed -i '' "s/# Version: .*/# Version: $$VERSION/" $(OUTPUT); \ sed -i '' "s/# Version: .*/# Version: $$VERSION/" $(OUTPUT); \
git add $(OUTPUT); \ git add $(OUTPUT); \
git commit -m "Release $$VERSION"; \ git commit -m "Release $$VERSION"; \
git tag -a "$$VERSION" -m "Release $$VERSION" git tag -a "$$VERSION" -m "Release $$VERSION"; \
@echo "\nRelease complete: \033[32m$$VERSION\033[0m" @echo "\nRelease complete: \033[32m$$VERSION\033[0m"
%: %:

View file

@ -1,15 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Import the beddu.sh library
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source "$(dirname -- "$0")/../build/beddu.sh" source "$(dirname -- "$0")/../dist/beddu.sh"
# Demo function to showcase the framework
demo() { demo() {
_violet=99 _violet=99
_pink=219 _pink=219
pen "\n>> $_q <<\n" hide_cursor
line line
pen $_violet "╔═════════════════════════════════════════════╗" pen $_violet "╔═════════════════════════════════════════════╗"
@ -27,7 +25,7 @@ demo() {
line line
spin $_pink "Loading text formatting..." spin $_pink "Loading text formatting..."
sleep 1 sleep 1
spop spop --keep-cursor-hidden
upclear upclear
pen $_pink italic "-- Text formatting --" pen $_pink italic "-- Text formatting --"
line line
@ -39,7 +37,7 @@ demo() {
line line
spin $_pink "Loading basic colors..." spin $_pink "Loading basic colors..."
sleep 1 sleep 1
spop spop --keep-cursor-hidden
upclear upclear
pen $_pink italic "-- Basic colors --" pen $_pink italic "-- Basic colors --"
line line
@ -51,14 +49,14 @@ demo() {
pen cyan "Cyan text" pen cyan "Cyan text"
pen white "White text" pen white "White text"
pen grey "Grey text" pen grey "Grey text"
pen -n black "Black text" pen -n black "Black text "
pen italic "[Black text - might not be visible]" pen italic "[Black text - might not be visible]"
line line
line line
spin $_pink "Loading ANSI 256 colors..." spin $_pink "Loading ANSI 256 colors..."
sleep 1 sleep 1
spop spop --keep-cursor-hidden
upclear upclear
pen $_pink italic "-- ANSI 256 colors (examples) --" pen $_pink italic "-- ANSI 256 colors (examples) --"
line line
@ -70,7 +68,7 @@ demo() {
line line
spin $_pink "Loading combined formatting..." spin $_pink "Loading combined formatting..."
sleep 1 sleep 1
spop spop --keep-cursor-hidden
upclear upclear
pen $_pink italic "-- Combined formatting --" pen $_pink italic "-- Combined formatting --"
line line
@ -88,7 +86,7 @@ demo() {
line line
spin $_pink "Loading output utilities..." spin $_pink "Loading output utilities..."
sleep 1 sleep 1
spop spop --keep-cursor-hidden
upclear upclear
pen $_pink italic "-- Output utilities --" pen $_pink italic "-- Output utilities --"
line line
@ -99,7 +97,7 @@ demo() {
line line
spin $_pink "Starting interactive experience..." spin $_pink "Starting interactive experience..."
sleep 1 sleep 1
spop spop --keep-cursor-hidden
upclear upclear
pen $_pink italic "-- Interactive functions --" pen $_pink italic "-- Interactive functions --"
line line

View file

@ -46,7 +46,7 @@ spin() {
hide_cursor hide_cursor
# Use a trap to catch USR1 signal for clean shutdown # Use a trap to catch USR1 signal for clean shutdown
trap "show_cursor; exit 0" USR1 trap "exit 0" USR1
# Print the first frame of the spinner # Print the first frame of the spinner
pen -n cyan "${spinner:0:1} " pen -n cyan "${spinner:0:1} "
@ -82,10 +82,11 @@ spop() {
# Ensure it's really gone # Ensure it's really gone
if ps -p "${_spinner_pid}" >/dev/null 2>&1; then if ps -p "${_spinner_pid}" >/dev/null 2>&1; then
kill "${_spinner_pid}" 2>/dev/null kill "${_spinner_pid}" 2>/dev/null
# Manually clean up display, unless asked not to do so fi
if [[ "$keep_cursor_hidden" == false ]]; then
show_cursor # Manually clean up display, unless asked not to do so
fi if [[ "$keep_cursor_hidden" == false ]]; then
show_cursor
fi fi
_spinner_pid="" _spinner_pid=""