From 38a420d64967912b9c4f394b7641e9ae1994b0f7 Mon Sep 17 00:00:00 2001 From: w6vvn Date: Thu, 4 Sep 2025 15:21:31 -0700 Subject: [PATCH] add currently visited document, pre-rendering, to global state its becoming apparent that this doesn't need to be global state, and can be passed from iteration to iteration in the program loop. this shall be revisited --- gem300.rkt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gem300.rkt b/gem300.rkt index 35d2fc4..17b8b1f 100644 --- a/gem300.rkt +++ b/gem300.rkt @@ -7,15 +7,20 @@ ;; rendered out gemtext document as it shall be shown to the user (define document-buffer null) +;; global state which will be the document structure, before rendering +(define document null) + (define (go-cmd url) (if (non-empty-string? url) (let-values ([(status meta c-in) (net:get url)]) - (let-values ([(document) (gmi:parse (port->lines c-in))] + (let-values ([(doc) (gmi:parse (port->lines c-in))] [(db-in db-out) (make-pipe #f)]) + (set! document doc) + (set! document-buffer db-in) (parameterize ([current-output-port db-out]) - (gmi:render document)) + (gmi:render doc)) (let ([remaining (pipe-content-length db-in)]) (printf "document retrieved. ~a bytes\n" remaining))