From c557b89e46ed076f7af13d8631e480ac14b2545a Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 24 Oct 2018 16:54:21 +0000 Subject: [PATCH] Replace crashes with popups --- src/TaskMachine/UI/Behaviors.hs | 9 +++++++-- todo.txt | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/TaskMachine/UI/Behaviors.hs b/src/TaskMachine/UI/Behaviors.hs index ea7b0c6..f7aa265 100644 --- a/src/TaskMachine/UI/Behaviors.hs +++ b/src/TaskMachine/UI/Behaviors.hs @@ -113,7 +113,7 @@ actionEditNew s = do actionEditSelected :: Action actionEditSelected s = case selectedTask (tasks s) of - Nothing -> error "no task selected" -- TODO: Add popup notification + Nothing -> pure s Just t -> let edit = taskEdit RTaskEdit t ExistingTask in pure s{editor=Just edit} @@ -194,7 +194,12 @@ actionFinishEdit t = pure . finishEdit t finishEdit :: TaskEdit RName -> UIState -> UIState finishEdit edit s = case editedTask edit of - Left e -> error e -- TODO: Error popup + Left e -> + let p = popup "Syntax error" e + [ ("Continue editing", B.continue) + , ("Abort", \s' -> B.continue s'{editor=Nothing}) + ] + in s{errorPopup=Just p} Right task -> s{tasks=modify task, editor=Nothing} where modify :: Task -> TaskList RName diff --git a/todo.txt b/todo.txt index af28786..555e400 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,4 @@ -- c2018-09-18 Clean up file (adding creation/completion dates) +x2018-10-23 c2018-09-18 Clean up file (adding creation/completion dates) - c2018-09-18 Purge - move completed tasks to a separate file x2018-10-23 c2018-09-28 Move cursor to beginning of task description when editing tasks - c2018-09-28 Syntax highlighting while editing tasks @@ -9,4 +9,7 @@ x2018-09-30 c2018-09-18 Offer "retry" or "quit" +dialogue - couldn't load from t x2018-09-30 c2018-09-18 Offer "retry" or "quit" +dialogue - couldn't save to todo file x2018-09-30 c2018-09-18 Offer "retry" or "quit" +dialogue - syntax error in todo file x2018-09-30 c2018-09-30 Custom exception messages -- c2018-10-23 Don't crash on parse errors etc. +x2018-10-24 c2018-10-23 Don't crash on parse errors etc. +- c2018-10-24 Add "u" - undo and "z" - redo buttons +- c2018-10-24 Redo coloring - maybe black-on-white color scheme in-editor? +- c2018-10-24 Reverse ordering of completed tasks - most recent at the top