diff options
author | Thomas Adam <thomas@xteddy.org> | 2020-04-22 12:01:38 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2020-04-22 12:01:38 +0100 |
commit | 8ae3915cc2c65228af12ff392ed8fdf26db489a2 (patch) | |
tree | 9a8088c37a83408787f36da5e82f02fd82e12f09 /layout-set.c | |
parent | dd5299841a87c0bf842488f7f9feb84b7e37c819 (diff) | |
parent | b72498c4ff0566d377a4757d1393817627c281ec (diff) | |
download | rtmux-8ae3915cc2c65228af12ff392ed8fdf26db489a2.tar.gz rtmux-8ae3915cc2c65228af12ff392ed8fdf26db489a2.tar.bz2 rtmux-8ae3915cc2c65228af12ff392ed8fdf26db489a2.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'layout-set.c')
-rw-r--r-- | layout-set.c | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/layout-set.c b/layout-set.c index f712b059..9ef28416 100644 --- a/layout-set.c +++ b/layout-set.c @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #include "tmux.h" @@ -186,6 +187,8 @@ layout_set_main_h(struct window *w) struct window_pane *wp; struct layout_cell *lc, *lcmain, *lcother, *lcchild; u_int n, mainh, otherh, sx, sy; + char *cause; + const char *s; layout_print_cell(w->layout_root, __func__, 1); @@ -198,8 +201,15 @@ layout_set_main_h(struct window *w) /* Find available height - take off one line for the border. */ sy = w->sy - 1; - /* Get the main pane height and work out the other pane height. */ - mainh = options_get_number(w->options, "main-pane-height"); + /* Get the main pane height. */ + s = options_get_string(w->options, "main-pane-height"); + mainh = args_string_percentage(s, 0, sy, sy, &cause); + if (cause != NULL) { + mainh = 24; + free(cause); + } + + /* Work out the other pane height. */ if (mainh + PANE_MINIMUM >= sy) { if (sy <= PANE_MINIMUM + PANE_MINIMUM) mainh = PANE_MINIMUM; @@ -207,10 +217,12 @@ layout_set_main_h(struct window *w) mainh = sy - PANE_MINIMUM; otherh = PANE_MINIMUM; } else { - otherh = options_get_number(w->options, "other-pane-height"); - if (otherh == 0) + s = options_get_string(w->options, "other-pane-height"); + otherh = args_string_percentage(s, 0, sy, sy, &cause); + if (cause != NULL || otherh == 0) { otherh = sy - mainh; - else if (otherh > sy || sy - otherh < mainh) + free(cause); + } else if (otherh > sy || sy - otherh < mainh) otherh = sy - mainh; else mainh = sy - otherh; @@ -273,6 +285,8 @@ layout_set_main_v(struct window *w) struct window_pane *wp; struct layout_cell *lc, *lcmain, *lcother, *lcchild; u_int n, mainw, otherw, sx, sy; + char *cause; + const char *s; layout_print_cell(w->layout_root, __func__, 1); @@ -285,8 +299,15 @@ layout_set_main_v(struct window *w) /* Find available width - take off one line for the border. */ sx = w->sx - 1; - /* Get the main pane width and work out the other pane width. */ - mainw = options_get_number(w->options, "main-pane-width"); + /* Get the main pane width. */ + s = options_get_string(w->options, "main-pane-width"); + mainw = args_string_percentage(s, 0, sx, sx, &cause); + if (cause != NULL) { + mainw = 80; + free(cause); + } + + /* Work out the other pane width. */ if (mainw + PANE_MINIMUM >= sx) { if (sx <= PANE_MINIMUM + PANE_MINIMUM) mainw = PANE_MINIMUM; @@ -294,10 +315,12 @@ layout_set_main_v(struct window *w) mainw = sx - PANE_MINIMUM; otherw = PANE_MINIMUM; } else { - otherw = options_get_number(w->options, "other-pane-width"); - if (otherw == 0) + s = options_get_string(w->options, "other-pane-width"); + otherw = args_string_percentage(s, 0, sx, sx, &cause); + if (cause != NULL || otherw == 0) { otherw = sx - mainw; - else if (otherw > sx || sx - otherw < mainw) + free(cause); + } else if (otherw > sx || sx - otherw < mainw) otherw = sx - mainw; else mainw = sx - otherw; |