From 2041fef742a8a7307f783054a868848506f056ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Sun, 2 Jul 2023 07:49:57 +0200 Subject: [PATCH] Allow stripping SGR from sgr-list. --- src/sgr-list.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sgr-list.scm b/src/sgr-list.scm index ca653ed..ab0bb58 100644 --- a/src/sgr-list.scm +++ b/src/sgr-list.scm @@ -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)