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.

make overlay have 1 level of nsted focus to prevent escaping

+46 -44
+26 -20
forks/nottui/lib/nottui/widgets/overlays.ml
··· 81 81 } 82 82 83 83 let text_prompt 84 - ?pad_h 85 - ?pad_w 86 - ?(modify_body = fun x -> x) 87 - ?(focus = Focus.make ()) 88 - ?(char_count = false) 89 - ~(show_prompt_var : text_prompt_data Option.t Lwd.var) 90 - ui 84 + ?pad_h 85 + ?pad_w 86 + ?(modify_body = fun x -> x) 87 + ?(focus = Focus.make ()) 88 + ?(char_count = false) 89 + ~(show_prompt_var : text_prompt_data Option.t Lwd.var) 90 + ui 91 91 = 92 92 let prompt_input = Lwd.var ("", 0) in 93 93 let prompt_val = Lwd.get prompt_input in ··· 135 135 (* TODO: Write a ui resize function that takes an optional version of the layout spec where eveyr field is optional too, then we can use that when we want to make a widget with a custom internal state, or i can just use w mw h mw etc *) 136 136 137 137 let selection_list_prompt 138 - ?pad_w 139 - ?pad_h 140 - ?(modify_body = fun x -> x) 141 - ?(focus = Focus.make ()) 142 - ~show_prompt_var 143 - ui 138 + ?pad_w 139 + ?pad_h 140 + ?(modify_body = fun x -> x) 141 + ?(focus = Focus.make ()) 142 + ~show_prompt_var 143 + ui 144 144 = 145 145 (*Build the ui so that it is either the prompt or nothing depending on whether show prompt is enabled*) 146 146 let prompt_args = ··· 183 183 } 184 184 185 185 let selection_list_prompt_filterable 186 - ?pad_w 187 - ?pad_h 188 - ?(modify_body = fun x -> x) 189 - ?(focus = Focus.make ()) 190 - ~show_prompt_var 191 - ui 186 + ?pad_w 187 + ?pad_h 188 + ?(modify_body = fun x -> x) 189 + ?(focus = Focus.make ()) 190 + ~show_prompt_var 191 + ui 192 192 = 193 193 (*Build the ui so that it is either the prompt or nothing depending on whether show prompt is enabled*) 194 194 let prompt_args = ··· 229 229 Focus.request_reversable focus; 230 230 prompt_field |> Ui.resize ~w:5 ~sw:1 231 231 in 232 - ui |> BB.focusable ~focus ~label_top:label ?on_key |> clear_bg 232 + ui 233 + |> BB.focusable ~focus ~label_top:label ?on_key 234 + |> clear_bg 235 + (*This is a little confusing, but by wrapping the content in 2 nested keyboard areas we make it the user cannot escape the popup. 236 + becasue focus moves between keyboard areas within a current keyboard area by adding 2 we make escape impossible *) 237 + |> Lwd.map ~f:(fun ui -> 238 + ui |> Ui.keyboard_area (fun x -> `Unhandled)) 233 239 | None -> 234 240 Focus.release_reversable focus; 235 241 Ui.empty |> Lwd.pure
+1 -1
jj_tui/bin/jj_commands.ml
··· 269 269 if is_sub && input == Lwd.peek ui_state.input then ui_state.input $= `Normal; 270 270 `Handled 271 271 | Jj_process.JJError (cmd, error) -> 272 - handle_jj_error cmd error; 272 + handle_jj_error ~cmd ~error; 273 273 `Unhandled 274 274 275 275
+19 -23
jj_tui/bin/jj_ui.ml
··· 57 57 | `ASCII 'q', _ -> 58 58 Vars.quit $= true; 59 59 `Handled 60 - |`Arrow _,[`Meta]-> 61 - (*totatlly disable all forced focus navigation*) 62 - `Handled 60 + (* | `Arrow _, [ `Ctrl ] *) 61 + (* | `Arrow _, [ `Meta ] *) 62 + (* | `Tab, [ `Meta ] *) 63 + (* | `Tab, [ `Meta; `Shift ] -> *) 64 + (* `Handled *) 63 65 | _ -> 64 66 `Unhandled) 65 67 ; (fun event -> 66 - match Lwd.peek ui_state.input, Lwd.peek ui_state.show_prompt, Lwd.peek ui_state.show_popup with 67 - | `Mode _, _,_ -> 68 + match 69 + ( Lwd.peek ui_state.input 70 + , Lwd.peek ui_state.show_prompt 71 + , Lwd.peek ui_state.show_popup ) 72 + with 73 + | `Mode _, _, _ -> 68 74 (match event with 69 75 | `Escape, [] -> 70 76 ui_state.show_popup $= None; ··· 72 78 `Handled 73 79 | _ -> 74 80 `Unhandled) 75 - | `Normal, None,None -> (* only control focus when no popup and no input mode is active*) 81 + | `Normal, None, None -> 82 + (* only control focus when no popup and no input mode is active*) 76 83 (match event with 77 84 | `Arrow `Left, _ -> 78 85 `Remap (`Focus `Up, []) ··· 134 141 ; W.Scroll.v_area (ui_state.jj_branches $-> Ui.atom) 135 142 |> W.is_focused ~focus:branch_focus (fun ui focused -> 136 143 ui 137 - |> Ui.keyboard_area (function 138 - | k -> 139 - Jj_commands.handleInputs Jj_commands.default_list k 140 - | _ -> 141 - `Unhandled) 144 + |> Ui.keyboard_area (fun k -> 145 + Jj_commands.handleInputs Jj_commands.default_list k) 142 146 |> Ui.resize 143 147 ~w:5 144 148 ~sw:1 ··· 161 165 |> W.Overlay.popup ~show_popup_var:ui_state.show_popup 162 166 |> W.Overlay.selection_list_prompt_filterable 163 167 ~show_prompt_var:ui_state.show_string_selection_prompt 164 - |> inputs ~custom:(function 165 - | k -> 166 - Jj_commands.handleInputs Jj_commands.default_list k 167 - | `Arrow _, [ `Ctrl ] 168 - | `Arrow _, [ `Meta ] 169 - | `Tab, [ `Meta ] 170 - | `Tab, [ `Meta; `Shift ] -> 171 - (* block all normal focus keys *) 172 - `Handled 173 - | _ -> 174 - `Unhandled) 168 + |> inputs ~custom:(fun x -> Jj_commands.handleInputs Jj_commands.default_list x) 175 169 ;; 170 + 171 + (* block all normal focus keys *) 176 172 177 173 (** Shows the op log *) 178 174 let log_view () = ··· 188 184 189 185 let mainUi () = 190 186 (* first lets load the config*) 191 - Vars.config $= Config.load_config(); 187 + Vars.config $= Config.load_config (); 192 188 [%log info "loaded config"]; 193 189 (*we want to initialize our states and keep them up to date*) 194 190 let$* startup_result = check_startup () in