Skip to content

Commit 9f73860

Browse files
authored
Merge pull request #16 from pnathan/issue-15
Properly addresses color strings
2 parents c0f5efd + 6896841 commit 9f73860

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

cl-ansi-text.asd

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:components ((:file "cl-ansi-text")
66
(:file "define-colors"))
77
:name "cl-ansi-text"
8-
:version "1.2"
8+
:version "1.2.1"
99
:maintainer "Paul Nathan"
1010
:author "Paul Nathan"
1111
:licence "LLGPL"

src/cl-ansi-text.lisp

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ then writes out the string that resets the decoration."
203203

204204
(defmethod rgb-color-code ((color string) &optional (style :foreground))
205205
"Takes RGB integer ala Web integers"
206-
(rgb-color-code (cl-colors2:hex-to-rgb color)
206+
(rgb-color-code (cl-colors2:parse-hex-rgb color)
207207
style))
208208

209209
(defmethod rgb-color-code ((color cl-colors2:rgb) &optional (style :foreground))

test/cl-ansi-text-test.lisp

+14-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@
8282
(is (equal '(#\Esc #\[ #\4 #\8 #\; #\2 #\; #\2 #\5 #\5 #\; #\2 #\5 #\5 #\; #\2 #\5 #\5 #\m)
8383
(make-color-string-as-list #xFFFFFF :effect :unset :style :background)))))
8484

85+
(test color-rgb
86+
;; RGB plain
87+
(is (equal (coerce (cl-ansi-text:make-color-string "ff0000") 'list)
88+
'(#\Esc #\[ #\3 #\1 #\m)))
89+
;; Web Style
90+
(is (equal (coerce (cl-ansi-text:make-color-string "#ff0000") 'list)
91+
'(#\Esc #\[ #\3 #\1 #\m)))
92+
93+
;; redux, but with 3 octets not 3 16-lets
94+
(is (equal (coerce (cl-ansi-text:make-color-string "f00") 'list)
95+
'(#\Esc #\[ #\3 #\1 #\m)))
96+
(is (equal (coerce (cl-ansi-text:make-color-string "#f00") 'list)
97+
'(#\Esc #\[ #\3 #\1 #\m))))
98+
8599
(test color-named-functions
86100
(let ((str "Test string."))
87101
(is (equal (black str)
@@ -125,4 +139,3 @@
125139
(is
126140
(equal str
127141
(white (cyan (magenta (blue (yellow (green (red (black str))))))))))))
128-

0 commit comments

Comments
 (0)