Skip to content

Commit

Permalink
Clean eventHandler.
Browse files Browse the repository at this point in the history
  • Loading branch information
damianfral committed Oct 7, 2023
1 parent b196935 commit cc5ae3f
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,26 @@ eventHandler (VtyEvent evt) = case evt of
V.EvKey (KChar 'q') _ -> halt
V.EvKey (KChar 'J') _ -> modify movePrev
V.EvKey (KChar 'K') _ -> modify moveNext
V.EvKey (KChar 'j') _ ->
gets current >>= \Entry {..} -> vScrollBy (viewportScroll $ Content entryDay) 1
V.EvKey (KChar 'k') _ ->
gets current >>= \Entry {..} -> vScrollBy (viewportScroll $ Content entryDay) (-1)
V.EvKey (KChar 'e') _ ->
gets current >>= \Entry {..} ->
suspendAndResume' $ callProcess "$EDITOR" [entryFile]
V.EvKey (KChar 'j') _ -> increaseScrollContent
V.EvKey (KChar 'k') _ -> decreaseScrollContent
V.EvKey (KChar 'e') _ -> editContent
_ -> pure ()
eventHandler _ = pure ()

increaseScrollContent = do
Entry {..} <- gets current
let resource = Content entryDay
vScrollBy (viewportScroll resource) 1

decreaseScrollContent = do
Entry {..} <- gets current
let resource = Content entryDay
vScrollBy (viewportScroll resource) (-1)

editContent = do
Entry {..} <- gets current
suspendAndResume' $ callProcess "hx" [entryFile]

isMarkdownFile :: FilePath -> Bool
isMarkdownFile file = takeExtension file == ".md"

Expand Down

0 comments on commit cc5ae3f

Please sign in to comment.