From eb0d091771fa39dcb2a5b4793a1c10abcec0dc5e Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Tue, 16 Jan 2024 01:13:39 +0100 Subject: world: organize and layout guile too --- world/ui.scm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'world/ui.scm') 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)) -- cgit v1.2.3