Use liftIO instead of suspendAndResume
This commit is contained in:
parent
a8bdc47b2c
commit
efeeef39eb
3 changed files with 6 additions and 3 deletions
|
|
@ -28,6 +28,7 @@ dependencies:
|
||||||
#- bytestring
|
#- bytestring
|
||||||
- containers
|
- containers
|
||||||
- megaparsec
|
- megaparsec
|
||||||
|
- mtl
|
||||||
- optparse-applicative
|
- optparse-applicative
|
||||||
#- sqlite-simple
|
#- sqlite-simple
|
||||||
#- stm
|
#- stm
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ module TaskMachine.UI.Behaviors.TaskEdit
|
||||||
|
|
||||||
import qualified Brick as B
|
import qualified Brick as B
|
||||||
import qualified Brick.Widgets.Edit as B
|
import qualified Brick.Widgets.Edit as B
|
||||||
|
import Control.Monad.Trans
|
||||||
import qualified Data.Text.Zipper as T
|
import qualified Data.Text.Zipper as T
|
||||||
import qualified Graphics.Vty as VTY
|
import qualified Graphics.Vty as VTY
|
||||||
import Text.Megaparsec
|
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 _ 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.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.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
|
let newState = finishEdit edit s
|
||||||
saveUIState newState
|
liftIO $ saveUIState newState
|
||||||
pure newState
|
B.continue newState
|
||||||
taskEditBehavior edit s e = do
|
taskEditBehavior edit s e = do
|
||||||
newEdit <- B.handleEditorEvent e edit
|
newEdit <- B.handleEditorEvent e edit
|
||||||
B.continue s{taskEdit=Just newEdit}
|
B.continue s{taskEdit=Just newEdit}
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -7,3 +7,4 @@
|
||||||
- c2018-09-28 Move cursor to beginning of task description when editing tasks
|
- c2018-09-28 Move cursor to beginning of task description when editing tasks
|
||||||
- c2018-09-28 Syntax highlighting while editing tasks
|
- c2018-09-28 Syntax highlighting while editing tasks
|
||||||
x2018-09-27 c2018-09-18 Quit using Esc or q
|
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue