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
This commit is contained in:
2025-09-04 15:21:31 -07:00
parent ea9a3b8fb7
commit 38a420d649

View File

@@ -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))