terminal user interface to jujutsu. Focused on speed and clarity
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix issues with graph and file hovering updating/not updating

+60 -59
+48 -52
jj_tui/bin/file_view.ml
··· 10 10 open Jj_tui 11 11 open Picos_std_structured 12 12 13 - let active_files= Lwd.var [""] 13 + let active_files = Lwd.var [ "" ] 14 14 15 15 let rec command_mapping = 16 16 [ ··· 33 33 , fun rev -> 34 34 Cmd 35 35 ([ 36 - "squash" 37 - ; "-u" 38 - ; "--keep-emptied" 39 - ; "--from" 40 - ; get_hovered_rev () 41 - ; "--into" 42 - ; rev 43 - ] 44 - @ 45 - (Lwd.peek active_files)) 46 - ) 36 + "squash" 37 + ; "-u" 38 + ; "--keep-emptied" 39 + ; "--from" 40 + ; get_hovered_rev () 41 + ; "--into" 42 + ; rev 43 + ] 44 + @ Lwd.peek active_files) ) 47 45 } 48 46 ; { 49 47 key = 'N' ··· 51 49 ; cmd = 52 50 Dynamic_r 53 51 (fun rev -> 54 - Cmd ( 55 - [ 56 - "squash" 57 - ; "-u" 58 - ; "--keep-emptied" 59 - ; "--from" 60 - ; rev 61 - ; "--into" 62 - ; rev ^ "+" 63 - ]@ 64 - Lwd.peek active_files 65 - ) 66 - ) 52 + Cmd 53 + ([ "squash"; "-u"; "--keep-emptied"; "--from"; rev; "--into"; rev ^ "+" ] 54 + @ Lwd.peek active_files)) 67 55 } 68 56 ; { 69 57 key = 'P' ··· 71 59 ; cmd = 72 60 Dynamic_r 73 61 (fun rev -> 74 - Cmd( 75 - [ 76 - "squash" 77 - ; "-u" 78 - ; "--keep-emptied" 79 - ; "--from" 80 - ; rev 81 - ; "--into" 82 - ; rev ^ "-" 83 - ]@ 84 - Lwd.peek active_files 85 - ) 86 - ) 62 + Cmd 63 + ([ "squash"; "-u"; "--keep-emptied"; "--from"; rev; "--into"; rev ^ "-" ] 64 + @ Lwd.peek active_files)) 87 65 } 88 66 ; { 89 67 key = 'd' ··· 93 71 (fun rev -> 94 72 let selected = Lwd.peek active_files in 95 73 confirm_prompt 96 - ("discard all changes to:\n" ^ (selected|>String.concat "\n") ^ "\nin rev " ^ rev) 97 - (Cmd (["restore"; "--to"; rev; "--from"; rev ^ "-"] @selected))) 74 + ("discard all changes to:\n" 75 + ^ (selected |> String.concat "\n") 76 + ^ "\nin rev " 77 + ^ rev) 78 + (Cmd ([ "restore"; "--to"; rev; "--from"; rev ^ "-" ] @ selected))) 98 79 } 99 80 ] 100 81 ;; 82 + 83 + let hovered_var = ref "./" 101 84 102 85 let file_view focus = 103 86 let file_uis = ··· 117 100 It will have a cancellation system just like this one. 118 101 when any of the dependencies change, selected file, selected rev, focus etc, it will re-render if needed and cancel the current rendering. 119 102 *) 120 - file_uis|> 121 - W.Lists.multi_selection_list_custom 122 - ~reset_selections:Vars.ui_state.reset_selection 123 - ~on_selection_change:(fun ~hovered ~selected -> 124 - let active= 125 - if selected|>List.length =0 then [hovered] else selected 126 - in 127 - Lwd.set active_files active; 128 - if Focus.peek_has_focus focus 129 - then Show_view.(pushStatus (File_preview (Vars.get_hovered_rev (), hovered)))) 130 - ~custom_handler:(fun ~selected:_ ~selectable_items:_ key -> 131 - match key with `ASCII k, [] -> handleInputs command_mapping k | _ -> `Unhandled) 103 + let ui = 104 + file_uis 105 + |> W.Lists.multi_selection_list_custom 106 + ~reset_selections:Vars.ui_state.reset_selection 107 + ~on_selection_change:(fun ~hovered ~selected -> 108 + let active = if selected |> List.length = 0 then [ hovered ] else selected in 109 + Lwd.set active_files active; 110 + hovered_var := hovered; 111 + if Focus.peek_has_focus focus 112 + then 113 + Show_view.(push_status (File_preview (Vars.get_hovered_rev (), hovered)))) 114 + ~custom_handler:(fun ~selected:_ ~selectable_items:_ key -> 115 + match key with 116 + | `ASCII k, [] -> 117 + handleInputs command_mapping k 118 + | _ -> 119 + `Unhandled) 120 + in 121 + let$ ui = ui 122 + and$ _ = 123 + Focus.status focus |>$ fun focus -> 124 + if Focus.has_focus focus 125 + then Show_view.(push_status (File_preview (Vars.get_hovered_rev (), !hovered_var))) 126 + in 127 + ui 132 128 ;; 133 129 end
+6 -3
jj_tui/bin/graph_view.ml
··· 351 351 352 352 (*TODO:make a custom widget the renders the commit with and without selection. 353 353 with selection replace the dot with a blue version and slightly blue tint the background *) 354 - let graph_view () = 354 + let graph_view ~focus () = 355 355 (*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 *) 356 356 let error_var = Lwd.var None in 357 357 let revset_ui = ··· 431 431 Lwd.set Vars.ui_state.hovered_revision hovered; 432 432 Lwd.set Vars.ui_state.selected_revisions selected; 433 433 (*If the files are focused we shouldn't send this*) 434 - if Show_view.lastMessage 435 - Show_view.(pushStatus (Graph_preview (Vars.get_hovered_rev ()))); 434 + if Focus.peek_has_focus focus then 435 + Show_view.(push_status (Graph_preview (Vars.get_hovered_rev ()))); 436 436 437 437 [%log debug "Hovered revision: '%s'" (Global_vars.get_unique_id hovered)]; 438 438 Picos_std_structured.Flock.fork (fun () -> Global_funcs.update_views ())) ··· 440 440 in 441 441 let final_ui = 442 442 let$ list_ui = list_ui 443 + and$ _= Focus.status focus|>$(fun focus->if Focus.has_focus focus then 444 + Show_view.(push_status (Graph_preview (Vars.get_hovered_rev ()))); 445 + ) 443 446 and$ error = Lwd.get error_var in 444 447 match error with Some e -> e |> Ui.keyboard_area handleKeys | None -> list_ui 445 448 in
+1 -1
jj_tui/bin/jj_ui.ml
··· 111 111 ~mh:(if focused then Int.min (ui |> Ui.layout_max_height) 12 else 2) 112 112 ~mw:1000) 113 113 |> W.Box.focusable ~focus:file_focus ~pad_h:0 ~pad_w:1 114 - ; Graph_view.graph_view () 114 + ; Graph_view.graph_view ~focus:graph_focus () 115 115 |>$ Ui.resize ~sh:3 ~w:5 ~sw:1 ~mw:1000 ~h:10 ~mh:1000 116 116 |> W.Box.focusable ~focus:graph_focus ~pad_h:0 ~pad_w:1 117 117 ; W.Scroll.v_area (ui_state.jj_branches $-> Ui.atom)
+5 -3
jj_tui/bin/show_view.ml
··· 8 8 [@@deriving show] 9 9 10 10 let statusStream = Stream.create () 11 - let lastMessage = None 12 - let pushStatus status = Stream.push statusStream status 11 + let lastMessage = ref None 12 + let push_status status = 13 + lastMessage:=Some status; 14 + Stream.push statusStream status 13 15 14 16 (** pushes the last message to the queue again to re-render everything *) 15 - let re_render () = lastMessage |> Option.iter pushStatus 17 + let re_render () = !lastMessage |> Option.iter push_status 16 18 17 19 module Make (Vars : Global_vars.Vars) = struct 18 20 open Lwd_infix