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.

ensure leaving a prompt/popup with focus nvigation is impossible

+47 -30
+1 -1
jj_tui/bin/jj_commands.ml
··· 127 127 let move_command = 128 128 render_command_line 129 129 ~indent_level:0 130 - ("Alt+Arrows" |> String.to_seq |> Seq.map Uchar.of_char |> Array.of_seq) 130 + ("Arrows" |> String.to_seq |> Seq.map Uchar.of_char |> Array.of_seq) 131 131 "navigation between windows" 132 132 in 133 133 ((commands |> render_commands) @ if include_arrows then [ move_command ] else [])
+46 -29
jj_tui/bin/jj_ui.ml
··· 37 37 W.button (Printf.sprintf "quit ") (fun () -> Vars.quit $= true) |> Lwd.pure 38 38 ;; 39 39 40 + let rec forward_events handlers event = 41 + match handlers with 42 + | h :: rest -> 43 + (match h event with `Unhandled -> forward_events rest event | other -> other) 44 + | [] -> 45 + `Unhandled 46 + ;; 47 + 40 48 let inputs ?(custom = fun _ -> `Unhandled) ui = 41 - let$ input_state = Lwd.get ui_state.input 42 - and$ ui = ui in 43 49 ui 44 - |> Ui.keyboard_area @@ fun event -> 45 - match custom event with 46 - | `Unhandled -> 47 - (match event with 48 - | `Arrow `Left, _ -> 49 - `Remap (`Focus `Up, []) 50 - | `Arrow `Right, _ -> 51 - `Remap (`Focus `Down, []) 52 - | `ASCII 'q', _ -> 53 - Vars.quit $= true; 54 - `Handled 55 - | `Escape, _ -> 56 - (* TODO: I could refactor this and the rest of the mode handling so that when the popup is up and in focus it handles all key inputs *) 57 - (match input_state with 58 - | `Mode _ -> 59 - ui_state.show_popup $= None; 60 - ui_state.input $= `Normal; 61 - `Handled 62 - | _ -> 63 - `Unhandled) 64 - | _ -> 65 - `Unhandled) 66 - | a -> 67 - a 50 + |>$ Ui.keyboard_area @@ fun event -> 51 + event 52 + |> forward_events 53 + [ 54 + custom 55 + ; (function 56 + | `ASCII 'q', _ -> 57 + Vars.quit $= true; 58 + `Handled 59 + | _ -> 60 + `Unhandled) 61 + ; (fun event -> 62 + match Lwd.peek ui_state.input, Lwd.peek ui_state.show_prompt, Lwd.peek ui_state.show_popup with 63 + | `Mode _, _,_ -> 64 + (match event with 65 + | `Escape, [] -> 66 + ui_state.show_popup $= None; 67 + ui_state.input $= `Normal; 68 + `Handled 69 + | _ -> 70 + `Unhandled) 71 + | `Normal, None,None -> (* only control focus when no popup and no input mode is active*) 72 + (match event with 73 + | `Arrow `Left, _ -> 74 + `Remap (`Focus `Up, []) 75 + | `Arrow `Right, _ -> 76 + `Remap (`Focus `Down, []) 77 + | _ -> 78 + `Unhandled) 79 + | _ -> 80 + `Unhandled) 81 + ] 68 82 ;; 69 83 70 84 (* shows a pretty box in the middle of the screen with our error in it*) ··· 97 111 (*left side window stack*) 98 112 W.vbox 99 113 [ 100 - File_view.file_view ~focus:file_focus summary_focus 114 + File_view.file_view ~focus:file_focus summary_focus 101 115 (* |>$ Ui.resize ~w:5 ~sw:1 ~mw:1000 *) 102 116 |> W.is_focused ~focus:file_focus (fun ui focused -> 103 117 ui ··· 110 124 ~mh:(if focused then Int.min (ui |> Ui.layout_max_height) 12 else 2) 111 125 ~mw:1000) 112 126 |> W.Box.focusable ~focus:file_focus ~pad_h:0 ~pad_w:1 113 - ; Graph_view.graph_view ~focus:graph_focus summary_focus () 127 + ; Graph_view.graph_view ~focus:graph_focus summary_focus () 114 128 |>$ Ui.resize ~sh:3 ~w:5 ~sw:1 ~mw:1000 ~h:10 ~mh:1000 115 129 |> W.Box.focusable ~focus:graph_focus ~pad_h:0 ~pad_w:1 116 130 ; W.Scroll.v_area (ui_state.jj_branches $-> Ui.atom) ··· 146 160 |> inputs ~custom:(function 147 161 | `ASCII k, [] -> 148 162 Jj_commands.handleInputs Jj_commands.default_list k 149 - |`Arrow _,[`Meta]| `Tab, [`Meta]|`Tab, [`Meta;`Shift]-> 163 + | `Arrow _, [ `Ctrl ] 164 + | `Arrow _, [ `Meta ] 165 + | `Tab, [ `Meta ] 166 + | `Tab, [ `Meta; `Shift ] -> 150 167 (* block all normal focus keys *) 151 168 `Handled 152 169 | _ ->