Allow stripping SGR from sgr-list.

This commit is contained in:
Dominik Pantůček 2023-07-02 07:49:57 +02:00
parent 870335c637
commit 2041fef742

View file

@ -208,7 +208,8 @@
;; Converts a SGR list into a single string
(define* (sgr-list->string lst
(initial-state empty-sgr-state)
#:reset-state (reset-state #f))
#:reset-state (reset-state #f)
#:strip-ansi? (strip-ansi? #f))
(let loop ((lst lst)
(res '())
(state initial-state))
@ -221,7 +222,9 @@
(let ((token (car lst)))
(if (sgr-state? token)
(loop (cdr lst)
(cons (sgr-state-change->string state token) res)
(if strip-ansi?
res
(cons (sgr-state-change->string state token) res))
token)
(loop (cdr lst)
(cons (car token) res)