From efeeef39eb9b93c794f2c98aaf409f14bb95c4fe Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 29 Sep 2018 10:59:36 +0000 Subject: [PATCH] Use liftIO instead of suspendAndResume --- package.yaml | 1 + src/TaskMachine/UI/Behaviors/TaskEdit.hs | 7 ++++--- todo.txt | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.yaml b/package.yaml index c338c30..595fb48 100644 --- a/package.yaml +++ b/package.yaml @@ -28,6 +28,7 @@ dependencies: #- bytestring - containers - megaparsec +- mtl - optparse-applicative #- sqlite-simple #- stm diff --git a/src/TaskMachine/UI/Behaviors/TaskEdit.hs b/src/TaskMachine/UI/Behaviors/TaskEdit.hs index ae0cf08..b251cf4 100644 --- a/src/TaskMachine/UI/Behaviors/TaskEdit.hs +++ b/src/TaskMachine/UI/Behaviors/TaskEdit.hs @@ -4,6 +4,7 @@ module TaskMachine.UI.Behaviors.TaskEdit import qualified Brick as B import qualified Brick.Widgets.Edit as B +import Control.Monad.Trans import qualified Data.Text.Zipper as T import qualified Graphics.Vty as VTY import Text.Megaparsec @@ -25,10 +26,10 @@ taskEditBehavior :: B.Editor String RName -> UIState -> VTY.Event -> NewState taskEditBehavior _ s (VTY.EvKey VTY.KEsc []) = B.continue s{taskEdit=Nothing} taskEditBehavior edit s (VTY.EvKey VTY.KHome []) = B.continue s{taskEdit=Just (B.applyEdit T.gotoBOL edit)} taskEditBehavior edit s (VTY.EvKey VTY.KEnd []) = B.continue s{taskEdit=Just (B.applyEdit T.gotoEOL edit)} -taskEditBehavior edit s (VTY.EvKey VTY.KEnter []) = B.suspendAndResume $ do +taskEditBehavior edit s (VTY.EvKey VTY.KEnter []) = do let newState = finishEdit edit s - saveUIState newState - pure newState + liftIO $ saveUIState newState + B.continue newState taskEditBehavior edit s e = do newEdit <- B.handleEditorEvent e edit B.continue s{taskEdit=Just newEdit} diff --git a/todo.txt b/todo.txt index 668e9be..4cb4270 100644 --- a/todo.txt +++ b/todo.txt @@ -7,3 +7,4 @@ - c2018-09-28 Move cursor to beginning of task description when editing tasks - c2018-09-28 Syntax highlighting while editing tasks x2018-09-27 c2018-09-18 Quit using Esc or q +x2018-09-29 c2018-09-28 Use B.EventM's MonadIO instance instead of B.suspendAndResume (facepalm)