Skip to content

Commit 9872b49

Browse files
committed
improve render
1 parent f478952 commit 9872b49

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/main.f90

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ program donut
55
implicit none (type, external)
66

77
character, parameter :: ESC = achar(27)
8+
character(3), parameter :: LF = ESC // "[d" !< line feed
9+
character(3), parameter :: TL = ESC // "[2J" !< erase screen and move to top left
810
character, parameter :: TAB(0:11) = [".", ",", "-", "~", ":", ";", "=", "!", "*", "#", "$", "@"]
911
real(wp), parameter :: PI = 4*atan(1.)
1012

@@ -22,6 +24,8 @@ program donut
2224
character(:), allocatable :: dumpfn
2325
logical :: dump
2426

27+
print *, ESC // "[?25l" !< hide cursor
28+
2529
Nloop = 300
2630
dump = .false.
2731
do ii = 1, command_argument_count()
@@ -49,7 +53,8 @@ program donut
4953

5054
if(dump) open(newunit=u, file=dumpfn, status='replace', action='write')
5155

52-
write(stdout,"(a)", advance="no") ESC // "[2J" !< move cursor to top left
56+
write(stdout,"(a)", advance="no") TL
57+
!! move cursor to top left
5358

5459
do ii = 1,Nloop
5560
z=0
@@ -82,7 +87,7 @@ program donut
8287
j = j + 0.07
8388
enddo
8489

85-
write(stdout, "(a)", advance="no") ESC // "[d" !< line feed
90+
write(stdout, "(a)", advance="no") LF
8691

8792
do k=0, rows-2
8893
print '(81a)', screen(k*cols:k*cols+cols)
@@ -95,4 +100,6 @@ program donut
95100

96101
if(dump) close(u)
97102

103+
print *, ESC // "[?25h" !< show cursor
104+
98105
end program

fpm.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = "donut"
2+
description = "Spinning donut TTY"
3+
version = "1.0.0"

0 commit comments

Comments
 (0)