summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-12-28 04:41:52 +0100
committertv <tv@shackspace.de>2014-12-28 04:41:52 +0100
commit51e3df5fd288c72ab427dda980d6a9f2d6f8adf9 (patch)
tree272a4c3df7c5857756201756331a2589ba0c3cb7
parent4c1239c2e846d8f1987257e1fc76232ec295804f (diff)
replace tabs by spaces in Trammel String
-rw-r--r--Trammel.hs8
-rw-r--r--test4.hs3
2 files changed, 11 insertions, 0 deletions
diff --git a/Trammel.hs b/Trammel.hs
index bd3cd32..d83b846 100644
--- a/Trammel.hs
+++ b/Trammel.hs
@@ -24,6 +24,14 @@ data Trammel a
deriving (Eq, Show)
+instance Functor Trammel where
+ fmap f = \case
+ Append t1 t2 -> Append (fmap f t1) (fmap f t2)
+ Plain s -> Plain (f s)
+ SGR pm t -> SGR pm (fmap f t)
+ Empty -> Empty
+
+
instance Monoid (Trammel a) where
mappend = Append
mempty = Empty
diff --git a/test4.hs b/test4.hs
index b9990a0..d9a2e74 100644
--- a/test4.hs
+++ b/test4.hs
@@ -124,6 +124,7 @@ redraw :: State -> IO ()
redraw _q@State{..} = do
let image =
+ map (fmap $ fmap $ sub '\t' ' ') $
map (trammelTake screenWidth . trammelDrop xoffset) $
take screenHeight $
headBuffer ++ drop yoffset treeBuffer
@@ -135,6 +136,8 @@ redraw _q@State{..} = do
putStr $ pp $ "\ESC[H" <> first <> mconcat (map ("\n"<>) rest)
_ ->
return ()
+ where
+ sub x x' c = if c == x then x' else c