diff options
Diffstat (limited to '')
-rw-r--r-- | lib/todos.ml | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/todos.ml b/lib/todos.ml index 0920829..bc8607f 100644 --- a/lib/todos.ml +++ b/lib/todos.ml @@ -73,17 +73,34 @@ let rec render | `Mouse ((`Press _ | `Drag), (_, y), _) -> render t { state with pos = 0, min y content_end } | `Key (`ASCII '?', []) -> Help_screen.render t { go_back = (fun () -> render t state) } - | `Key (`ASCII 's', []) -> + | `Key (`ASCII '1', []) -> goto_headlines (fun () -> render t state) + | `Key (`ASCII '3', []) -> goto_done (fun () -> render t state) + | `Key (`ASCII 'g', []) -> + let content, content_pretty = load_todos () in + let y = min (List.length content_pretty + content_start) y in + render + t + { state with + pos = x, y + ; content = content |> Array.of_list + ; content_pretty = Array.of_list content_pretty + } + | `Key (`ASCII 'r', []) -> let (input_state : Input_screen.state) = { screen = img ; user_input = "" - ; prompt = "GREP: " + ; prompt = "REGEXP: " ; on_enter = (fun tag -> - let content = Grep.get_tagged_headlines tag () |> Grep.parse_headlines in - let content_pretty = Grep.pretty_format content in + let content = Grep.get_tagged_todo tag () |> Grep.parse_todo_string in + let content_pretty = Grep.pretty_format_todo content in Common.Term.cursor t None; - render t { state with content; content_pretty }) + render + t + { state with + content = content |> Array.of_list + ; content_pretty = content_pretty |> Array.of_list + }) ; on_cancel = (fun _ -> Common.Term.cursor t None; @@ -91,18 +108,6 @@ let rec render } in Input_screen.render t input_state - | `Key (`ASCII '1', []) -> goto_headlines (fun () -> render t state) - | `Key (`ASCII '3', []) -> goto_done (fun () -> render t state) - | `Key (`ASCII 'g', []) -> - let content, content_pretty = load_todos () in - let y = min (List.length content_pretty + content_start) y in - render - t - { state with - pos = x, y - ; content = content |> Array.of_list - ; content_pretty = Array.of_list content_pretty - } | `Key (`ASCII 'j', []) | `Key (`ASCII 'N', [ `Ctrl ]) -> scroll_down () | `Key (`ASCII 'k', []) | `Key (`ASCII 'P', [ `Ctrl ]) -> scroll_up () | `Key (`ASCII 't', []) -> |