It seems less useful to me to be able to say "add 50% of the size of the pane/window to the size of this cell" than to say "make this cell cover 50% of the window". But I don't really mind that much if you think it is better.
Oh the top cell will be the size of the WINDOW not the pane, sorry. So it will be w->layout_root or w->sx and w->sy, not wp->layout_cell. On Tue, Oct 08, 2019 at 05:34:27AM -0700, Anindya Mukherjee wrote: > I was thinking that "-p percent" would be a way to enter an adjustment for > the "resize by" commands like LRUD. So it would "resize by". > In my 2x2 grid example when I look at the top level cell (found by walking > up) its size is 244x65 (for the current terminal size), while the size of > both the target wp and its layout cell is 122x32. Is there a quick way to > get to the top level given the target pane? > Alternatively we can resize by a percentage of the target pane's size like > I was doing initially which is also intuitive. > Best, > Anindya > On Tue, Oct 8, 2019 at 1:53 AM Nicholas Marriott > <[email protected]> wrote: > > OK this looks good but there are two things: > > - if you are using the whole size you should be able to use wp->sx and > A sy for the size rather than walking up to it (or you can get the root > A cell directly from wp->layout_cell). > > - this resizes BY a % of the total size which seems a bit odd - I was > A thinking it would resize TO a % of the total size? > > On Tue, Oct 08, 2019 at 12:34:13AM -0700, Anindya Mukherjee wrote: > >A A Great, thanks! > >A A I updated the code to use the root layout cell as that seems > intuitive to > >A A me, and also tried to fix some of the formatting issues. > >A A Best, > >A A Anindya > > > >A A On Tue, Oct 8, 2019 at 12:05 AM Nicholas Marriott > >A A <[email protected]> wrote: > > > >A A A Looks good aside from a few style nits I can fix before commit > (use tabs > >A A A not spaces, all the u_int variable declarations go in the same > >A A A statement, line length needs to be <= 80 columns, new line for > each new > >A A A sentence in tmux.1, "lines or columns" not "lines or cells" in > tmux.1). > > > >A A A I don't have strong feelings whether -p means % of parent cell > or total > >A A A size, it's up to you which you prefer. I'd add a line to the > manual > >A A A explaining what it means in either case. > > > >A A A Thanks! > > > >A A A On Mon, Oct 07, 2019 at 11:44:46PM -0700, Anindya Mukherjee > wrote: > >A A A >AA AA Fixed a mistake in the last upload. Sorry for the > noise. > >A A A >AA AA Although currently I am using the parent layout cell > of the > >A A A target window > >A A A >AA AA pane's cell to calculate the available space, I > wonder if it > >A A A would be > >A A A >AA AA better to use the root layout cell, which is > basically the entire > >A A A >AA AA terminal. An example is a 2x2 grid with 4 panes. Here > if I just > >A A A use the > >A A A >AA AA parent cell, it only covers half of the available > space and the > >A A A results > >A A A >AA AA are a little less intuitive compared to using the top > level cell. > >A A A >AA AA Best, > >A A A >AA AA Anindya > >A A A > > >A A A >AA AA On Mon, Oct 7, 2019 at 10:42 PM Anindya Mukherjee > >A A A <[email protected]> > >A A A >AA AA wrote: > >A A A > > >A A A >AA AA AA Some further adjustments. I realised that > checking the > >A A A percentage is not > >A A A >AA AA AA necessary because downstream code handles large > values > >A A A correctly. Also, > >A A A >AA AA AA the layout type of the parent layout_cell is > always > >A A A LAYOUT_WINDOWPANE so > >A A A >AA AA AA I check the args instead while calculating the > adjustment > >A A A (which is also > >A A A >AA AA AA what's done in split-window). > >A A A >AA AA AA Best, > >A A A >AA AA AA Anindya > >A A A > > >A A A >AA AA AA On Mon, Oct 7, 2019 at 9:17 PM Anindya Mukherjee > >A A A <[email protected]> > >A A A >AA AA AA wrote: > >A A A > > >A A A >AA AA AA AA Hi Nicholas, > >A A A >AA AA AA AA Thanks for the feedback! I have adjusted the > code > >A A A accordingly. > >A A A >AA AA AA AA percentage can now be 0 to INT_MAX as in > split-window. > >A A A >AA AA AA AA Yes, initially I was setting the increment as > a percentage > >A A A of the > >A A A >AA AA AA AA current pane size thinking that would be > convenient. > >A A A However, upon > >A A A >AA AA AA AA trying percentage of the available space in > the parent cell > >A A A I prefer > >A A A >AA AA AA AA that. Also it is then consistent with > split-window. > >A A A >AA AA AA AA Changes attached. Please have a look. > >A A A >AA AA AA AA Best, > >A A A >AA AA AA AA Anindya > >A A A >AA AA AA AA On Mon, Oct 7, 2019 at 4:57 AM Nicholas > Marriott > >A A A >AA AA AA AA <[email protected]> wrote: > >A A A > > >A A A >AA AA AA AA AA Thanks for this. > >A A A > > >A A A >AA AA AA AA AA For strtonum - I think it does no harm to > let people do > >A A A -p0 or > >A A A >AA AA AA AA AA -p99999999 to mean as small or as big as > possible. > >A A A > > >A A A >AA AA AA AA AA With split-window, -p is a % of the > available space, but > >A A A you have > >A A A >AA AA AA AA AA made > >A A A >AA AA AA AA AA it a % of the existing size? Is this more > useful? > >A A A > > >A A A >AA AA AA AA AA You should be able to get the available > space by looking > >A A A at the size > >A A A >AA AA AA AA AA of > >A A A >AA AA AA AA AA the parent cell > (wp->layout_cell->parent->sx and sy). > >A A A > > >A A A >AA AA AA AA AA On Sun, Oct 06, 2019 at 03:34:33PM -0700, > Anindya > >A A A Mukherjee wrote: > >A A A >AA AA AA AA AA >AAA AAA Thanks Thomas for the tips! I > have adjusted the > >A A A code > >A A A >AA AA AA AA AA accordingly. > >A A A >AA AA AA AA AA >AAA AAA Regarding the args_strtonum > call: I want to > >A A A disallow percent > >A A A >AA AA AA AA AA <=0 and > > >A A A >AA AA AA AA AA >AAA AAA 100. I thought adding 1, 100 > is a convenient > >A A A way of doing > >A A A >AA AA AA AA AA that, and I get > >A A A >AA AA AA AA AA >AAA AAA a "too small/large" error when > invalid values > >A A A are > >A A A >AA AA AA AA AA supplied.AAAA Is there any > >A A A >AA AA AA AA AA >AAA AAA issue with doing it this way? > >A A A >AA AA AA AA AA >AAA AAA Best, > >A A A >AA AA AA AA AA >AAA AAA Anindya > >A A A >AA AA AA AA AA >AAA AAA On Sun, Oct 6, 2019 at 3:03 PM > Thomas Adam > >A A A >AA AA AA AA AA <[email protected]> wrote: > >A A A >AA AA AA AA AA > > >A A A >AA AA AA AA AA >AAA AAA AAA Hi, > >A A A >AA AA AA AA AA > > >A A A >AA AA AA AA AA >AAA AAA AAA Thanks.AAAA Comments > below: > >A A A >AA AA AA AA AA > > >A A A >AA AA AA AA AA >AAA AAA AAA 1.AAAA You shouldn't > need to use 0U for > >A A A integer > >A A A >AA AA AA AA AA definitions. > >A A A >AA AA AA AA AA >AAA AAA AAA 2.AAAA In terms of > calling args_strtonum() > >A A A for > >A A A >AA AA AA AA AA percentage:AAAA 0, INT_MAX > >A A A >AA AA AA AA AA >AAA AAA AAA should be OK, rather than > 1, 100, no? > >A A A >AA AA AA AA AA >AAA AAA AAA 3.AAAA When you're > resizing in either L/R > >A A A or U/D, the > >A A A >AA AA AA AA AA layout cells are > >A A A >AA AA AA AA AA >AAA AAA AAA either LEFTRIGHT or > TOPBOTTOM.AAAA Rather > >A A A than embed your > >A A A >AA AA AA AA AA percentage > >A A A >AA AA AA AA AA >AAA AAA AAA check in all of the if > statements that > >A A A check for 'L', 'R', > >A A A >AA AA AA AA AA etc., you > >A A A >AA AA AA AA AA >AAA AAA AAA can pull this check out > to the top, > >A A A something like: > >A A A >AA AA AA AA AA > > >A A A >AA AA AA AA AA >AAA AAA AAA if (layout == > LAYOUT_TOPBOTTOM) > >A A A >AA AA AA AA AA >AAA AAA AAA AAAA AAAA adjust = > (wp->sy * percentage) / > >A A A 100 > >A A A >AA AA AA AA AA >AAA AAA AAA else > >A A A >AA AA AA AA AA >AAA AAA AAA AAAA AAAA adjust = > (wp->sx * percentage) / > >A A A 100 > >A A A >AA AA AA AA AA > > >A A A >AA AA AA AA AA >AAA AAA AAA I'm sure you get the > idea. > >A A A >AA AA AA AA AA > > >A A A >AA AA AA AA AA >AAA AAA AAA Kindly, > >A A A >AA AA AA AA AA >AAA AAA AAA Thomas > >A A A >AA AA AA AA AA > > >A A A >AA AA AA AA AA >AAA AAA AAA On Sun, 6 Oct 2019 at > 20:56, Anindya > >A A A Mukherjee > >A A A >AA AA AA AA AA <[email protected]> > >A A A >AA AA AA AA AA >AAA AAA AAA wrote: > >A A A >AA AA AA AA AA >AAA AAA AAA > > >A A A >AA AA AA AA AA >AAA AAA AAA > Hi, I have been playing > with adding a > >A A A percent option to > >A A A >AA AA AA AA AA resize-pane. > >A A A >AA AA AA AA AA >AAA AAA AAA It's on the todo list > (small things) for > >A A A tmux, and I find > >A A A >AA AA AA AA AA it very > >A A A >AA AA AA AA AA >AAA AAA AAA useful. Right now it's > working for me but > >A A A being new to > >A A A >AA AA AA AA AA tmux code I would > >A A A >AA AA AA AA AA >AAA AAA AAA love to have some eyes on > it. I have > >A A A attached my changes. > >A A A >AA AA AA AA AA >AAA AAA AAA > > >A A A >AA AA AA AA AA >AAA AAA AAA > If this is > worthwhile/useful then I can > >A A A do it properly > >A A A >AA AA AA AA AA via github. In > >A A A >AA AA AA AA AA >AAA AAA AAA that case any advice on > the proper > >A A A procedure is welcome! > >A A A >AA AA AA AA AA >AAA AAA AAA > > >A A A >AA AA AA AA AA >AAA AAA AAA > Anindya > >A A A >AA AA AA AA AA >AAA AAA AAA > > >A A A >AA AA AA AA AA >AAA AAA AAA > -- > >A A A >AA AA AA AA AA >AAA AAA AAA > You received this > message because you are > >A A A subscribed to > >A A A >AA AA AA AA AA the Google > >A A A >AA AA AA AA AA >AAA AAA AAA Groups "tmux-users" > group. > >A A A >AA AA AA AA AA >AAA AAA AAA > To unsubscribe from > this group and stop > >A A A receiving emails > >A A A >AA AA AA AA AA from it, send > >A A A >AA AA AA AA AA >AAA AAA AAA an email to > >A A A [email protected]. > >A A A >AA AA AA AA AA >AAA AAA AAA > To view this discussion > on the web, visit > >A A A >AA AA AA AA AA >AAA AAA A > >A A A >AA AA AA AA A > >A A A > > https://groups.google.com/d/msgid/tmux-users/CAN%2Bi5iO9yh4TSNJ_r7397%2BCwW55%2BwHqDOs20CBYpFmoXeZfHTA%40mail.gmail.com. > > > >A A A > diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c > >A A A > index 8d35d96f..519c9d5e 100644 > >A A A > --- a/cmd-resize-pane.c > >A A A > +++ b/cmd-resize-pane.c > >A A A > @@ -35,9 +35,9 @@ const struct cmd_entry > cmd_resize_pane_entry = { > >A A A >AA AA AA A .name = "resize-pane", > >A A A >AA AA AA A .alias = "resizep", > >A A A >A > >A A A > -AA AA A .args = { "DLMRt:Ux:y:Z", 0, 1 }, > >A A A > +AA AA A .args = { "DLMp:Rt:Ux:y:Z", 0, 1 }, > >A A A >AA AA AA A .usage = "[-DLMRUZ] [-x width] [-y height] " > >A A A CMD_TARGET_PANE_USAGE " " > >A A A > -AA AA AA AA AA AA AA "[adjustment]", > >A A A > +AA AA AA AA AA AA AA "[-p percentage] [adjustment]", > >A A A >A > >A A A >AA AA AA A .target = { 't', CMD_FIND_PANE, 0 }, > >A A A >A > >A A A > @@ -57,8 +57,9 @@ cmd_resize_pane_exec(struct cmd *self, > struct > >A A A cmdq_item *item) > >A A A >AA AA AA A struct sessionAA AA AA AA AA *s = > item->target.s; > >A A A >AA AA AA A const charAA AA AA AA AA AA AA *errstr; > >A A A >AA AA AA A charAA AA AA AA AA AA AA AA AA AA > *cause; > >A A A > -AA AA A u_intAA AA AA AA AA AA AA AA AA AA > adjust; > >A A A > +AA AA A u_intAA AA AA AA AA AA AA AA AA AA > adjust = 0; > >A A A >AA AA AA A intAA AA AA AA AA AA AA AA AA AA AA > x, y; > >A A A > +AA AA AA AA u_intAA AA AA AA AA AA AA AA AA > AA percentage = 0; > >A A A >A > >A A A >AA AA AA A if (args_has(args, 'M')) { > >A A A >AA AA AA AA AA AA AA A if > (cmd_mouse_window(&shared->mouse, &s) == > >A A A NULL) > >A A A > @@ -81,7 +82,29 @@ cmd_resize_pane_exec(struct cmd *self, > struct > >A A A cmdq_item *item) > >A A A >AA AA AA A } > >A A A >AA AA AA A server_unzoom_window(w); > >A A A >A > >A A A > -AA AA A if (args->argc == 0) > >A A A > +AA AA AA AA if (args_has(args, 'p')) { > >A A A > +AA AA AA AA AA AA AA AA percentage = > args_strtonum(args, 'p', 0, > >A A A INT_MAX, &cause); > >A A A > +AA AA AA AA AA AA A if (cause != NULL) { > >A A A > +AA AA AA AA AA AA AA AA AA AA A cmdq_error(item, > "percentage %s", > >A A A cause); > >A A A > +AA AA AA AA AA AA AA AA AA AA A free(cause); > >A A A > +AA AA AA AA AA AA AA AA AA AA A return > (CMD_RETURN_ERROR); > >A A A > +AA AA AA AA AA AA A } > >A A A > + > >A A A > +AA AA AA AA AA AA AA AA /* Should not also have an > adjustment in this > >A A A case. */ > >A A A > +AA AA AA AA AA AA AA AA if (args->argc > 0) { > >A A A > +AA AA AA AA AA AA AA AA AA AA A cmdq_error(item, > "percentage and > >A A A adjustment are mutually exclusive"); > >A A A > +AA AA AA AA AA AA AA AA AA AA A return > (CMD_RETURN_ERROR); > >A A A > +AA AA AA AA AA AA AA AA } > >A A A > + > >A A A > +AA AA AA AA AA AA AA AA /* Calculate adjustment > from parent cell > >A A A size. */ > >A A A > +AA AA AA AA AA AA AA AA if > (wp->layout_cell->parent) { /* A cell > >A A A filling the terminal has no parent */ > >A A A > +AA AA AA AA AA AA AA AA AA AA AA AA if > (args_has(args, 'U') || > >A A A args_has(args, 'D')) > >A A A > +AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA > AA adjust = > >A A A (wp->layout_cell->parent->sy * percentage) / 100; > >A A A > +AA AA AA AA AA AA AA AA AA AA AA AA else > >A A A > +AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA > AA adjust = > >A A A (wp->layout_cell->parent->sx * percentage) / 100; > >A A A > +AA AA AA AA AA AA AA AA } > >A A A > +AA AA AA AA } > >A A A > +AA AA A else if (args->argc == 0) > >A A A >AA AA AA AA AA AA AA A adjust = 1; > >A A A >AA AA AA A else { > >A A A >AA AA AA AA AA AA AA A adjust = > strtonum(args->argv[0], 1, INT_MAX, > >A A A &errstr); > >A A A > diff --git a/tmux.1 b/tmux.1 > >A A A > index e095ba40..f548af2c 100644 > >A A A > --- a/tmux.1 > >A A A > +++ b/tmux.1 > >A A A > @@ -2224,13 +2224,18 @@ if specified, to > >A A A >AA .Ar new-name . > >A A A >AA .It Xo Ic resize-pane > >A A A >AA .Op Fl DLMRUZ > >A A A > +.Op Fl p Ar percentage > >A A A >AA .Op Fl t Ar target-pane > >A A A >AA .Op Fl x Ar width > >A A A >AA .Op Fl y Ar height > >A A A >AA .Op Ar adjustment > >A A A >AA .Xc > >A A A >AA .D1 (alias: Ic resizep ) > >A A A > -Resize a pane, up, down, left or right by > >A A A > +Resize a pane, up, down, left or right by a > >A A A > +.Ar percentage > >A A A > +of the available space > >A A A > +.Fl p > >A A A > +or by > >A A A >AA .Ar adjustment > >A A A >AA with > >A A A >AA .Fl U , > >A A A > @@ -2246,7 +2251,11 @@ or > >A A A >AA .Fl y . > >A A A >AA The > >A A A >AA .Ar adjustment > >A A A > -is given in lines or cells (the default is 1). > >A A A > +is given in lines or cells (the default is 1). The > >A A A > +.Ar percentage > >A A A > +and the > >A A A > +.Ar adjustment > >A A A > +are mutually exclusive. > >A A A >AA .Pp > >A A A >AA With > >A A A >AA .Fl Z , > > > diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c > > index 8d35d96f..eeddabf9 100644 > > --- a/cmd-resize-pane.c > > +++ b/cmd-resize-pane.c > > @@ -35,9 +35,9 @@ const struct cmd_entry cmd_resize_pane_entry = { > >A A A A .name = "resize-pane", > >A A A A .alias = "resizep", > >A > > -A A A .args = { "DLMRt:Ux:y:Z", 0, 1 }, > > +A A A .args = { "DLMp:Rt:Ux:y:Z", 0, 1 }, > >A A A A .usage = "[-DLMRUZ] [-x width] [-y height] " > CMD_TARGET_PANE_USAGE " " > > -A A A A A A A "[adjustment]", > > +A A A A A A A "[-p percentage] [adjustment]", > >A > >A A A A .target = { 't', CMD_FIND_PANE, 0 }, > >A > > @@ -55,9 +55,10 @@ cmd_resize_pane_exec(struct cmd *self, struct > cmdq_item *item) > >A A A A struct windowA A A A A A *w = wl->window; > >A A A A struct clientA A A A A A *c = item->client; > >A A A A struct sessionA A A A A *s = item->target.s; > > +A A A struct layout_cellA A A *rootlc; > >A A A A const charA A A A A A A *errstr; > >A A A A charA A A A A A A A A A *cause; > > -A A A u_intA A A A A A A A A A adjust; > > +A A A u_intA A A A A A A A A A adjust = 0, percentage = > 0; > >A A A A intA A A A A A A A A A A x, y; > >A > >A A A A if (args_has(args, 'M')) { > > @@ -81,7 +82,33 @@ cmd_resize_pane_exec(struct cmd *self, struct > cmdq_item *item) > >A A A A } > >A A A A server_unzoom_window(w); > >A > > -A A A if (args->argc == 0) > > +A A A if (args_has(args, 'p')) { > > +A A A A A A A percentage = args_strtonum(args, 'p', 0, INT_MAX, > &cause); > > +A A A A A A A if (cause != NULL) { > > +A A A A A A A A A A A cmdq_error(item, "percentage %s", > cause); > > +A A A A A A A A A A A free(cause); > > +A A A A A A A A A A A return (CMD_RETURN_ERROR); > > +A A A A A A A } > > + > > +A A A A A A A /* Should not also have an adjustment in this > case. */ > > +A A A A A A A if (args->argc > 0) { > > +A A A A A A A A A A A cmdq_error(item, "percentage and > adjustment " > > +A A A A A A A A A A A A A A A A A A A "are mutually > exclusive"); > > +A A A A A A A A A A A return (CMD_RETURN_ERROR); > > +A A A A A A A } > > + > > +A A A A A A A /* Find the root layout cell */ > > +A A A A A A A rootlc = wp->layout_cell; > > +A A A A A A A while (rootlc->parent) > > +A A A A A A A A A A A rootlc = rootlc->parent; > > + > > +A A A A A A A /* Calculate adjustment from the root cell size. > */ > > +A A A A A A A if (args_has(args, 'U') || args_has(args, 'D')) > > +A A A A A A A A A A A adjust = (rootlc->sy * percentage) / > 100; > > +A A A A A A A else > > +A A A A A A A A A A A adjust = (rootlc->sx * percentage) / > 100; > > +A A A } > > +A A A else if (args->argc == 0) > >A A A A A A A A adjust = 1; > >A A A A else { > >A A A A A A A A adjust = strtonum(args->argv[0], 1, INT_MAX, > &errstr); > > diff --git a/tmux.1 b/tmux.1 > > index e095ba40..41066ddc 100644 > > --- a/tmux.1 > > +++ b/tmux.1 > > @@ -2224,13 +2224,18 @@ if specified, to > >A .Ar new-name . > >A .It Xo Ic resize-pane > >A .Op Fl DLMRUZ > > +.Op Fl p Ar percentage > >A .Op Fl t Ar target-pane > >A .Op Fl x Ar width > >A .Op Fl y Ar height > >A .Op Ar adjustment > >A .Xc > >A .D1 (alias: Ic resizep ) > > -Resize a pane, up, down, left or right by > > +Resize a pane, up, down, left or right by a > > +.Ar percentage > > +of the available space > > +.Fl p > > +or by > >A .Ar adjustment > >A with > >A .Fl U , > > @@ -2246,7 +2251,12 @@ or > >A .Fl y . > >A The > >A .Ar adjustment > > -is given in lines or cells (the default is 1). > > +is given in lines or columns (the default is 1). > > +The > > +.Ar percentage > > +and the > > +.Ar adjustment > > +are mutually exclusive. > >A .Pp > >A With > >A .Fl Z , -- You received this message because you are subscribed to the Google Groups "tmux-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/20191008130449.xv376i62b5cemrra%40yelena.
