Download raw body.
tog: key map to switch split mode
On 22-07-08 10:32am, Stefan Sperling wrote: > On Thu, Jul 07, 2022 at 04:03:23PM +0200, Omar Polo wrote: > > Mark Jamsek <mark@jamsek.com> wrote: > > > Thanks, op! This fixes the problem for me. > > > > Yep, this works perfectly! ok for me. Thanks! > > Why switch on hsplits only while we are already in vpslit mode? > Wouldn't it make more sense to apply 'S' regardless of the currently > visible split configuration? I would expect it to behave like this: > > $ env | grep TOG > TOG_COLORS=1 > $ tog > press S > press Enter > diff view opens in hsplit in 80x24 terminal > > Such that 'S' always toggles between vsplit and hsplit, and hsplit is > always applied regardless of terminal size, and vsplit is only applied > under consideration of terminal size. > > Does this suggested behaviour cause a problem I am not seeing? I think this makes more sense and am not sure why I didn't think of this to begin with :) The below diff seems to implement the behaviour you suggest. diff /home/mark/src/git/got-current commit - 3c1dfe12b3f3eae6dc7ef4762772e849794296c5 path + /home/mark/src/git/got-current blob - 39cc96c4b079ff1b9f5daafb5f0894e26c52df11 file + tog/tog.1 --- tog/tog.1 +++ tog/tog.1 @@ -81,11 +81,12 @@ Toggle fullscreen mode for a split-screen view. will automatically use split-screen views if the size of the terminal window is sufficiently large. .It Cm S +Switch the current split mode. When in a split-screen view, .Nm -will switch to the alternate split mode. -If the current view is in a horizontal split and the terminal window is not -wide enough, the view will remain unchanged. +will also render the view in the new split mode. +If the current mode and/or view is a horizontal split and the terminal window +is not wide enough, the split mode and view will remain unchanged. .It Cm - When in a split-screen view, decrease the size of the focussed split N increments (default: 1). blob - 310eb39a0776dd5fb11adc30d6c50fba6d7de13b file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -1115,8 +1115,9 @@ view_search_start(struct tog_view *view) } /* - * If view is a parent or child view and is currently in a splitscreen, switch - * to the alternate split. If in a hsplit and LINES < 120, don't vsplit. + * Switch the current split mode. If view is a parent or child view and is + * currently in a splitscreen, switch to the new split. If in a hsplit and + * LINES < 120, don't switch mode and don't vsplit. */ static const struct got_error * switch_split(struct tog_view *view) @@ -1129,17 +1130,17 @@ switch_split(struct tog_view *view) else v = view; - if (!v->child || !view_is_splitscreen(v->child)) - return NULL; if (v->mode == TOG_VIEW_SPLIT_HRZN && v->cols < 120) return NULL; - if (!v->mode || v->mode == TOG_VIEW_SPLIT_HRZN) { - v->child->nscrolled = LINES - v->child->nlines; + if (!v->mode || v->mode == TOG_VIEW_SPLIT_HRZN) v->mode = TOG_VIEW_SPLIT_VERT; - } else if (v->mode == TOG_VIEW_SPLIT_VERT) + else if (v->mode == TOG_VIEW_SPLIT_VERT) v->mode = TOG_VIEW_SPLIT_HRZN; + if (!v->child) + return NULL; + view_get_split(v, &v->child->begin_y, &v->child->begin_x); if (v->mode == TOG_VIEW_SPLIT_HRZN && v->child->resized_y) v->child->begin_y = v->child->resized_y; @@ -1149,6 +1150,7 @@ switch_split(struct tog_view *view) if (v->mode == TOG_VIEW_SPLIT_HRZN) { v->ncols = COLS; v->child->ncols = COLS; + v->child->nscrolled = LINES - v->child->nlines; err = view_init_hsplit(v, v->child->begin_y); if (err) -- Mark Jamsek <fnc.bsdbox.org> GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
tog: key map to switch split mode