From 96871af9eeac125562926ed373067530d303949f Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 29 Dec 2014 02:10:32 +0100 Subject: show relative time --- test5.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'test5.hs') diff --git a/test5.hs b/test5.hs index a65b719..2b43942 100644 --- a/test5.hs +++ b/test5.hs @@ -17,6 +17,7 @@ import Control.Exception import Control.Monad import Data.Maybe import Data.Monoid +import Data.Time import Scanner (getKey) import System.Directory import System.Environment @@ -135,9 +136,10 @@ winchHandler putEvent = run :: IO Event -> State -> IO () run getEvent = rec where - rec q = rec =<< - let q' = render q - in redraw q' >> getEvent >>= processEvent q' + rec q = rec =<< do + now <- getCurrentTime + let q' = render now q + redraw q' >> getEvent >>= processEvent q' processEvent :: State -> Event -> IO State @@ -161,13 +163,13 @@ processEvent q = \case } -render :: State -> State -render q@State{..} = +render :: UTCTime -> State -> State +render now q@State{..} = q { treeBuffer = newTreeBuf , headBuffer = newHeadBuf } where - newTreeBuf = renderTreeView (Z.label cursor) (Z.toTree cursor) + newTreeBuf = renderTreeView now (Z.label cursor) (Z.toTree cursor) newHeadBuf = [ Plain (show screenWidth) <> "x" <> Plain (show screenHeight) <> " " <> Plain (show $ linearPos cursor - yoffset) -- cgit v1.2.3