diff --git a/buffer.rkt b/buffer.rkt index 8333feb..b47a2ed 100644 --- a/buffer.rkt +++ b/buffer.rkt @@ -23,7 +23,10 @@ [blue . 4] [magenta . 5] [cyan . 6] [white . 7] [brblack . 8] [brred . 9] [brgreen . 10] [bryellow . 11] [brblue . 12] [brmagenta . 13] [brcyan . 14] [brwhite . 15])) -(define color/c (apply or/c #f (hash-keys symbol->color))) +(define color/c (apply or/c byte? #f (hash-keys symbol->color))) +(define (color->code c) + (if (byte? c) c + (hash-ref symbol->color c))) (define (select-style* s) (define (k s) (A:select-graphic-rendition (hash-ref symbol->style s))) @@ -31,11 +34,11 @@ (string-append (k 'normal) (k s)))) (define (select-text-color* c) (if c - (A:select-xterm-256-text-color (hash-ref symbol->color c)) + (A:select-xterm-256-text-color (color->code c)) (A:select-graphic-rendition A:style-default-text-color))) (define (select-background-color* c) (if c - (A:select-xterm-256-background-color (hash-ref symbol->color c)) + (A:select-xterm-256-background-color (color->code c)) (A:select-graphic-rendition A:style-default-background-color))) (define (make-terminal-buffer term-rows term-cols diff --git a/raart.scrbl b/raart.scrbl index cacc74c..fef4dfb 100644 --- a/raart.scrbl +++ b/raart.scrbl @@ -76,8 +76,9 @@ screen content so only updates are output. } A contract that recognizes the ASCII colors from the list @racket['(black red green yellow blue magenta cyan white brblack brred -brgreen bryellow brblue brmagenta brcyan brwhite)]. The actual color -display depends on the terminal configuration. } +brgreen bryellow brblue brmagenta brcyan brwhite)], as well as any +@racket[byte?] value. The actual color display depends on the terminal +configuration. } @defthing[style/c contract?]{ diff --git a/t/draw.rkt b/t/draw.rkt index d6beb07..c8e3077 100644 --- a/t/draw.rkt +++ b/t/draw.rkt @@ -11,7 +11,7 @@ ;;70 80 10 20 (matte 80 20 #:halign 'right - (fg 'blue + (fg 17 (frame #:fg 'red (inset 4 5