···1010 open Jj_tui
1111 open Picos_std_structured
12121313- let active_files= Lwd.var [""]
1313+ let active_files = Lwd.var [ "" ]
14141515 let rec command_mapping =
1616 [
···3333 , fun rev ->
3434 Cmd
3535 ([
3636- "squash"
3737- ; "-u"
3838- ; "--keep-emptied"
3939- ; "--from"
4040- ; get_hovered_rev ()
4141- ; "--into"
4242- ; rev
4343- ]
4444- @
4545- (Lwd.peek active_files))
4646- )
3636+ "squash"
3737+ ; "-u"
3838+ ; "--keep-emptied"
3939+ ; "--from"
4040+ ; get_hovered_rev ()
4141+ ; "--into"
4242+ ; rev
4343+ ]
4444+ @ Lwd.peek active_files) )
4745 }
4846 ; {
4947 key = 'N'
···5149 ; cmd =
5250 Dynamic_r
5351 (fun rev ->
5454- Cmd (
5555- [
5656- "squash"
5757- ; "-u"
5858- ; "--keep-emptied"
5959- ; "--from"
6060- ; rev
6161- ; "--into"
6262- ; rev ^ "+"
6363- ]@
6464- Lwd.peek active_files
6565- )
6666- )
5252+ Cmd
5353+ ([ "squash"; "-u"; "--keep-emptied"; "--from"; rev; "--into"; rev ^ "+" ]
5454+ @ Lwd.peek active_files))
6755 }
6856 ; {
6957 key = 'P'
···7159 ; cmd =
7260 Dynamic_r
7361 (fun rev ->
7474- Cmd(
7575- [
7676- "squash"
7777- ; "-u"
7878- ; "--keep-emptied"
7979- ; "--from"
8080- ; rev
8181- ; "--into"
8282- ; rev ^ "-"
8383- ]@
8484- Lwd.peek active_files
8585- )
8686- )
6262+ Cmd
6363+ ([ "squash"; "-u"; "--keep-emptied"; "--from"; rev; "--into"; rev ^ "-" ]
6464+ @ Lwd.peek active_files))
8765 }
8866 ; {
8967 key = 'd'
···9371 (fun rev ->
9472 let selected = Lwd.peek active_files in
9573 confirm_prompt
9696- ("discard all changes to:\n" ^ (selected|>String.concat "\n") ^ "\nin rev " ^ rev)
9797- (Cmd (["restore"; "--to"; rev; "--from"; rev ^ "-"] @selected)))
7474+ ("discard all changes to:\n"
7575+ ^ (selected |> String.concat "\n")
7676+ ^ "\nin rev "
7777+ ^ rev)
7878+ (Cmd ([ "restore"; "--to"; rev; "--from"; rev ^ "-" ] @ selected)))
9879 }
9980 ]
10081 ;;
8282+8383+ let hovered_var = ref "./"
1018410285 let file_view focus =
10386 let file_uis =
···117100 It will have a cancellation system just like this one.
118101 when any of the dependencies change, selected file, selected rev, focus etc, it will re-render if needed and cancel the current rendering.
119102 *)
120120- file_uis|>
121121- W.Lists.multi_selection_list_custom
122122- ~reset_selections:Vars.ui_state.reset_selection
123123- ~on_selection_change:(fun ~hovered ~selected ->
124124- let active=
125125- if selected|>List.length =0 then [hovered] else selected
126126- in
127127- Lwd.set active_files active;
128128- if Focus.peek_has_focus focus
129129- then Show_view.(pushStatus (File_preview (Vars.get_hovered_rev (), hovered))))
130130- ~custom_handler:(fun ~selected:_ ~selectable_items:_ key ->
131131- match key with `ASCII k, [] -> handleInputs command_mapping k | _ -> `Unhandled)
103103+ let ui =
104104+ file_uis
105105+ |> W.Lists.multi_selection_list_custom
106106+ ~reset_selections:Vars.ui_state.reset_selection
107107+ ~on_selection_change:(fun ~hovered ~selected ->
108108+ let active = if selected |> List.length = 0 then [ hovered ] else selected in
109109+ Lwd.set active_files active;
110110+ hovered_var := hovered;
111111+ if Focus.peek_has_focus focus
112112+ then
113113+ Show_view.(push_status (File_preview (Vars.get_hovered_rev (), hovered))))
114114+ ~custom_handler:(fun ~selected:_ ~selectable_items:_ key ->
115115+ match key with
116116+ | `ASCII k, [] ->
117117+ handleInputs command_mapping k
118118+ | _ ->
119119+ `Unhandled)
120120+ in
121121+ let$ ui = ui
122122+ and$ _ =
123123+ Focus.status focus |>$ fun focus ->
124124+ if Focus.has_focus focus
125125+ then Show_view.(push_status (File_preview (Vars.get_hovered_rev (), !hovered_var)))
126126+ in
127127+ ui
132128 ;;
133129end
+6-3
jj_tui/bin/graph_view.ml
···351351352352 (*TODO:make a custom widget the renders the commit with and without selection.
353353 with selection replace the dot with a blue version and slightly blue tint the background *)
354354- let graph_view () =
354354+ let graph_view ~focus () =
355355 (*We have a seperate error var here instead of using a result type. This allows us to avoid using Lwd.bind which would cause our list selection to get reset anytime the content changes *)
356356 let error_var = Lwd.var None in
357357 let revset_ui =
···431431 Lwd.set Vars.ui_state.hovered_revision hovered;
432432 Lwd.set Vars.ui_state.selected_revisions selected;
433433 (*If the files are focused we shouldn't send this*)
434434- if Show_view.lastMessage
435435- Show_view.(pushStatus (Graph_preview (Vars.get_hovered_rev ())));
434434+ if Focus.peek_has_focus focus then
435435+ Show_view.(push_status (Graph_preview (Vars.get_hovered_rev ())));
436436437437 [%log debug "Hovered revision: '%s'" (Global_vars.get_unique_id hovered)];
438438 Picos_std_structured.Flock.fork (fun () -> Global_funcs.update_views ()))
···440440 in
441441 let final_ui =
442442 let$ list_ui = list_ui
443443+ and$ _= Focus.status focus|>$(fun focus->if Focus.has_focus focus then
444444+ Show_view.(push_status (Graph_preview (Vars.get_hovered_rev ())));
445445+ )
443446 and$ error = Lwd.get error_var in
444447 match error with Some e -> e |> Ui.keyboard_area handleKeys | None -> list_ui
445448 in