diff options
Diffstat (limited to '')
-rw-r--r-- | lib/done.ml | 15 | ||||
-rw-r--r-- | lib/grep.ml | 24 | ||||
-rw-r--r-- | lib/todos.ml | 39 |
3 files changed, 56 insertions, 22 deletions
diff --git a/lib/done.ml b/lib/done.ml index 6a60fd1..815f663 100644 --- a/lib/done.ml +++ b/lib/done.ml @@ -73,17 +73,22 @@ 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 '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_done 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; diff --git a/lib/grep.ml b/lib/grep.ml index 0e8294a..f672d01 100644 --- a/lib/grep.ml +++ b/lib/grep.ml @@ -99,6 +99,30 @@ let pretty_format_todo parsed_headlines = parsed_headlines +let get_tagged_done tag () = + let open Shexp_process in + let open Shexp_process.Infix in + eval + (chdir + execution_directory + (call done_get_args + |- call [ grep_cmd; "--no-messages"; "-E"; tag ] + |- call [ "sort"; "-n"; "-r" ] + |- read_all)) + + +let get_tagged_todo tag () = + let open Shexp_process in + let open Shexp_process.Infix in + eval + (chdir + execution_directory + (call todo_get_args + |- call [ grep_cmd; "--no-messages"; "-E"; tag ] + |- call [ "sort"; "-n"; "-r" ] + |- read_all)) + + let toggle_done file_name = let open Shexp_process in run_calls 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', []) -> |