···2020 the start ")
2121 else None)
2222;;
2323-2323+let is_jj_repo() =
2424+ jj_no_log ~color:false [ "log";"''" ] |> Base.String.is_substring ~substring:"There is no jj repo"|>not
2425(**Updates the status windows; Without snapshotting the working copy by default
2526 This should be called after any command that performs a change *)
2627let update_status ?(cause_snapshot = false) () =
+36-21
jj_tui/bin/jj_ui.ml
···107107108108 let mainUi ~sw env =
109109 (*we want to initialize our states and keep them up to date*)
110110- update_status ~cause_snapshot:true ();
111111- Eio.Fiber.fork_daemon ~sw (fun _ ->
112112- let clock = Eio.Stdenv.clock env in
113113- while true do
114114- Eio.Time.sleep clock 5.0;
115115- (*we need to lock this becasue we could end up updating while the ui is rendering*)
116116- Vars.render_mutex |> Eio.Mutex.lock;
117117- update_status ~cause_snapshot:true ();
118118- Vars.render_mutex |> Eio.Mutex.unlock
119119- done;
120120- `Stop_daemon);
121121- let$* running = Lwd.get ui_state.view in
122122- match running with
123123- | `Cmd_I cmd ->
124124- (*We have this extra step to paint the terminal empty for one step*)
125125- Lwd.set ui_state.view @@ `RunCmd cmd;
126126- full_term_sized_background
127127- | `RunCmd cmd ->
128128- Jj_widgets.interactive_process env ("jj" :: cmd)
129129- | `Main ->
130130- main_view ~sw
110110+ let is_jj_repo = is_jj_repo () in
111111+ if not is_jj_repo
112112+ then
113113+ W.string "Not in a jj repo."
114114+ |> Lwd.pure
115115+ |> Wd.border_box
116116+ |>$ Ui.resize
117117+ ~sw:1
118118+ ~sh:1
119119+ ~mw:10000
120120+ ~mh:10000
121121+ ~crop:Wd.neutral_grav
122122+ ~pad:Wd.neutral_grav
123123+ |> inputs
124124+ else (
125125+ update_status ~cause_snapshot:true ();
126126+ Eio.Fiber.fork_daemon ~sw (fun _ ->
127127+ let clock = Eio.Stdenv.clock env in
128128+ while true do
129129+ Eio.Time.sleep clock 5.0;
130130+ (*we need to lock this becasue we could end up updating while the ui is rendering*)
131131+ Vars.render_mutex |> Eio.Mutex.lock;
132132+ update_status ~cause_snapshot:true ();
133133+ Vars.render_mutex |> Eio.Mutex.unlock
134134+ done;
135135+ `Stop_daemon);
136136+ let$* running = Lwd.get ui_state.view in
137137+ match running with
138138+ | `Cmd_I cmd ->
139139+ (*We have this extra step to paint the terminal empty for one step*)
140140+ Lwd.set ui_state.view @@ `RunCmd cmd;
141141+ full_term_sized_background
142142+ | `RunCmd cmd ->
143143+ Jj_widgets.interactive_process env ("jj" :: cmd)
144144+ | `Main ->
145145+ main_view ~sw)
131146 ;;
132147end