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 status view controlled with enter and escape

+38 -21
+27 -18
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 inputs ui = 40 + 41 + let inputs ?(custom = fun _ -> `Unhandled) ui = 41 42 let$ input_state = Lwd.get ui_state.input 42 43 and$ ui = ui in 43 44 ui 44 45 |> Ui.keyboard_area @@ fun event -> 45 - match event with 46 - | `ASCII 'q', _ -> 47 - Vars.quit $= true; 48 - `Handled 49 - | `Escape, _ -> 50 - (* 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 *) 51 - (match input_state with 52 - | `Mode _ -> 53 - ui_state.show_popup $= None; 54 - ui_state.input $= `Normal; 46 + match custom event with 47 + | `Unhandled -> 48 + (match event with 49 + | `ASCII 'q', _ -> 50 + Vars.quit $= true; 55 51 `Handled 52 + | `Escape, _ -> 53 + (* 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 *) 54 + (match input_state with 55 + | `Mode _ -> 56 + ui_state.show_popup $= None; 57 + ui_state.input $= `Normal; 58 + `Handled 59 + | _ -> 60 + `Unhandled) 56 61 | _ -> 57 62 `Unhandled) 58 - | _ -> 59 - `Unhandled 63 + | a -> 64 + a 60 65 ;; 61 66 62 67 (* shows a pretty box in the middle of the screen with our error in it*) ··· 92 97 File_view.file_view file_focus 93 98 (* |>$ Ui.resize ~w:5 ~sw:1 ~mw:1000 *) 94 99 |> W.is_focused ~focus:file_focus (fun ui focused -> 95 - 96 100 ui 97 101 |> Ui.resize 98 102 ~w:5 99 103 ~sw:1 100 104 ~sh:12 101 105 ~h:2 102 - (*Lets our box get bigger when focused but not take up unecissarry spaec*) 103 - ~mh:(if focused then (Int.min (ui|>Ui.layout_max_height) 12) else 2) 106 + (*Lets our box get bigger when focused but not take up unecissarry spaec*) 107 + ~mh:(if focused then Int.min (ui |> Ui.layout_max_height) 12 else 2) 104 108 ~mw:1000) 105 109 |> W.Box.focusable ~focus:file_focus ~pad_h:0 ~pad_w:1 106 110 ; Graph_view.graph_view () ··· 124 128 |> W.Box.focusable ~focus:branch_focus ~pad_h:0 ~pad_w:1 125 129 ] 126 130 ; (*Right side summary/status/fileinfo view*) 127 - Show_view.render () 131 + Show_view.render summary_focus 128 132 |> W.Scroll.area 129 133 (* let mw=Int.max (Ui.layout_max_width ui) 100 in *) 130 134 |>$ Ui.resize ~w:0 ~sh:3 ~sw:1 ~mw:10000 ~mh:10000 ··· 136 140 |> W.Overlay.popup ~show_popup_var:ui_state.show_popup 137 141 |> W.Overlay.selection_list_prompt_filterable 138 142 ~show_prompt_var:ui_state.show_string_selection_prompt 139 - |> inputs 143 + |> inputs ~custom:(function 144 + | `Enter, [] -> 145 + Focus.request_reversable summary_focus; 146 + `Handled 147 + | _ -> 148 + `Unhandled) 140 149 ;; 141 150 142 151 (** Shows the op log *)
+11 -3
jj_tui/bin/show_view.ml
··· 10 10 let pushStatus status = Stream.push statusStream status 11 11 12 12 (** pushes the last message to the queue again to re-render everything *) 13 - let reRender ()= lastMessage |> Option.iter pushStatus 13 + let reRender () = lastMessage |> Option.iter pushStatus 14 14 15 15 module Make (Vars : Global_vars.Vars) = struct 16 16 open Lwd_infix ··· 67 67 done 68 68 ;; 69 69 70 - let render () = 70 + let render focus = 71 71 Flock.fork (fun () -> render_loop statusStream); 72 - Lwd.get viewState |>$ fun x -> x |> Ui.atom 72 + Lwd.get viewState |>$ fun x -> 73 + x 74 + |> Ui.atom 75 + |> Ui.keyboard_area (function 76 + | `Escape, [] -> 77 + Focus.release_reversable focus; 78 + `Handled 79 + | _ -> 80 + `Unhandled) 73 81 ;; 74 82 75 83 (*