diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-24 18:35:29 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-24 18:35:29 -0500 |
commit | ade6e1bf69887a6e47c8bde8d736ee6316008ab9 (patch) | |
tree | e62c942f1abfc67273e84800da80b9fedea70762 /lib/stitched_article.ml | |
parent | 527e025e88fc01c7ed4fc3f951484b051c264d83 (diff) | |
download | stitch-ade6e1bf69887a6e47c8bde8d736ee6316008ab9.tar.gz stitch-ade6e1bf69887a6e47c8bde8d736ee6316008ab9.tar.bz2 stitch-ade6e1bf69887a6e47c8bde8d736ee6316008ab9.zip |
Stashnarrowing
Diffstat (limited to 'lib/stitched_article.ml')
-rw-r--r-- | lib/stitched_article.ml | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/stitched_article.ml b/lib/stitched_article.ml index 86a22e9..d053fe1 100644 --- a/lib/stitched_article.ml +++ b/lib/stitched_article.ml @@ -13,13 +13,15 @@ type state = ; goto_todos_view : (unit -> unit) -> unit ; goto_done_view : (unit -> unit) -> unit ; output : string option - ; tag : string + ; tag : string list } let title ~tag = match tag with - | "" -> I.strf ~attr:A.(st bold) "%s" "Notes" |> I.pad ~l:0 ~t:0 - | a -> I.strf ~attr:A.(st bold) "%s > %s" "Notes" a |> I.pad ~l:0 ~t:0 + | [] -> I.strf ~attr:A.(st bold) "%s" "Notes" |> I.pad ~l:0 ~t:0 + | _ -> + let tags_str = String.concat " > " tag in + I.strf ~attr:A.(st bold) "%s > %s" "Notes" tags_str |> I.pad ~l:0 ~t:0 let content_start = 1 @@ -50,8 +52,7 @@ let rec render and elements = Array.mapi (fun i (_, el) -> Compontent.current_line size_x y scroll el (i + content_start)) - (* TODO: Fix this ugly slow conversion *) - (Array.to_seq content_pretty |> Seq.drop scroll |> Array.of_seq) + (content_pretty |> Basic.array_drop scroll) in let open I in output_info </> Array.fold_left (fun sum el -> el </> sum) (title ~tag) elements @@ -97,7 +98,7 @@ let rec render in let result = Export.to_path path ~content:export in render t { state with output = Some result }) - else render t { state with output = Some "Export Blank; skipping" }) + else render t { state with output = Some "Export blank; skipping" }) ; on_cancel = (fun _ -> Common.Term.cursor t None; @@ -163,10 +164,10 @@ let rec render ; user_input = "" ; prompt = "REGEXP" ; on_enter = - (fun tag -> + (fun new_tag -> try - let content = Grep.get_file_names tag |> Array.of_list in let oc = open_out "/tmp/stitch-output" in + let content = Grep.get_file_names (new_tag :: tag) |> Array.of_list in Printf.fprintf oc "%s\n" (String.concat "\n" (content |> Array.to_list)); close_out oc; let content = @@ -187,7 +188,7 @@ let rec render ; content_pretty ; pos = 0, content_start ; scroll = 0 - ; tag + ; tag = new_tag :: tag } with | _ -> |