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 scroll reset when content changes

+17 -8
+15 -6
forks/nottui/lib/nottui/widgets/scroll.ml
··· 15 15 let default_scroll_state = { position = 0; bound = 0 } 16 16 17 17 (** Primative for implementing scrolling, should be avoided unless you actually have reason to be changing the scroll state *) 18 - let vscroll_area_intern ~state ~change t = 18 + let vscroll_area_intern ?(reset_on_content_change = true) ~state ~change t = 19 19 let visible = ref (-1) in 20 20 let total = ref (-1) in 21 21 let scroll state delta = ··· 59 59 else false 60 60 in 61 61 if tchange || vchange 62 - then change `Content { state with bound = maxi 0 (!total - !visible) }) 62 + then 63 + change 64 + `Content 65 + { position = (if reset_on_content_change then 0 else state.position) 66 + ; bound = maxi 0 (!total - !visible) 67 + }) 63 68 |> Ui.mouse_area (scroll_handler state) 64 69 |> Ui.keyboard_area (focus_handler state) 65 70 (*restore original max height*) 66 71 |> Ui.resize ~mh:tmh) 67 72 ;; 68 73 69 - let scroll_area_intern ?focus ~state ~change t = 74 + let scroll_area_intern ?(reset_on_content_change = true) ?focus ~state ~change t = 70 75 let open Lwd_utils in 71 76 let w_visible = ref (-1) in 72 77 let w_total = ref (-1) in ··· 132 137 else false 133 138 in 134 139 if tchange || vchange 135 - then Some { state with bound = maxi 0 (!total - !visible) } 140 + then 141 + Some 142 + { bound = maxi 0 (!total - !visible) 143 + ; position = (if reset_on_content_change then 0 else state_w.position) 144 + } 136 145 else None 137 146 in 138 147 let w_update = sense tw w state_w w_total w_visible in ··· 151 160 152 161 open Internal 153 162 154 - let v_area ui = 163 + let v_area ?(reset_on_content_change = true) ui = 155 164 let state = Lwd.var Internal.default_scroll_state in 156 165 ui 157 166 |> Internal.vscroll_area_intern ~change:(fun _ x -> state $= x) ~state:(Lwd.get state) 158 167 ;; 159 168 160 - let area ?focus ui = 169 + let area ?(reset_on_content_change = true) ?focus ui = 161 170 let state = Lwd.var (Internal.default_scroll_state, Internal.default_scroll_state) in 162 171 ui 163 172 |> Internal.scroll_area_intern
+2 -2
forks/nottui/lib/nottui/widgets/scroll.mli
··· 1 1 (** A keyboard scroll area that only scrolls in the vertical direction *) 2 - val v_area : Nottui_main.ui Lwd.t -> Nottui_main.ui Lwd.t 2 + val v_area : ?reset_on_content_change:bool -> Nottui_main.ui Lwd.t -> Nottui_main.ui Lwd.t 3 3 4 4 (** A scroll area that allows keyboard scrolling in both x and y directions*) 5 - val area : ?focus:Nottui_main.Focus.status -> Nottui_main.ui Lwd.t -> Nottui_main.ui Lwd.t 5 + val area : ?reset_on_content_change:bool -> ?focus:Nottui_main.Focus.status -> Nottui_main.ui Lwd.t -> Nottui_main.ui Lwd.t 6 6 7 7 (** A scroll area that allows keyboard scrolling in both x and y directions and has no limits. 8 8 This might be useful if you have some very dynamic content and the usual scroll area doesn't know how big things are*)