diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-23 13:45:28 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-23 13:45:28 -0500 |
commit | eed9e36b661009e5bcf1c4f5ec3a9279bbb7cda5 (patch) | |
tree | 65940a73db6096bd5f7bcb8d3b9a86f4f28864ab /lib/stitched_article.ml | |
parent | 833716046de9b3ee8e4f277f383967c0d35ba28a (diff) | |
download | stitch-eed9e36b661009e5bcf1c4f5ec3a9279bbb7cda5.tar.gz stitch-eed9e36b661009e5bcf1c4f5ec3a9279bbb7cda5.tar.bz2 stitch-eed9e36b661009e5bcf1c4f5ec3a9279bbb7cda5.zip |
Add ability to export current view
Diffstat (limited to 'lib/stitched_article.ml')
-rw-r--r-- | lib/stitched_article.ml | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/stitched_article.ml b/lib/stitched_article.ml index ae9f174..deedb43 100644 --- a/lib/stitched_article.ml +++ b/lib/stitched_article.ml @@ -79,6 +79,32 @@ let rec render 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 'o', []) -> + let (input_state : Input_prompt.state) = + { screen = img + ; user_input = "" + ; prompt = "EXPORT TO" + ; on_enter = + (fun path -> + Common.Term.cursor t None; + if String.equal (String.trim path) String.empty |> not + then ( + let export = + String.concat + "\n" + (Array.to_list content_pretty + |> List.map (fun (_, b) -> Grep.display_type_line b)) + in + Export.to_path path ~content:export; + render t { state with output = Some ("Export written to: " ^ path ) }) + else render t { state with output = Some "Export Blank; skipping" }) + ; on_cancel = + (fun _ -> + Common.Term.cursor t None; + render t {state with output = Some "Export Cancelled"}) + } + in + Input_prompt.render t input_state | `Key (`ASCII '!', []) -> let file_number_offset, content_line = Array.get content_pretty (y - content_start) in let content_line = Grep.display_type_line content_line in |