Allow more drawing colors

This commit is contained in:
Jay McCarthy 2020-04-16 10:23:27 -04:00
parent 745eb82670
commit 9d82f2f8ad
3 changed files with 10 additions and 6 deletions

View File

@ -23,7 +23,10 @@
[blue . 4] [magenta . 5] [cyan . 6] [white . 7] [blue . 4] [magenta . 5] [cyan . 6] [white . 7]
[brblack . 8] [brred . 9] [brgreen . 10] [bryellow . 11] [brblack . 8] [brred . 9] [brgreen . 10] [bryellow . 11]
[brblue . 12] [brmagenta . 13] [brcyan . 14] [brwhite . 15])) [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 (select-style* s)
(define (k s) (A:select-graphic-rendition (hash-ref symbol->style s))) (define (k s) (A:select-graphic-rendition (hash-ref symbol->style s)))
@ -31,11 +34,11 @@
(string-append (k 'normal) (k s)))) (string-append (k 'normal) (k s))))
(define (select-text-color* c) (define (select-text-color* c)
(if 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))) (A:select-graphic-rendition A:style-default-text-color)))
(define (select-background-color* c) (define (select-background-color* c)
(if 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))) (A:select-graphic-rendition A:style-default-background-color)))
(define (make-terminal-buffer term-rows term-cols (define (make-terminal-buffer term-rows term-cols

View File

@ -76,8 +76,9 @@ screen content so only updates are output. }
A contract that recognizes the ASCII colors from the list A contract that recognizes the ASCII colors from the list
@racket['(black red green yellow blue magenta cyan white brblack brred @racket['(black red green yellow blue magenta cyan white brblack brred
brgreen bryellow brblue brmagenta brcyan brwhite)]. The actual color brgreen bryellow brblue brmagenta brcyan brwhite)], as well as any
display depends on the terminal configuration. } @racket[byte?] value. The actual color display depends on the terminal
configuration. }
@defthing[style/c contract?]{ @defthing[style/c contract?]{

View File

@ -11,7 +11,7 @@
;;70 80 10 20 ;;70 80 10 20
(matte 80 20 (matte 80 20
#:halign 'right #:halign 'right
(fg 'blue (fg 17
(frame #:fg 'red (frame #:fg 'red
(inset (inset
4 5 4 5