implement some guards on the client. definitely need to relearn how to do syntax macros now...

This commit is contained in:
2025-09-06 12:29:36 -07:00
parent e081ec9edf
commit dbaa44190f

View File

@@ -30,6 +30,10 @@
(super-new) (super-new)
(define/public (up-cmd) (define/public (up-cmd)
(if (null? current-url)
(displayln "you need to 'go' somewhere first!")
(if (string=? (path->string (if (string=? (path->string
(simplify-path (simplify-path
(url->path current-url))) (url->path current-url)))
@@ -42,7 +46,7 @@
(build-path (url->path current-url) 'up) (build-path (url->path current-url) 'up)
#f)]) #f)])
(get (struct-copy url current-url (get (struct-copy url current-url
[path (url-path (path->url parent))]))))) [path (url-path (path->url parent))]))))))
(define/public (go-cmd url-string) (define/public (go-cmd url-string)
(if (non-empty-string? url-string) (if (non-empty-string? url-string)
@@ -62,15 +66,19 @@
(displayln (read-line document-buffer)) (displayln (read-line document-buffer))
(iter (sub1 depth))))) (iter (sub1 depth)))))
(if (null? document-buffer)
(displayln "you need to 'go' somewhere first!")
(let ()
(iter 10) (iter 10)
(newline) (newline)
(let ([remaining (pipe-content-length document-buffer)]) (let ([remaining (pipe-content-length document-buffer)])
(printf "~a bytes remaining\n" remaining))) (printf "~a bytes remaining\n" remaining)))))
(define/public (visit-cmd line) (define/public (visit-cmd line)
(define url (gmi:match-link document-object line)) (if (null? document-object)
(displayln "you need to 'go' somewhere first!")
(get (combine-url/relative current-url (url->string url)))) (let ([url (gmi:match-link document-object line)])
(get (combine-url/relative current-url (url->string url))))))
(define/private (get url) (define/private (get url)
(define (iter url depth) (define (iter url depth)
@@ -93,6 +101,7 @@
[(and (>= status 20) [(and (>= status 20)
(<= status 29)) (<= status 29))
(let-values ([(doc) (gmi:parse (port->lines c-in))] (let-values ([(doc) (gmi:parse (port->lines c-in))]
[(db-in db-out) (make-pipe #f)]) [(db-in db-out) (make-pipe #f)])