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 popup double focusing

+49 -26
+15 -5
forks/nottui/lib/nottui/nottui_main.ml
··· 61 61 let clock = ref 0 62 62 let currently_focused : var ref = ref (make () |> fst) 63 63 let focus_stack : var list ref = ref [] 64 + let focus_stack_to_str ()= 65 + (!focus_stack|>List.map Lwd.peek|>List.map (string_of_int)|>String.concat ","|>Printf.sprintf "[%s]") 66 + 67 + let focusLock= Mutex.create() 64 68 65 69 let request_var (v : var) = 66 70 incr clock; ··· 68 72 currently_focused := v 69 73 ;; 70 74 71 - let request ((v, _) : handle) = request_var v 75 + let request ((v, _) : handle) = 76 + Mutex.protect focusLock @@ fun _-> 77 + request_var v 72 78 73 79 let release ((v, _) : handle) = 80 + Mutex.protect focusLock @@ fun _-> 74 81 incr clock; 75 82 Lwd.set v 0 76 83 ;; 77 84 78 85 let var_equal a b = Lwd.peek a = Lwd.peek b 86 + 79 87 80 88 let request_reversable ((v, _) : handle) = 81 - Log.debug (fun m -> m "Maybe requesting revesable focus %d" (Lwd.peek v)); 89 + Mutex.protect focusLock @@ fun _-> 90 + Log.debug (fun m -> m "Maybe requesting reversable focus %d" (Lwd.peek v)); 82 91 if not @@ var_equal !currently_focused v 83 92 then ( 84 93 focus_stack := !currently_focused :: !focus_stack; 85 94 request_var v; 86 - Log.debug (fun m -> m "Requested reversable focus %d" (Lwd.peek v))) 95 + Log.debug (fun m -> m "Requested reversable focus %d. stack:%s" (Lwd.peek v) (focus_stack_to_str ()))) 87 96 ;; 88 97 89 98 let release_reversable ((v, _) : handle) = 99 + (* Mutex.protect focusLock @@ fun _-> *) 90 100 Log.debug (fun m -> 91 - m "Maybe release or remove %d from reversable focus stack" (Lwd.peek v)); 101 + m "Maybe release or remove %d from reversable focus stack. stack: %s" (Lwd.peek v) (focus_stack_to_str ())); 92 102 (* we should only release if we actually have the focus*) 93 103 if var_equal !currently_focused v 94 104 then ( ··· 97 107 | hd :: tl -> 98 108 request_var hd; 99 109 Log.debug (fun m -> 100 - m "Released reversable focus %d in echange form %d" (Lwd.peek v) (Lwd.peek v)); 110 + m "Released reversable focus %d in exchange for: %d" (Lwd.peek v) (Lwd.peek hd)); 101 111 focus_stack := tl 102 112 | _ -> ()) 103 113 else (
+2 -1
forks/nottui/lib/nottui/widgets/overlays.ml
··· 3 3 open Nottui_main 4 4 open Shared 5 5 open Lwd_infix 6 + module Log = (val Logs.src_log (Logs.Src.create "nottui_widgets")) 6 7 7 8 open struct 8 9 module BB = Border_box ··· 225 226 match show_popup with 226 227 | Some (content, label) -> 227 228 let ui = 228 - let$ prompt_field = content in 229 229 Focus.request_reversable focus; 230 + let$ prompt_field = content in 230 231 prompt_field |> Ui.resize ~w:5 ~sw:1 231 232 in 232 233 ui
+5
jj_tui/bin/global_vars.ml
··· 68 68 val get_active_revs : unit -> string list 69 69 val get_active_revs_lwd : unit -> string list Lwd.t 70 70 val config : Config.t Lwd.var 71 + val show_popup: ((ui Lwd.t * string) option ) ->unit 71 72 end 72 73 73 74 module Vars : Vars = struct ··· 101 102 let term = ref None 102 103 let term_width_height : (int * int) Lwd.var = Lwd.var (0, 0) 103 104 let get_term () = Option.get !term 105 + 104 106 105 107 let reset_selection () = 106 108 Flock.fork(fun _ -> ··· 144 146 else selected |> List.map get_unique_id 145 147 ;; 146 148 149 + let show_popup popup= 150 + [%log debug "setting show popup"]; 151 + Lwd.set ui_state.show_popup popup 147 152 let config = ui_state.config 148 153 end
+4 -4
jj_tui/bin/graph_commands.ml
··· 41 41 (fun () -> 42 42 Fun 43 43 (fun _ -> 44 - ui_state.show_popup 45 - $= Some (commands_list_ui ~include_arrows:true (get_commands ()), "Help"); 44 + show_popup 45 + @@ Some (commands_list_ui ~include_arrows:true (get_commands ()), "Help"); 46 46 ui_state.input $= `Mode (fun _ -> `Unhandled))) 47 47 } 48 48 ; { ··· 288 288 Fun 289 289 (fun _ -> 290 290 ui_state.input $= `Normal; 291 - ui_state.show_popup $= None) 291 + show_popup None) 292 292 } 293 293 ] 294 294 |> List.map (fun x -> x.key, x) ··· 304 304 |> Lwd.pure 305 305 in 306 306 let ui = W.vbox [ log; commands_list_ui subcmds ] in 307 - ui_state.show_popup $= Some (ui, "Git push will:"); 307 + show_popup @@ Some (ui, "Git push will:"); 308 308 ui_state.input $= `Mode (command_input ~is_sub:true subcmds))) 309 309 } 310 310 ; {
+18 -15
jj_tui/bin/jj_commands.ml
··· 6 6 open Jj_tui.Key_map 7 7 open Jj_tui.Key 8 8 open Jj_tui 9 + open Log 9 10 10 11 (** Internal to this module. I'm trying this out as a way to avoid .mli files*) 11 12 module Shared = struct ··· 72 73 open Jj_process.Make (Vars) 73 74 open Notty 74 75 open Nottui 76 + open Log 75 77 open! Jj_tui.Util 76 78 77 79 exception Handled ··· 149 151 |> W.Scroll.area 150 152 ;; 151 153 152 - let rec handleCommand description cmd = 153 - [%log info "Handling command: %s" description]; 154 + let rec handleCommand description (cmd:string command_variant) = 155 + [%log 156 + info "Handling command. description: %s" description]; 154 157 let noOut args = 155 158 let _ = args in 156 159 let _result = jj args in ··· 202 205 let send_cmd args = change_view (`Cmd_I args) in 203 206 match cmd with 204 207 | Cmd_I args -> 205 - ui_state.show_popup $= None; 208 + show_popup None; 206 209 send_cmd args; 207 210 raise Handled 208 211 | Cmd args -> 209 - ui_state.show_popup $= None; 212 + show_popup None; 210 213 noOut args; 211 214 raise Handled 212 215 | Cmd_r args -> 213 - ui_state.show_popup $= None; 216 + show_popup None; 214 217 noOut (args @ [ "-r"; Vars.get_hovered_rev () ]); 215 218 raise Handled 216 219 | Cmd_with_revs rev_type -> 217 220 let args, revs = get_revs rev_type in 218 - ui_state.show_popup $= None; 221 + show_popup None; 219 222 noOut (args @ ("-r" :: revs)); 220 223 reset_selection_post_cmd rev_type; 221 224 raise Handled 222 225 | Prompt (str, args) -> 223 - ui_state.show_popup $= None; 226 + show_popup None; 224 227 prompt str (`Cmd args); 225 228 raise Handled 226 229 | Prompt_r (str, args) -> 227 - ui_state.show_popup $= None; 230 + show_popup None; 228 231 prompt str (`Cmd (args @ [ "-r"; Vars.get_hovered_rev () ])); 229 232 raise Handled 230 233 | PromptThen (label, next) -> 231 - ui_state.show_popup $= None; 234 + show_popup None; 232 235 (*We run a prompt that then runs our next command when finished*) 233 236 prompt label @@ `Fun (fun x -> next x |> command_no_input description); 234 237 raise Handled 235 238 | Prompt_I (str, args) -> 236 - ui_state.show_popup $= None; 239 + show_popup None; 237 240 prompt str (`Cmd_I args); 238 241 raise Handled 239 242 | Selection_prompt (str, items, predicate, cmd) -> 240 - ui_state.show_popup $= None; 243 + show_popup None; 241 244 ui_state.show_prompt $= None; 242 245 prompt_selection str items predicate cmd; 243 246 raise Handled 244 247 | Fun func -> 245 - ui_state.show_popup $= None; 248 + show_popup None; 246 249 func (); 247 250 Global_funcs.update_status (); 248 251 raise Handled 249 252 | SubCmd sub_map -> 250 - ui_state.show_popup $= Some (commands_list_ui sub_map, description); 253 + show_popup @@ Some (commands_list_ui sub_map, description); 251 254 ui_state.input $= `Mode (command_input ~is_sub:true sub_map); 252 255 raise Handled 253 256 | Dynamic f -> ··· 314 317 ; cmd = 315 318 Fun 316 319 (fun _ -> 317 - ui_state.show_popup 318 - $= Some 320 + show_popup@@ 321 + Some 319 322 (commands_list_ui ~include_arrows:true (make_default_list ()), "Help"); 320 323 ui_state.input $= `Mode (fun _ -> `Unhandled)) 321 324 }
+1 -1
jj_tui/bin/jj_ui.ml
··· 74 74 | `Mode _, _, _ -> 75 75 (match event with 76 76 | `Escape, [] -> 77 - ui_state.show_popup $= None; 77 + show_popup None; 78 78 ui_state.input $= `Normal; 79 79 `Handled 80 80 | _ ->
+4
todo.md
··· 43 43 44 44 # Small screen mode: 45 45 mode that only shows the graph or diff for small screens 46 + 47 + 48 + ## Fix focus issues. 49 + I need to use the new variant of Lwd.peek so that we are fetching the latest value when doing the focus switching. mostly the focus comparison is key