projects
/
advent-of-code-2019.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cb2096d
)
Move back to using tput for hiding the cursor (it works more reliably), also turn...
author
Brett Parker
<iDunno@sommitrealweird.co.uk>
Thu, 10 Dec 2020 21:21:44 +0000
(21:21 +0000)
committer
Brett Parker
<iDunno@sommitrealweird.co.uk>
Thu, 10 Dec 2020 21:21:44 +0000
(21:21 +0000)
day13/screen.sh
patch
|
blob
|
history
diff --git
a/day13/screen.sh
b/day13/screen.sh
index e447c2a2636b6d34c304e5f0c3e55c56101c1b1c..d3bbe6d8fa92e2300592b26af4cad4af36971036 100644
(file)
--- a/
day13/screen.sh
+++ b/
day13/screen.sh
@@
-1,9
+1,27
@@
__arcade_score=0
clear_screen() {
__arcade_score=0
clear_screen() {
+ # first reset then clear
+ echo -en '\033c'
echo -en '\033[2J'
}
echo -en '\033[2J'
}
+echo_off() {
+ stty -echo
+}
+
+echo_on() {
+ stty echo
+}
+
+hide_cursor() {
+ tput civis
+}
+
+show_cursor() {
+ tput cvvid
+}
+
move_cursor() {
local x=$1
local y=$2
move_cursor() {
local x=$1
local y=$2
@@
-42,14
+60,6
@@
draw_tile() {
esac
}
esac
}
-hide_cursor() {
- echo -en '\033[25l'
-}
-
-show_cursor() {
- echo -en '\033[25h'
-}
-
draw_score_board() {
local value=${1:-0}
local scoreboard_y=20
draw_score_board() {
local value=${1:-0}
local scoreboard_y=20
@@
-78,6
+88,7
@@
update_score_board() {
arcade_screen_init() {
clear_screen
arcade_screen_init() {
clear_screen
+ echo_off
hide_cursor
draw_score_board
}
hide_cursor
draw_score_board
}
@@
-94,7
+105,7
@@
arcade_screen_update() {
arcade_screen_finish() {
move_cursor 0 23
show_cursor
arcade_screen_finish() {
move_cursor 0 23
show_cursor
- echo
high score: $__arcade_score
+ echo
_on
}
arcade_screen() {
}
arcade_screen() {
@@
-103,10
+114,7
@@
arcade_screen() {
local -A blocks
# first, clear the screen and hide the cursor
local -A blocks
# first, clear the screen and hide the cursor
- clear_screen
- hide_cursor
-
- draw_score_board
+ arcade_screen_init
while read x; do
read y
while read x; do
read y