aboutsummaryrefslogtreecommitdiff
path: root/lib/todos.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-05-15 14:18:05 -0500
committerMarc Coquand <marc@mccd.space>2024-05-15 14:18:05 -0500
commit613b17e9f30b4def18e014993576a4324d9b11a4 (patch)
treeeada6c85627f617dc226137d0f1a024360ca2baa /lib/todos.ml
parente1bdc8f64a16b233a2633b05c2b073169a4c42c4 (diff)
downloadstitch-613b17e9f30b4def18e014993576a4324d9b11a4.tar.gz
stitch-613b17e9f30b4def18e014993576a4324d9b11a4.tar.bz2
stitch-613b17e9f30b4def18e014993576a4324d9b11a4.zip
Add regexp search for done and todo
Diffstat (limited to 'lib/todos.ml')
-rw-r--r--lib/todos.ml39
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', []) ->