diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-15 14:13:09 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-15 14:13:09 -0500 |
commit | e1bdc8f64a16b233a2633b05c2b073169a4c42c4 (patch) | |
tree | e6b81b42159a214eda6a61f7ef1c710ee1a7e2e5 | |
parent | 3f696169ab1a560d94d169c1a5b744346da4c081 (diff) | |
download | stitch-e1bdc8f64a16b233a2633b05c2b073169a4c42c4.tar.gz stitch-e1bdc8f64a16b233a2633b05c2b073169a4c42c4.tar.bz2 stitch-e1bdc8f64a16b233a2633b05c2b073169a4c42c4.zip |
Add refresh button
Diffstat (limited to '')
-rw-r--r-- | lib/done.ml | 14 | ||||
-rw-r--r-- | lib/help_screen.ml | 4 | ||||
-rw-r--r-- | lib/todos.ml | 14 |
3 files changed, 28 insertions, 4 deletions
diff --git a/lib/done.ml b/lib/done.ml index 5daad60..6a60fd1 100644 --- a/lib/done.ml +++ b/lib/done.ml @@ -93,16 +93,28 @@ let rec render Input_screen.render t input_state | `Key (`ASCII '1', []) -> goto_headlines (fun () -> render t state) | `Key (`ASCII '2', []) -> goto_todo (fun () -> render t state) + | `Key (`ASCII 'g', []) -> + let content, content_pretty = load_done () 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', []) -> let selected_file, _ = Array.get content (y - content_start) in let _ = Grep.toggle_todo selected_file in let content, content_pretty = load_done () in + let y = min (List.length content_pretty + content_start) y in render t { state with - content = content |> Array.of_list + pos = x, y + ; content = content |> Array.of_list ; content_pretty = Array.of_list content_pretty } | `Key (`Arrow d, _) -> diff --git a/lib/help_screen.ml b/lib/help_screen.ml index b74e91c..af744c4 100644 --- a/lib/help_screen.ml +++ b/lib/help_screen.ml @@ -52,8 +52,8 @@ let render_menu ~menu ~title ~start_y = let note_view_menu = [ "Toggle Stitch", "s" ] -let todo_view_menu = [ "Toggle Done", "t" ] -let done_view_menu = [ "Toggle Todo", "t" ] +let todo_view_menu = [ "Toggle Done", "t"; "Refresh", "g" ] +let done_view_menu = [ "Toggle Todo", "t"; "Refresh", "g" ] let rec render t ({ go_back } as state) = let img = diff --git a/lib/todos.ml b/lib/todos.ml index fd9eaf1..0920829 100644 --- a/lib/todos.ml +++ b/lib/todos.ml @@ -93,16 +93,28 @@ let rec render 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', []) -> let selected_file, _ = Array.get content (y - content_start) in let _ = Grep.toggle_done selected_file in let content, content_pretty = load_todos () in + let y = min (List.length content_pretty + content_start) y in render t { state with - content = content |> Array.of_list + pos = x, y + ; content = content |> Array.of_list ; content_pretty = Array.of_list content_pretty } | `Key (`Arrow d, _) -> |