aboutsummaryrefslogtreecommitdiff
path: root/lib/stitched_article.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-05-14 19:11:24 -0500
committerMarc Coquand <marc@mccd.space>2024-05-14 19:11:24 -0500
commit8dc118d9bf685d96022a010fb2a20d724c40b5cf (patch)
treece99ac0f13c0f8407bbde30630366b9143ef7558 /lib/stitched_article.ml
parenta76fb32e7c5815e37b5772f15326f00ec58a322d (diff)
downloadstitch-8dc118d9bf685d96022a010fb2a20d724c40b5cf.tar.gz
stitch-8dc118d9bf685d96022a010fb2a20d724c40b5cf.tar.bz2
stitch-8dc118d9bf685d96022a010fb2a20d724c40b5cf.zip
Add help menu
Diffstat (limited to 'lib/stitched_article.ml')
-rw-r--r--lib/stitched_article.ml4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/stitched_article.ml b/lib/stitched_article.ml
index bbdf7f4..c5c31d3 100644
--- a/lib/stitched_article.ml
+++ b/lib/stitched_article.ml
@@ -2,6 +2,7 @@ module Grep = Grep
module Common = Common
open Notty
module Input_screen = Input_screen
+module Help_screen = Help_screen
type state =
{ pos : int * int
@@ -62,6 +63,7 @@ let rec render t ({ pos; scroll; content_pretty; go_back; content } as state) =
render t { state with pos = 0, min y content_length }
| `Key (`ASCII 'j', []) | `Key (`ASCII 'N', [ `Ctrl ]) -> scroll_down ()
| `Key (`ASCII 'k', []) | `Key (`ASCII 'P', [ `Ctrl ]) -> scroll_up ()
+ | `Key (`ASCII '?', []) -> Help_screen.render t { go_back = (fun () -> render t state) }
| `Key (`ASCII 'e', []) | `Key (`Enter, []) ->
(* Editor might be set with extra args, in that case we need to separate these *)
let[@warning "-8"] (editor :: args) =
@@ -69,6 +71,8 @@ let rec render t ({ pos; scroll; content_pretty; go_back; content } as state) =
in
let selected_file, line_number, _, file_number_offset = Array.get content y in
let full_path_file = Grep.execution_directory ^ "/" ^ selected_file in
+ (* Because each file title consists of two lines, we need to account for the offset
+ it adds by removing the file_number *)
let line_number_arg = "+" ^ Int.to_string (line_number - file_number_offset) in
let full_args =
Array.append (Array.of_list args) [| line_number_arg; full_path_file |]