diff options
author | Raúl Benencia <rul@kalgan.cc> | 2013-09-05 22:42:28 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2013-09-05 22:42:28 -0300 |
commit | 4f9e2732d8c19bcb731f82d590436f5a3168ec8d (patch) | |
tree | d31241f86dc8ad15fd4a5e9594b171cfcba60cf1 /src/Lazymail/Screen.hs | |
parent | 7af6e583d7d6893f67745e23017eba436f8ed826 (diff) |
Working configurable keybindings
Diffstat (limited to 'src/Lazymail/Screen.hs')
-rw-r--r-- | src/Lazymail/Screen.hs | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/Lazymail/Screen.hs b/src/Lazymail/Screen.hs index 7bc980b..ba64cee 100644 --- a/src/Lazymail/Screen.hs +++ b/src/Lazymail/Screen.hs @@ -19,12 +19,13 @@ import System.Exit import UI.NCurses -- Local imports +import Codec.Text.Rfc1342 import Lazymail.Config import qualified Lazymail.Handlers as EH +import Lazymail.Keymap(findHandler) import Lazymail.Maildir import Lazymail.Email(lookupField, getBody, getHeaders, lookupField') import Lazymail.Print -import Codec.Text.Rfc1342 import Lazymail.State import Lazymail.Types @@ -217,30 +218,20 @@ drawStatusHelper IndexMode st = {- Status bar string for Email mode -} drawStatusHelper EmailMode st = ["mode: Email"] -{- Handle an event - - TODO: Handle the events in a cleaner way. -} +{- Handle an event -} handleEvent :: LazymailCurses () handleEvent = loop where loop = do + st <- get + cfg <- ask w <- liftCurses $ defaultWindow ev <- liftCurses $ getEvent w Nothing - st <- get case ev of Nothing -> loop Just ev' -> - case ev' of - EventCharacter 'q' -> EH.previousMode - - EventSpecialKey KeyUpArrow -> EH.scrollUp - EventCharacter 'k' -> EH.scrollUp - - EventSpecialKey KeyDownArrow -> EH.scrollDown - EventCharacter 'j' -> EH.scrollDown - - EventCharacter '\n' -> EH.advanceMode - EventSpecialKey KeyRightArrow -> EH.advanceMode - - _ -> loop + case findHandler st cfg ev' of + Nothing -> loop + Just handler -> handler {- Reset the current row to the beginning -} resetCurrentRow = (=<<) put $ get >>= \st -> return $ st { currentRow = 0 } |