Simple support for newlines
This commit is contained in:
parent
b7ca692420
commit
aceb2475f1
1 changed files with 20 additions and 13 deletions
11
gaart.scm
11
gaart.scm
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue