Simple support for newlines

This commit is contained in:
Vivianne 2024-03-11 00:49:58 -04:00
parent b7ca692420
commit aceb2475f1
Signed by: vv
GPG key ID: F3E249EDFAC7BE26

View file

@ -65,7 +65,14 @@
(blit! rpos cpos grapheme)
#f)))
(define (text str)
;; TODO: detect non-printable characters other than newline
;; We need to discard them and also handle escape codes/printing those, etc.
(define* (text str #:key (halign #f))
(define contains-newline? (string-index str #\newline))
(if contains-newline?
(if halign
(vappend* (map text (string-split str #\newline)) #:halign halign)
(scm-error 'keyword-argument-error "text" "String contained newlines but no halign argument was set" '() (list halign)))
(gaart
(string-width str) 1
(λ (okay? blit! rpos cpos)
@ -77,7 +84,7 @@
(+ c (grapheme-width gr)))
cpos
(string->grapheme-list str))
#f)))
#f))))
(define (place-at back row-offset col-offset front)
(match-let ((($ <gaart> bw bh draw-b) back)