aboutsummaryrefslogtreecommitdiff
path: root/lib/stitched_article.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stitched_article.ml')
-rw-r--r--lib/stitched_article.ml26
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