Allow -p more than 100%, and account for borders when sizing new panes.

From Dane Jensen.
This commit is contained in:
nicm
2026-06-23 09:29:26 +00:00
parent 3ec115115d
commit 9dba08ac8b
7 changed files with 76 additions and 38 deletions

View File

@@ -88,7 +88,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
int input, empty, is_floating, flags = 0;
const char *template, *style, *value;
char *cause = NULL, *cp, *title;
struct options_entry *oe;
const struct options_table_entry *oe;
struct args_value *av;
enum pane_lines lines;
u_int count = args_count(args);
@@ -118,8 +118,20 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
if (empty)
flags |= SPAWN_EMPTY;
if ((value = args_get(args, 'B')) == NULL)
lines = window_get_pane_lines(w);
else {
oe = options_search("pane-border-lines");
lines = options_find_choice(oe, value, &cause);
if (cause != NULL) {
cmdq_error(item, "pane-border-lines %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
}
if (is_floating)
lc = layout_get_floating_cell(item, args, w, wp, &cause);
lc = layout_get_floating_cell(item, args, lines, w, wp, &cause);
else
lc = layout_get_tiled_cell(item, args, w, wp, flags, &cause);
if (cause != NULL) {
@@ -156,10 +168,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
if ((new_wp = spawn_pane(&sc, &cause)) == NULL) {
cmdq_error(item, "create pane failed: %s", cause);
free(cause);
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
return (CMD_RETURN_ERROR);
goto fail;
}
style = args_get(args, 's');
@@ -167,7 +176,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
if (options_set_string(new_wp->options, "window-style", 0,
"%s", style) == NULL) {
cmdq_error(item, "bad style: %s", style);
return (CMD_RETURN_ERROR);
goto fail;
}
options_set_string(new_wp->options, "window-active-style", 0,
"%s", style);
@@ -179,7 +188,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
if (options_set_string(new_wp->options,
"pane-active-border-style", 0, "%s", style) == NULL) {
cmdq_error(item, "bad active border style: %s", style);
return (CMD_RETURN_ERROR);
goto fail;
}
}
style = args_get(args, 'R');
@@ -188,22 +197,11 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
"%s", style) == NULL) {
cmdq_error(item, "bad inactive border style: %s",
style);
return (CMD_RETURN_ERROR);
goto fail;
}
}
value = args_get(args, 'B');
if (value != NULL) {
oe = options_get(new_wp->options, "pane-border-lines");
lines = options_find_choice(options_table_entry(oe), value,
&cause);
if (cause != NULL) {
cmdq_error(item, "pane-border-lines %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
options_set_number(new_wp->options, "pane-border-lines",
lines);
}
if (args_has(args, 'B'))
options_set_number(new_wp->options, "pane-border-lines", lines);
if (args_has(args, 'k') || args_has(args, 'm')) {
options_set_number(new_wp->options, "remain-on-exit", 3);
if (args_has(args, 'm')) {
@@ -228,10 +226,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
window_remove_pane(wp->window, new_wp);
cmdq_error(item, "%s", cause);
free(cause);
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
return (CMD_RETURN_ERROR);
goto fail;
case 1:
input = 0;
break;
@@ -273,4 +268,13 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_WAIT);
}
return (CMD_RETURN_NORMAL);
fail:
if (sc.argv != NULL)
cmd_free_argv(sc.argc, sc.argv);
environ_free(sc.environ);
layout_destroy_cell(w, lc, &w->layout_root);
return (CMD_RETURN_ERROR);
}