diff options
author | tv <tv@shackspace.de> | 2014-12-25 18:37:39 +0100 |
---|---|---|
committer | tv <tv@shackspace.de> | 2014-12-25 18:37:39 +0100 |
commit | 235e78ebf0ac09b1f213f7090f6cce34d90dd00a (patch) | |
tree | 4553dc5668fccd7879894ddd57b8ab897d82db21 | |
parent | 0faf55683d3032dce0f16cb69c3127d94dc729bc (diff) |
print message on unbound key
-rw-r--r-- | test3.hs | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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 |