From 3460f892b3eb76d9c2e48f806c06709c8a8801ab Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Fri, 9 Feb 2024 23:43:18 -0500 Subject: [PATCH] Thanks juli, updated style to be fucking awesome --- termenv/style.scm | 44 +++++++++++++++++++++++++++++--------------- tests/test-style.scm | 4 ++++ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/termenv/style.scm b/termenv/style.scm index f2cebd0..dea3590 100644 --- a/termenv/style.scm +++ b/termenv/style.scm @@ -1,6 +1,8 @@ (define-module (termenv style) #:use-module (termenv) #:use-module (termenv unix) + #:use-module (ice-9 match) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-9 gnu) #:export (make-style styled @@ -34,6 +36,17 @@ (string style-string set-style-string) (sequences style-sequences set-style-sequences)) +;; Unsure if there's a simpler way to do set-record-type-printer! semantics on just a list? +(define-immutable-record-type + (make-stylelist list) + stylelist? + (list stylelist-list set-stylelist-list)) + +(define (stylelist-styled stylelist port) + (map (cut styled <> port) (stylelist-list stylelist))) + +(set-record-type-printer! stylelist-styled) + (define (make-style str) (_make-style 'ansi str '())) @@ -47,22 +60,23 @@ (let ((seq (string-join (style-sequences style) ";"))) (if (equal? seq "") (just-str) - (format port "~a~am~a~am" %CSI seq str (string-append %CSI %RESET))))))) + (format port "~a~am~a~a~am" %CSI seq str %CSI %RESET)))))) (set-record-type-printer!