summaryrefslogtreecommitdiffstats
path: root/test5.hs
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-12-29 02:10:32 +0100
committertv <tv@shackspace.de>2014-12-29 02:10:32 +0100
commit96871af9eeac125562926ed373067530d303949f (patch)
tree99e28de08913c1ac08a8f2241609ab3114797139 /test5.hs
parent8b1a855a0b6f122e8f9e372bdcaaa8abacddb079 (diff)
show relative time
Diffstat (limited to 'test5.hs')
-rw-r--r--test5.hs14
1 files changed, 8 insertions, 6 deletions
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)