"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: tog: key map to switch split mode
To:
Omar Polo <op@omarpolo.com>
Cc:
Mark Jamsek <mark@jamsek.com>, gameoftrees@openbsd.org
Date:
Thu, 07 Jul 2022 10:25:54 +0200

Download raw body.

Thread
Omar Polo <op@omarpolo.com> wrote:
> Mark Jamsek <mark@jamsek.com> wrote:
> > On 22-07-03 04:11pm, Omar Polo wrote:
> > > Mark Jamsek <mark@jamsek.com> wrote:
> > > > This introduces the 'S' global key map to switch the current splitscreen
> > > > mode.
> > > > 
> > > > If in a vsplit, it will switch to a hsplit.
> > > > If in a hsplit, it will switch to a vsplit IFF COLUMNS > 119 else the
> > > > view will remain unchanged (to honour existing vsplit behaviour).
> > > 
> > > it works fine for me, and I really like the idea.
> > > 
> > > ok op
> > > 
> > > two small nit inline, feel free to discard it however.
> > 
> > rebased and revised diff with op's suggestions
> 
> still ok for me :)

no wait, there's an error in view_get_split now.  the first time the
child view is opened in a split, but from the second onward is goes
fullscreen.

to reproduce: open tog, RET to see the child view in a split, q, RET
again and it's fullscreen.

> >  static void
> >  view_get_split(struct tog_view *view, int *y, int *x)
> >  {
> > -	char *mode;
> > -
> >  	*x = 0;
> >  	*y = 0;
> > 
> > -	mode = getenv("TOG_VIEW_SPLIT_MODE");
> > -
> > -	if (!mode || mode[0] != 'h') {
> > -		view->mode = TOG_VIEW_SPLIT_VERT;
> > +	if (view->mode == TOG_VIEW_SPLIT_VERT)
> >  		*x = view_split_begin_x(view->begin_x);
> > -	} else if (mode && mode[0] == 'h') {
> > -		view->mode = TOG_VIEW_SPLIT_HRZN;
> > +	else if (view->mode == TOG_VIEW_SPLIT_HRZN)
> >  		*y = view_split_begin_y(view->lines);
> > -	}

the issue is here.  The second time view->mode is TOG_VIEW_SPLIT_NONE so
none of the branches are taken and both x and y are set to zero.