summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-12-25 18:37:39 +0100
committertv <tv@shackspace.de>2014-12-25 18:37:39 +0100
commit235e78ebf0ac09b1f213f7090f6cce34d90dd00a (patch)
tree4553dc5668fccd7879894ddd57b8ab897d82db21
parent0faf55683d3032dce0f16cb69c3127d94dc729bc (diff)
print message on unbound key
-rw-r--r--test3.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/test3.hs b/test3.hs
index 2f7bec4..1d4e59f 100644
--- a/test3.hs
+++ b/test3.hs
@@ -48,6 +48,7 @@ data State = State
, cursor :: Z.TreePos Z.Full TreeView
, xoffset :: Int
, yoffset :: Int
+ , message :: String
}
@@ -98,6 +99,7 @@ main' query =
, cursor = Z.fromTree $ fromSearchResults query r_
, xoffset = 0
, yoffset = 0
+ , message = "Welcome to much; quit with ^C"
}
rec :: State -> IO ()
@@ -113,10 +115,15 @@ main' query =
--string def (maybe "Nothing" describe (focusNext v cursor)) <->
treeImage (Just $ Z.label cursor) (Z.toTree cursor)
--renderTree q
- pic = picForImage $ translate xoffset yoffset img
+ pic = picForImage $
+ (string def message) <->
+ translate xoffset yoffset img
--v = Z.root cursor
update vty pic
nextEvent vty >>= \e -> case e of
+ EvKey (KChar 'c') [MCtrl] ->
+ error "^C"
+
EvKey (KChar 'k') [] ->
rec q { cursor = fromMaybe (Z.root cursor) $ findPrev cursor }
EvKey (KChar 'j') [] ->
@@ -133,7 +140,7 @@ main' query =
rec q
_ -> do
- error $ "Last event was: " ++ show e
+ rec q { message = "unbound key: " ++ show e }
where
onEnter c_ = case Z.label c_ of
TVMessage m -> do