=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-resize-pane.c,v retrieving revision 1.38 retrieving revision 1.39 diff -c -r1.38 -r1.39 *** src/usr.bin/tmux/cmd-resize-pane.c 2019/07/06 20:56:34 1.38 --- src/usr.bin/tmux/cmd-resize-pane.c 2019/10/15 08:25:37 1.39 *************** *** 1,4 **** ! /* $OpenBSD: cmd-resize-pane.c,v 1.38 2019/07/06 20:56:34 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-resize-pane.c,v 1.39 2019/10/15 08:25:37 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 19,24 **** --- 19,25 ---- #include #include + #include #include "tmux.h" *************** *** 55,64 **** struct window *w = wl->window; struct client *c = item->client; struct session *s = item->target.s; ! const char *errstr; ! char *cause; u_int adjust; ! int x, y; if (args_has(args, 'M')) { if (cmd_mouse_window(&shared->mouse, &s) == NULL) --- 56,66 ---- struct window *w = wl->window; struct client *c = item->client; struct session *s = item->target.s; ! const char *errstr, *p; ! char *cause, *copy; u_int adjust; ! int x, y, percentage; ! size_t plen; if (args_has(args, 'M')) { if (cmd_mouse_window(&shared->mouse, &s) == NULL) *************** *** 91,111 **** } } ! if (args_has(args, 'x')) { ! x = args_strtonum(args, 'x', PANE_MINIMUM, INT_MAX, &cause); ! if (cause != NULL) { ! cmdq_error(item, "width %s", cause); ! free(cause); ! return (CMD_RETURN_ERROR); } layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x); } ! if (args_has(args, 'y')) { ! y = args_strtonum(args, 'y', PANE_MINIMUM, INT_MAX, &cause); ! if (cause != NULL) { ! cmdq_error(item, "height %s", cause); ! free(cause); ! return (CMD_RETURN_ERROR); } layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y); } --- 93,150 ---- } } ! if ((p = args_get(args, 'x')) != NULL) { ! plen = strlen(p); ! if (p[plen - 1] == '%') { ! copy = xstrdup(p); ! copy[plen - 1] = '\0'; ! percentage = strtonum(copy, 0, INT_MAX, &errstr); ! free(copy); ! if (errstr != NULL) { ! cmdq_error(item, "width %s", errstr); ! return (CMD_RETURN_ERROR); ! } ! x = (w->sx * percentage) / 100; ! if (x < PANE_MINIMUM) ! x = PANE_MINIMUM; ! if (x > INT_MAX) ! x = INT_MAX; ! } else { ! x = args_strtonum(args, 'x', PANE_MINIMUM, INT_MAX, ! &cause); ! if (cause != NULL) { ! cmdq_error(item, "width %s", cause); ! free(cause); ! return (CMD_RETURN_ERROR); ! } } layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x); } ! if ((p = args_get(args, 'y')) != NULL) { ! plen = strlen(p); ! if (p[plen - 1] == '%') { ! copy = xstrdup(p); ! copy[plen - 1] = '\0'; ! percentage = strtonum(copy, 0, INT_MAX, &errstr); ! free(copy); ! if (errstr != NULL) { ! cmdq_error(item, "height %s", errstr); ! return (CMD_RETURN_ERROR); ! } ! y = (w->sy * percentage) / 100; ! if (y < PANE_MINIMUM) ! y = PANE_MINIMUM; ! if (y > INT_MAX) ! y = INT_MAX; ! } ! else { ! y = args_strtonum(args, 'y', PANE_MINIMUM, INT_MAX, ! &cause); ! if (cause != NULL) { ! cmdq_error(item, "height %s", cause); ! free(cause); ! return (CMD_RETURN_ERROR); ! } } layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y); }