diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-15 10:45:54 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-15 10:45:54 -0500 |
commit | 47892663040f7e295cc4052438cf804b040f0389 (patch) | |
tree | d299cb4f0741904b1a8d484a6fba365b41592bf5 /lib/headlines.ml | |
parent | 7038e0073e7f7f672644ca949eeda399d6a533fb (diff) | |
download | stitch-47892663040f7e295cc4052438cf804b040f0389.tar.gz stitch-47892663040f7e295cc4052438cf804b040f0389.tar.bz2 stitch-47892663040f7e295cc4052438cf804b040f0389.zip |
Add TODOs, update help, rebind keys
Diffstat (limited to 'lib/headlines.ml')
-rw-r--r-- | lib/headlines.ml | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/headlines.ml b/lib/headlines.ml index b30903d..0633a73 100644 --- a/lib/headlines.ml +++ b/lib/headlines.ml @@ -4,6 +4,7 @@ open Notty module Input_screen = Input_screen module Stitched_article = Stitched_article module Help_screen = Help_screen +module Todos = Todos type state = { pos : int * int @@ -12,6 +13,7 @@ type state = ; content_pretty : string array } +(* TODO: Add page title *) let rec render t ({ pos; scroll; content; content_pretty } as state) = let x, y = pos in let img = @@ -48,7 +50,16 @@ let rec render t ({ pos; scroll; content; content_pretty } as state) = | `Mouse ((`Press _ | `Drag), (_, y), _) -> render t { state with pos = 0, min y content_length } | `Key (`ASCII '?', []) -> Help_screen.render t { go_back = (fun () -> render t state) } - | `Key (`ASCII '@', []) -> + | `Key (`ASCII 't', []) -> + let todo_content = Grep.get_todos () |> Grep.parse_todo_string in + let todo_pretty = Grep.pretty_format_todo todo_content in + let todo_state = + Todos.init + ~content:(todo_content |> Array.of_list) + ~content_pretty:(todo_pretty |> Array.of_list) + in + Todos.render t todo_state + | `Key (`ASCII 's', []) -> let content = Array.map (fun (file_name, _) -> Grep.get_full_file_content_content file_name) @@ -67,11 +78,11 @@ let rec render t ({ pos; scroll; content; content_pretty } as state) = ; scroll = 0 ; 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 |