diff options
Diffstat (limited to 'world/ui.scm')
-rw-r--r-- | world/ui.scm | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/world/ui.scm b/world/ui.scm index 40d4e69..757e7dd 100644 --- a/world/ui.scm +++ b/world/ui.scm @@ -1,8 +1,5 @@ - - -(define (echo-char) +(define (tui-loop) (define table (make-piece-table "hola")) - (ui-initialize!) (let loop ((char (read-char))) (move-cursor! 0 0) (cond @@ -10,11 +7,13 @@ (else (piece-table-insert! table 4 "hola" 'normal) (erase-screen!) (write-string (piece-table->string table)) - (loop (read-char))))) - (ui-deinitialize!)) + (loop (read-char)))))) -(define (start arguments) - (with-raw-io (current-input-port) echo-char)) +(define (call-with-tui thunk) + (dynamic-wind + tui-initialize! + (lambda () (with-raw-io (current-input-port) thunk)) + tui-deinitialize!)) -;; Extend `with-raw-io` with the initialization functions and just move to a -;; `with-tui` function that calls the provided thunk in the proper mode +(define (run arguments) + (call-with-tui tui-loop)) |