From e75d0cf94582a5aa6dde781b8428ffff45cf7e76 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Jan 2019 13:55:35 +0100 Subject: Blessings: add stripSGR --- src/Blessings.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/Blessings.hs b/src/Blessings.hs index 21cbabd..302b8bc 100644 --- a/src/Blessings.hs +++ b/src/Blessings.hs @@ -251,6 +251,14 @@ renderSGR pm = ("\ESC["<>) . (<>"m") . Bless.intercalate ";" . map Bless.fromInt $ pm +stripSGR :: Blessings a -> Blessings a +stripSGR = \case + Append t1 t2 -> Append (stripSGR t1) (stripSGR t2) + SGR _ t -> stripSGR t + Plain x -> Plain x + Empty -> Empty + + pp :: (Blessable a) => Blessings a -> a pp t = render emptyRenderState t "" -- cgit v1.2.3