diff --git a/gaart.scm b/gaart.scm index 708da91..39799a5 100644 --- a/gaart.scm +++ b/gaart.scm @@ -54,14 +54,10 @@ (define* (blank #:optional (w 0) (h 1)) (gaart w h (λ (okay? blit! rpos cpos) #f))) -;; TODO: use stock char->grapheme -(define (char->grapheme char) - ((make-grapheme-iterator) char)) - (define (char ch) (define grapheme (char->grapheme ch)) (unless grapheme - (error (format #f "Unable to convert ~s to a valid unicode grapheme" ch))) + (scm-error #f "char" "Unable to convert ~s to a valid unicode grapheme" (list ch) (list ch))) (gaart 1 1 @@ -75,12 +71,12 @@ (λ (okay? blit! rpos cpos) ;; Go through each grapheme, print it and advance the position ;; depending on the width - (stream-fold + (fold (λ (gr c) (blit! rpos c gr) (+ c (grapheme-width gr))) cpos - (string->grapheme-stream str)) + (string->grapheme-list str)) #f))) (define (place-at back row-offset col-offset front) @@ -95,7 +91,7 @@ (match-let ((($ xw xh _) x)) (unless (and (<= (+ xw cpos) matte-width) (<= (+ xh rpos) matte-height)) - (error (format #f "matte-at: Original (~ax~a@~a,~a) must fit inside matte (~ax~a)" xw xh cpos rpos matte-width matte-height))) + (scm-error #f "matte-at" "Original (~ax~a@~a,~a) must fit inside matte (~ax~a)" (list xw xh cpos rpos matte-width matte-height) (list x))) (place-at (blank matte-width matte-height) rpos cpos x))) (define* (matte matte-width matte-height x #:key (halign 'center) (valign 'center)) @@ -104,7 +100,7 @@ (match-let ((($ xw xh draw-x) x)) (unless (and (<= xw width) (<= xh height)) - (error (format #f "matte: Original (~ax~a) must fit inside matte (~ax~a)" xw xh width height))) + (scm-error #f "matte" "Original (~ax~a) must fit inside matte (~ax~a)" (list xw xh width height) (list x))) (matte-at width height (match halign @@ -186,8 +182,7 @@ (match-let ((($ xw xh draw-x) x) (($ yw yh draw-y) y)) (unless (= xw yw) - ;; TODO: proper error messages with irritants - (error (format #f "vappend2: Widths must be equal: ~a vs ~a" xw yw))) + (scm-error #f "vappend2" "Widths must be equal: ~a vs ~a" (list xw yw) (list xw yw))) (gaart xw (+ xh yh) (λ (okay? blit! rpos cpos) @@ -218,7 +213,7 @@ (match-let ((($ xw xh draw-x) x) (($ yw yh draw-y) y)) (unless (= xh yh) - (error (format #f "happend2: Heights must be equal: ~a vs ~a" xh yh))) + (scm-error #f "happend2" "Heights must be equal: ~a vs ~a" (list xh yh) (list xh yh))) (gaart (+ xw yw) xh (λ (okay? blit! rpos cpos) diff --git a/gaart/draw.scm b/gaart/draw.scm index 845de19..c906431 100644 --- a/gaart/draw.scm +++ b/gaart/draw.scm @@ -14,4 +14,5 @@ (blit! (λ (rpos cpos grapheme) (buffer-set! buf rpos cpos grapheme)))) (draw okay? blit! 0 0) - (write-buffer buf port))) + (write-buffer buf port) + buf))