Download raw body.
tog: vsplit view restored after resize of fullscreen mode
On 23-04-21 07:45PM, Mikhail wrote: > On Fri, Apr 21, 2023 at 09:31:36PM +1000, Mark Jamsek wrote: > > On 23-04-21 11:00AM, Stefan Sperling wrote: > > > On Fri, Apr 21, 2023 at 01:26:14PM +1000, Mark Jamsek wrote: > > > > On 23-04-20 09:01PM, Mikhail wrote: > > > > > Make xterm big enough to be able to show vertical split and do the > > > > > following in a repo: > > > > > > > > > > <enter> (show any commit in vsplit) > > > > > F > > > > > <resize xterm> > > > > > > > > > > vsplit view is restored. > > > > > > > > > > Is it expected? > > > > > > > > It's arguably surprising behaviour but, yes, this is how tog has always > > > > behaved--at least as far back as 0.60--so is expected in that sense. > > > > > > > > I'm not sure if it should be changed as this sort of comports with the > > > > docs (emphasis added): > > > > > > > > F Toggle fullscreen mode for a split-screen view. **tog will > > > > automatically use vertical split-screen views if the size of the > > > > terminal window is sufficiently large.** > > > > > > > > And this is convenient sometimes. For example, when tog is started in > > > > a small 80x24 term which is then increased and if viewing a diff, it > > > > auto-splits with the log view. This is handy imo. > > > > > > > > That said, we could keep that aspect, but when the user explicitly > > > > requests fullscreen mode with F, not split when resized. > > > > > > I would be fine with F overriding this. Pressing F again would then > > > return to automatic mode, either fullscreen or split view depending > > > on the current terminal size. Would that work? > > > The docs could be of course be updated to say something more specific > > > like "Force fullscreen mode. By default, tog will automatically use > > > split-screen views if ..." > > > > Yes, this should be quite straight forward; just record when F is > > toggled and only redraw fullscreen when we get a SIGWINCH. Please let me > > know if the below diff produces the behaviour you describe and if so > > I'll continue with it and update the docs too. > > I tested the patch and found a regression: > > start tog 219x80 (all sizes are approximation of course) > <enter> > F > q > resize tog 127x39 > screen becomes mangled (https://people.freebsd.org/~misha/got1.png) Thanks, I see this too! We need to unset the new force_fullscreen flag when closing a child view. Please let me know if the following diff produces the desired behaviour without the breakage: diffstat /home/mark/src/got M tog/tog.c | 43+ 12- 1 file changed, 43 insertions(+), 12 deletions(-) diff /home/mark/src/got commit - 3aa652eff930e9f4d878f8d4a7d01ffd3e95e096 path + /home/mark/src/got blob - c1264e0741802f1cb6105a4bc666bda6ea965ebb file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -656,6 +656,7 @@ struct tog_view { int gline, hiline; /* navigate to and highlight this nG line */ int ch, count; /* current keymap and count prefix */ int resized; /* set when in a resize event */ + int force_fullscreen; /* set when 'F'ullscreen is toggled */ int focussed; /* Only set on one parent or child view at a time. */ int dying; struct tog_view *parent; @@ -1739,13 +1740,24 @@ view_input(struct tog_view **new, int *done, struct to tog_sigwinch_received = 0; tog_sigcont_received = 0; TAILQ_FOREACH(v, views, entry) { - err = view_resize(v); - if (err) - return err; + if (!v->force_fullscreen) { + err = view_resize(v); + if (err) + return err; + } err = v->input(new, v, KEY_RESIZE); if (err) return err; - if (v->child) { + if (v->child && v->child->force_fullscreen) { + err = view_fullscreen(v->child); + if (err) + return err; + if (v->force_fullscreen) { + err = view_fullscreen(v); + if (err) + return err; + } + } else if (v->child) { err = view_resize(v->child); if (err) return err; @@ -1753,7 +1765,8 @@ view_input(struct tog_view **new, int *done, struct to KEY_RESIZE); if (err) return err; - if (v->child->resized_x || v->child->resized_y) { + if (v->child->resized_x || + v->child->resized_y) { err = view_resize_split(v, 0); if (err) return err; @@ -1796,15 +1809,21 @@ view_input(struct tog_view **new, int *done, struct to } break; case 'q': - if (view->parent && view->mode == TOG_VIEW_SPLIT_HRZN) { - if (view->parent->resize) { - /* might need more commits to fill fullscreen */ - err = view->parent->resize(view->parent, 0); - if (err) - break; + if (view->parent) { + view->parent->force_fullscreen = 0; + if (view->mode == TOG_VIEW_SPLIT_HRZN) { + /* might need commits to fill the screen */ + if (view->parent->resize) { + err = view->parent->resize(view->parent, + 0); + if (err) + break; + } + offset_selection_up(view->parent); } - offset_selection_up(view->parent); } + if (view->child) + view->child->force_fullscreen = 0; err = view->input(new, view, ch); view->dying = 1; break; @@ -1819,8 +1838,12 @@ view_input(struct tog_view **new, int *done, struct to if (view_is_splitscreen(view->child)) { view->focussed = 0; view->child->focussed = 1; + view->force_fullscreen = 1; + view->child->force_fullscreen = 1; err = view_fullscreen(view->child); } else { + view->force_fullscreen = 0; + view->child->force_fullscreen = 0; err = view_splitscreen(view->child); if (!err) err = view_resize_split(view, 0); @@ -1829,12 +1852,18 @@ view_input(struct tog_view **new, int *done, struct to break; err = view->child->input(new, view->child, KEY_RESIZE); + if (view->force_fullscreen) + view->child->action = "force fullscreen mode"; } else { if (view_is_splitscreen(view)) { view->parent->focussed = 0; view->focussed = 1; + view->force_fullscreen = 1; + view->parent->force_fullscreen = 1; err = view_fullscreen(view); } else { + view->force_fullscreen = 0; + view->parent->force_fullscreen = 0; err = view_splitscreen(view); if (!err && view->mode != TOG_VIEW_SPLIT_HRZN) err = view_resize(view->parent); @@ -1844,6 +1873,8 @@ view_input(struct tog_view **new, int *done, struct to if (err) break; err = view->input(new, view, KEY_RESIZE); + if (view->force_fullscreen) + view->action = "force fullscreen mode"; } if (err) break; -- Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org> GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
tog: vsplit view restored after resize of fullscreen mode