Merge pull request #591 from krzygorz/ansi-fix

(chibi show): Make ANSI escape codes work with col state variable
This commit is contained in:
Alex Shinn 2019-11-08 18:54:41 +08:00 committed by GitHub
commit 33d6cfd0ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -733,12 +733,16 @@ def | 6
(test "\x1B;[31mred\x1B;[0m" (show #f (as-red "red")))
(test "\x1B;[31mred\x1B;[34mblue\x1B;[31mred\x1B;[0m"
(show #f (as-red "red" (as-blue "blue") "red")))
(test "\x1b;[31m1234567\x1b;[0m col: 7"
(show #f (as-unicode (as-red "1234567") (fn ((col)) (each " col: " col)))))
;; unicode
(test "〜日本語〜"
(show #f (with ((pad-char #\〜)) (padded/both 5 "日本語"))))
(test "日本語"
(show #f (as-unicode (with ((pad-char #\〜)) (padded/both 5 "日本語")))))
(test "日本語 col: 6"
(show #f (as-unicode "日本語" (fn ((col)) (each " col: " col)))))
;; from-file
;; for reference, filesystem-test relies on creating files under /tmp

View file

@ -18,7 +18,7 @@
(else "0")))
(define (ansi-escape color)
(each (integer->char 27) "[" (color->ansi color) "m"))
(string-append (string (integer->char 27)) "[" (color->ansi color) "m"))
(define (colored new-color . args)
(fn (color)