summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-12-27 23:28:49 +0000
committerdavidovski <david@davidovski.xyz>2023-12-27 23:28:49 +0000
commit50f7e8a1bc95ef8802a7cf31bcdb03256f08a303 (patch)
tree87ad7d2982d1d1b747dfa3bdf147adaca39e9043
parent0456749720eee65b2a97aee705bb7e3cf2bae337 (diff)
do not use tput
-rwxr-xr-xtypr.sh17
1 files changed, 7 insertions, 10 deletions
diff --git a/typr.sh b/typr.sh
index 1a4c838..e35dc86 100755
--- a/typr.sh
+++ b/typr.sh
@@ -6,7 +6,7 @@ entered_text=""
text=""
tty_init () {
- tput clear
+ printf ""
export SAVED_TTY_SETTINGS=$(stty -g)
stty raw -echo
trap typr_cleanup 1 2 3 6
@@ -15,10 +15,8 @@ tty_init () {
}
tty_cleanup () {
- tput clear
- tput cnorm
stty $SAVED_TTY_SETTINGS
-
+ printf "[?25h"
}
tty_readc () {
@@ -87,8 +85,7 @@ typr_draw_text () {
i=$((i+1))
done
- printf "%s[${cpos}H" "$draw"
- tput cnorm
+ printf "%s[${cpos}H[?25h" "$draw"
}
typr_get_time () {
@@ -111,8 +108,7 @@ typr_calculate_wpm () {
}
typr_show_results () {
- tput clear
- tput civis
+ printf "[?25l"
now="$(date +%s%N)"
time_ns=$((now-start))
@@ -215,8 +211,9 @@ typr_main () {
}
typr_init () {
- cols="$(tput cols)"
- lines="$(tput lines)"
+ set -- $(stty size)
+ cols="$2"
+ lines="$1"
areax=$((cols / 3))
areay=$((lines / 3))