···22open Lwd_infix
33open Jj_process.Make (Global_vars.Vars)
44open Picos_std_structured
55+open Jj_tui.Logging
5667let colored_string = Jj_tui.AnsiReverse.colored_string
78···5051 This should be called after any command that performs a change *)
5152let update_views ?(cause_snapshot = false) () =
5253 safe_jj (fun () ->
5454+ [%log debug "updating views"];
5355 let rev = Vars.get_hovered_rev () in
5456 let branches =
5557 jj_no_log ~snapshot:cause_snapshot [ "bookmark"; "list"; "-a" ] |> colored_string
···7476 let comp = Flock.fork_as_promise (fun () -> update_views ~cause_snapshot ()) in
7577 current_computation := comp
7678;;
7979+8080+let last_op_id = ref ""
8181+8282+(** Update all the jj views, if there has been some kind of change*)
8383+let update_if_changed () =
8484+ (* If the last op_id has changed then there has been a change somewhere and we should re-render. otherwise don't bother*)
8585+ [%log info "Checking if there has been a change to the repo"];
8686+ let this_op =
8787+ jj_no_log
8888+ ~color:false
8989+ ~snapshot:true
9090+ [ "op"; "log"; "--limit"; "1"; "-T"; "self.id()"; "--no-graph" ]
9191+ in
9292+ if !last_op_id <> this_op
9393+ then (
9494+ [%log info "updating ui state becasue of a change in the repo"];
9595+ last_op_id := this_op;
9696+ update_status ())
9797+;;
+1-2
jj_tui/bin/jj_ui.ml
···193193 Flock.fork (fun () ->
194194 while true do
195195 Picos.Fiber.sleep ~seconds:5.0;
196196- update_status ~cause_snapshot:true ()
197197- (*we need to lock this becasue we could end up updating while the ui is rendering*)
196196+ update_if_changed ()
198197 done;
199198 ());
200199 let$* running = Lwd.get ui_state.view in
+2-2
jj_tui/bin/show_view.ml
···108108 anything, obviously this is important"]);
109109 current_loading_computation
110110 := Flock.fork_as_promise (fun () ->
111111- (* If it's been more than half a second, show the state as loading*)
111111+ (* If it's been more than half a second, show the state as loading*)
112112 Control.sleep ~seconds:0.3;
113113 viewState $= { (Lwd.peek viewState) with detail = Loading });
114114 current_detail_computation
···116116 try
117117 [%log debug "Rendering status detail with: %a" pp_status_state msg];
118118 let detail = Loaded (render_detail msg) in
119119- (*Make sure the loading is done*)
119119+ (*Make sure the loading is done*)
120120 !current_loading_computation |> Promise.terminate;
121121 viewState $= { (Lwd.peek viewState) with detail }
122122 with
···11+## Key remapping:
22+33+How to hande key remapping:
44+- Inside nottui:
55+ - I coud allow users to specify some kind of key mapping function that looks for incoming keys and maps them to other keys.
66+- Inside my own program.
77+ - I could make all components take an `keyList` record and let the caller override that.
88+ - This option is more versitile because it allows one list to use say, arrows, and the other to use something like hjkl