Compare commits

..

9 Commits
3.7 ... 3.7b

Author SHA1 Message Date
Nicholas Marriott
e802909de0 Fix so that the end of a synchronized update again triggers a redraw. 2026-07-01 17:49:40 +01:00
Nicholas Marriott
0e418b62d2 Remove C-r from help. 2026-06-30 07:44:51 +01:00
Nicholas Marriott
78a2145a47 Update CHANGES. 2026-06-30 07:42:25 +01:00
Nicholas Marriott
dbe50934b1 Add caching of scrollbar options to 3.7a branch. 2026-06-30 07:41:02 +01:00
nicm
166267c87a Allow :. in names again, forbidding them is overly pernickety. Only
forbid invalid UTF-8 and #(.
2026-06-29 19:53:42 +01:00
nicm
132a63d1da Allow empty window and session names. 2026-06-29 17:36:40 +01:00
nicm
4e612612dc Only forbid #( in names and titles (styles are #[ and are useful). 2026-06-29 08:11:08 +01:00
Nicholas Marriott
6c2ef75681 Bump version. 2026-06-28 16:54:51 +01:00
Nicholas Marriott
84291b021f Fix check so as to not use NULL name. 2026-06-27 10:58:39 +01:00
20 changed files with 134 additions and 156 deletions

13
CHANGES
View File

@@ -1,3 +1,16 @@
CHANGES FROM 3.7a TO 3.7b
* Fix so that the end of a synchronized update again triggers a redraw.
CHANGES FROM 3.7 TO 3.7a
* Fix crash in break-pane when no name is provided.
* Scrollbar options are now cached rather than being looked up for every redraw
(issue 5298).
* Only forbid #( in names, allow #[, empty names, : and .
CHANGES FROM 3.6b TO 3.7 CHANGES FROM 3.6b TO 3.7
* Add floating panes. These are panes which sit above the layout ("tiled * Add floating panes. These are panes which sit above the layout ("tiled

View File

@@ -62,7 +62,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
int idx = target->idx, before; int idx = target->idx, before;
const char *template, *name = args_get(args, 'n'); const char *template, *name = args_get(args, 'n');
if (name != NULL && !check_name(name, WINDOW_NAME_FORBID)) { if (name != NULL && !check_name(name)) {
cmdq_error(item, "invalid window name: %s", name); cmdq_error(item, "invalid window name: %s", name);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
@@ -86,7 +86,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (name != NULL) { if (name != NULL) {
window_set_name(w, name, WINDOW_NAME_FORBID); window_set_name(w, name, 0);
options_set_number(w->options, "automatic-rename", 0); options_set_number(w->options, "automatic-rename", 0);
} }
server_unlink_window(src_s, wl); server_unlink_window(src_s, wl);
@@ -114,9 +114,9 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
w->active = wp; w->active = wp;
w->latest = tc; w->latest = tc;
if (name != NULL) { if (name == NULL) {
newname = default_window_name(w); newname = default_window_name(w);
window_set_name(w, newname, WINDOW_NAME_FORBID); window_set_name(w, newname, 0);
free(newname); free(newname);
} else { } else {
window_set_name(w, name, 0); window_set_name(w, name, 0);

View File

@@ -101,22 +101,22 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
if ((tmp = args_get(args, 'n')) != NULL) { if ((tmp = args_get(args, 'n')) != NULL) {
ename = format_single(item, tmp, c, NULL, NULL, NULL); ename = format_single(item, tmp, c, NULL, NULL, NULL);
if (!check_name(ename, WINDOW_NAME_FORBID)) { if (!check_name(ename)) {
cmdq_error(item, "invalid window name: %s", ename); cmdq_error(item, "invalid window name: %s", ename);
free(ename); free(ename);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
wname = clean_name(ename, WINDOW_NAME_FORBID); wname = clean_name(ename, 0);
free(ename); free(ename);
} }
if ((tmp = args_get(args, 's')) != NULL) { if ((tmp = args_get(args, 's')) != NULL) {
ename = format_single(item, tmp, c, NULL, NULL, NULL); ename = format_single(item, tmp, c, NULL, NULL, NULL);
if (!check_name(ename, SESSION_NAME_FORBID)) { if (!check_name(ename)) {
cmdq_error(item, "invalid session name: %s", ename); cmdq_error(item, "invalid session name: %s", ename);
free(ename); free(ename);
goto fail; goto fail;
} }
sname = clean_name(ename, SESSION_NAME_FORBID); sname = clean_name(ename, 0);
free(ename); free(ename);
} }
if (args_has(args, 'A')) { if (args_has(args, 'A')) {
@@ -152,12 +152,12 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
else if (groupwith != NULL) else if (groupwith != NULL)
prefix = xstrdup(groupwith->name); prefix = xstrdup(groupwith->name);
else { else {
if (!check_name(group, SESSION_NAME_FORBID)) { if (!check_name(group)) {
cmdq_error(item, cmdq_error(item,
"invalid session group name: %s", group); "invalid session group name: %s", group);
goto fail; goto fail;
} }
prefix = clean_name(group, SESSION_NAME_FORBID); prefix = clean_name(group, 0);
} }
} }

View File

@@ -73,12 +73,12 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
name = args_get(args, 'n'); name = args_get(args, 'n');
if (name != NULL) { if (name != NULL) {
expanded = format_single(item, name, c, s, NULL, NULL); expanded = format_single(item, name, c, s, NULL, NULL);
if (!check_name(expanded, WINDOW_NAME_FORBID)) { if (!check_name(expanded)) {
cmdq_error(item, "invalid window name: %s", expanded); cmdq_error(item, "invalid window name: %s", expanded);
free(expanded); free(expanded);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
wname = clean_name(expanded, WINDOW_NAME_FORBID); wname = clean_name(expanded, 0);
free(expanded); free(expanded);
} }
if (args_has(args, 'S') && wname != NULL && target->idx == -1) { if (args_has(args, 'S') && wname != NULL && target->idx == -1) {

View File

@@ -52,12 +52,12 @@ cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
char *newname, *tmp; char *newname, *tmp;
tmp = format_single_from_target(item, args_string(args, 0)); tmp = format_single_from_target(item, args_string(args, 0));
if (!check_name(tmp, SESSION_NAME_FORBID)) { if (!check_name(tmp)) {
cmdq_error(item, "invalid session name: %s", tmp); cmdq_error(item, "invalid session name: %s", tmp);
free(tmp); free(tmp);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
newname = clean_name(tmp, SESSION_NAME_FORBID); newname = clean_name(tmp, 0);
free(tmp); free(tmp);
if (strcmp(newname, s->name) == 0) { if (strcmp(newname, s->name) == 0) {
free(newname); free(newname);

View File

@@ -51,13 +51,13 @@ cmd_rename_window_exec(struct cmd *self, struct cmdq_item *item)
char *name; char *name;
name = format_single_from_target(item, args_string(args, 0)); name = format_single_from_target(item, args_string(args, 0));
if (!check_name(name, WINDOW_NAME_FORBID)) { if (!check_name(name)) {
cmdq_error(item, "invalid window name: %s", name); cmdq_error(item, "invalid window name: %s", name);
free(name); free(name);
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
window_set_name(wl->window, name, WINDOW_NAME_FORBID); window_set_name(wl->window, name, 0);
options_set_number(wl->window->options, "automatic-rename", 0); options_set_number(wl->window->options, "automatic-rename", 0);
free(name); free(name);

View File

@@ -181,7 +181,7 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
struct window_pane *wp; struct window_pane *wp;
struct layout_cell *lc; struct layout_cell *lc;
int y, ly, x, lx, sx, sy, new_sx, new_sy; int y, ly, x, lx, sx, sy, new_sx, new_sy;
int scrollbars, sb_pos, left, right; int left, right;
int new_xoff, new_yoff, resizes = 0; int new_xoff, new_yoff, resizes = 0;
wp = cmd_mouse_pane(m, NULL, &wl); wp = cmd_mouse_pane(m, NULL, &wl);
@@ -193,15 +193,13 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
lc = wp->layout_cell; lc = wp->layout_cell;
sx = wp->sx; sx = wp->sx;
sy = wp->sy; sy = wp->sy;
scrollbars = options_get_number(w->options, "pane-scrollbars");
sb_pos = options_get_number(w->options, "pane-scrollbars-position");
left = wp->xoff - 1; left = wp->xoff - 1;
right = wp->xoff + sx; right = wp->xoff + sx;
if (window_pane_show_scrollbar(wp, scrollbars) && if (window_pane_show_scrollbar(wp) &&
sb_pos == PANE_SCROLLBARS_LEFT) { w->sb_pos == PANE_SCROLLBARS_LEFT) {
left -= wp->scrollbar_style.width + wp->scrollbar_style.pad; left -= wp->scrollbar_style.width + wp->scrollbar_style.pad;
} else if (window_pane_show_scrollbar(wp, scrollbars) && } else if (window_pane_show_scrollbar(wp) &&
sb_pos == PANE_SCROLLBARS_RIGHT) { w->sb_pos == PANE_SCROLLBARS_RIGHT) {
right += wp->scrollbar_style.width + wp->scrollbar_style.pad; right += wp->scrollbar_style.width + wp->scrollbar_style.pad;
} }

View File

@@ -1,6 +1,6 @@
# configure.ac # configure.ac
AC_INIT([tmux], 3.7) AC_INIT([tmux], 3.7b)
AC_PREREQ([2.60]) AC_PREREQ([2.60])
AC_CONFIG_AUX_DIR(etc) AC_CONFIG_AUX_DIR(etc)

16
input.c
View File

@@ -1953,16 +1953,16 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx)
case 2004: case 2004:
screen_write_mode_clear(sctx, MODE_BRACKETPASTE); screen_write_mode_clear(sctx, MODE_BRACKETPASTE);
break; break;
case 2026:
screen_write_stop_sync(ictx->wp);
if (ictx->wp != NULL)
ictx->wp->flags |= PANE_REDRAW;
break;
case 2031: case 2031:
screen_write_mode_clear(sctx, MODE_THEME_UPDATES); screen_write_mode_clear(sctx, MODE_THEME_UPDATES);
if (ictx->wp != NULL) if (ictx->wp != NULL)
ictx->wp->flags &= ~PANE_THEMECHANGED; ictx->wp->flags &= ~PANE_THEMECHANGED;
break; break;
case 2026: /* synchronized output */
screen_write_stop_sync(ictx->wp);
if (ictx->wp != NULL)
ictx->wp->flags |= PANE_REDRAW;
break;
default: default:
log_debug("%s: unknown '%c'", __func__, ictx->ch); log_debug("%s: unknown '%c'", __func__, ictx->ch);
break; break;
@@ -2065,7 +2065,7 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx)
ictx->wp->flags &= ~PANE_THEMECHANGED; ictx->wp->flags &= ~PANE_THEMECHANGED;
} }
break; break;
case 2026: /* synchronized output */ case 2026:
screen_write_start_sync(ictx->wp); screen_write_start_sync(ictx->wp);
break; break;
default: default:
@@ -2822,10 +2822,10 @@ input_exit_rename(struct input_ctx *ictx)
if (o != NULL) if (o != NULL)
options_remove_or_default(o, -1, NULL); options_remove_or_default(o, -1, NULL);
if (!options_get_number(w->options, "automatic-rename")) if (!options_get_number(w->options, "automatic-rename"))
window_set_name(w, "", WINDOW_NAME_FORBID_EXT); window_set_name(w, "", 1);
} else { } else {
options_set_number(w->options, "automatic-rename", 0); options_set_number(w->options, "automatic-rename", 0);
window_set_name(w, ictx->input_buf, WINDOW_NAME_FORBID_EXT); window_set_name(w, ictx->input_buf, 1);
} }
server_redraw_window_borders(w); server_redraw_window_borders(w);
server_status_window(w); server_status_window(w);

View File

@@ -359,12 +359,10 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
{ {
struct window_pane *wp; struct window_pane *wp;
struct layout_cell *lc; struct layout_cell *lc;
int status, scrollbars, sb_pos, sb_w, sb_pad; int status, sb_w, sb_pad;
u_int sx, sy; u_int sx, sy;
status = options_get_number(w->options, "pane-border-status"); status = options_get_number(w->options, "pane-border-status");
scrollbars = options_get_number(w->options, "pane-scrollbars");
sb_pos = options_get_number(w->options, "pane-scrollbars-position");
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if ((lc = wp->layout_cell) == NULL || wp == skip) if ((lc = wp->layout_cell) == NULL || wp == skip)
@@ -382,14 +380,14 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
sy--; sy--;
} }
if (window_pane_show_scrollbar(wp, scrollbars)) { if (window_pane_show_scrollbar(wp)) {
sb_w = wp->scrollbar_style.width; sb_w = wp->scrollbar_style.width;
sb_pad = wp->scrollbar_style.pad; sb_pad = wp->scrollbar_style.pad;
if (sb_w < 1) if (sb_w < 1)
sb_w = 1; sb_w = 1;
if (sb_pad < 0) if (sb_pad < 0)
sb_pad = 0; sb_pad = 0;
if (sb_pos == PANE_SCROLLBARS_LEFT) { if (w->sb_pos == PANE_SCROLLBARS_LEFT) {
if ((int)sx - sb_w < PANE_MINIMUM) { if ((int)sx - sb_w < PANE_MINIMUM) {
wp->xoff = wp->xoff + wp->xoff = wp->xoff +
(int)sx - PANE_MINIMUM; (int)sx - PANE_MINIMUM;
@@ -398,7 +396,7 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
sx = sx - sb_w - sb_pad; sx = sx - sb_w - sb_pad;
wp->xoff = wp->xoff + sb_w + sb_pad; wp->xoff = wp->xoff + sb_w + sb_pad;
} }
} else /* sb_pos == PANE_SCROLLBARS_RIGHT */ } else /* w->sb_pos == PANE_SCROLLBARS_RIGHT */
if ((int)sx - sb_w - sb_pad < PANE_MINIMUM) if ((int)sx - sb_w - sb_pad < PANE_MINIMUM)
sx = PANE_MINIMUM; sx = PANE_MINIMUM;
else else
@@ -438,16 +436,15 @@ layout_resize_check(struct window *w, struct layout_cell *lc,
struct layout_cell *lcchild; struct layout_cell *lcchild;
struct style *sb_style = &w->active->scrollbar_style; struct style *sb_style = &w->active->scrollbar_style;
u_int available, minimum; u_int available, minimum;
int status, scrollbars; int status;
status = options_get_number(w->options, "pane-border-status"); status = options_get_number(w->options, "pane-border-status");
scrollbars = options_get_number(w->options, "pane-scrollbars");
if (lc->type == LAYOUT_WINDOWPANE) { if (lc->type == LAYOUT_WINDOWPANE) {
/* Space available in this cell only. */ /* Space available in this cell only. */
if (type == LAYOUT_LEFTRIGHT) { if (type == LAYOUT_LEFTRIGHT) {
available = lc->sx; available = lc->sx;
if (scrollbars) if (w->sb != PANE_SCROLLBARS_OFF)
minimum = PANE_MINIMUM + sb_style->width + minimum = PANE_MINIMUM + sb_style->width +
sb_style->pad; sb_style->pad;
else else
@@ -1003,7 +1000,6 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
u_int sx, sy, xoff, yoff, size1, size2, minimum; u_int sx, sy, xoff, yoff, size1, size2, minimum;
u_int new_size, saved_size, resize_first = 0; u_int new_size, saved_size, resize_first = 0;
int full_size = (flags & SPAWN_FULLSIZE), status; int full_size = (flags & SPAWN_FULLSIZE), status;
int scrollbars;
/* /*
* If full_size is specified, add a new cell at the top of the window * If full_size is specified, add a new cell at the top of the window
@@ -1014,7 +1010,6 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
else else
lc = wp->layout_cell; lc = wp->layout_cell;
status = options_get_number(wp->window->options, "pane-border-status"); status = options_get_number(wp->window->options, "pane-border-status");
scrollbars = options_get_number(wp->window->options, "pane-scrollbars");
/* Copy the old cell size. */ /* Copy the old cell size. */
sx = lc->sx; sx = lc->sx;
@@ -1025,7 +1020,7 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
/* Check there is enough space for the two new panes. */ /* Check there is enough space for the two new panes. */
switch (type) { switch (type) {
case LAYOUT_LEFTRIGHT: case LAYOUT_LEFTRIGHT:
if (scrollbars) { if (wp->window->sb != PANE_SCROLLBARS_OFF) {
minimum = PANE_MINIMUM * 2 + sb_style->width + minimum = PANE_MINIMUM * 2 + sb_style->width +
sb_style->pad; sb_style->pad;
} else } else

View File

@@ -148,7 +148,6 @@ static const char* mode_tree_help_start[] = {
"\r\033[1m T \033[0m\016x\017 \033[0mUntag all %1s\n", "\r\033[1m T \033[0m\016x\017 \033[0mUntag all %1s\n",
"\r\033[1m C-t \033[0m\016x\017 \033[0mTag all %1s\n", "\r\033[1m C-t \033[0m\016x\017 \033[0mTag all %1s\n",
"\r\033[1m C-s \033[0m\016x\017 \033[0mSearch forward\n", "\r\033[1m C-s \033[0m\016x\017 \033[0mSearch forward\n",
"\r\033[1m C-r \033[0m\016x\017 \033[0mSearch backward\n",
"\r\033[1m n \033[0m\016x\017 \033[0mRepeat search forward\n", "\r\033[1m n \033[0m\016x\017 \033[0mRepeat search forward\n",
"\r\033[1m N \033[0m\016x\017 \033[0mRepeat search backward\n", "\r\033[1m N \033[0m\016x\017 \033[0mRepeat search backward\n",
"\r\033[1m f \033[0m\016x\017 \033[0mFilter %1s\n", "\r\033[1m f \033[0m\016x\017 \033[0mFilter %1s\n",

View File

@@ -95,7 +95,7 @@ check_window_name(struct window *w)
name = format_window_name(w); name = format_window_name(w);
if (strcmp(name, w->name) != 0) { if (strcmp(name, w->name) != 0) {
log_debug("@%u new name %s (was %s)", w->id, name, w->name); log_debug("@%u new name %s (was %s)", w->id, name, w->name);
window_set_name(w, name, WINDOW_NAME_FORBID_EXT); window_set_name(w, name, 1);
server_redraw_window_borders(w); server_redraw_window_borders(w);
server_status_window(w); server_status_window(w);
} else } else
@@ -166,7 +166,7 @@ parse_window_name(const char *in)
if (*name == '/') if (*name == '/')
name = basename(name); name = basename(name);
name = clean_name(name, WINDOW_NAME_FORBID); name = clean_name(name, 0);
free(copy); free(copy);
if (name == NULL) if (name == NULL)
return (xstrdup("")); return (xstrdup(""));

View File

@@ -1237,9 +1237,14 @@ options_push_changes(const char *name)
if (strcmp(name, "pane-border-status") == 0 || if (strcmp(name, "pane-border-status") == 0 ||
strcmp(name, "pane-scrollbars") == 0 || strcmp(name, "pane-scrollbars") == 0 ||
strcmp(name, "pane-scrollbars-position") == 0) { strcmp(name, "pane-scrollbars-position") == 0) {
RB_FOREACH(w, windows, &windows) RB_FOREACH(w, windows, &windows) {
w->sb = options_get_number(w->options,
"pane-scrollbars");
w->sb_pos = options_get_number(w->options,
"pane-scrollbars-position");
layout_fix_panes(w, NULL); layout_fix_panes(w, NULL);
} }
}
if (strcmp(name, "pane-scrollbars-style") == 0) { if (strcmp(name, "pane-scrollbars-style") == 0) {
RB_FOREACH(wp, window_pane_tree, &all_window_panes) { RB_FOREACH(wp, window_pane_tree, &all_window_panes) {
style_set_scrollbar_style_from_option( style_set_scrollbar_style_from_option(

View File

@@ -219,7 +219,7 @@ paste_rename(const char *oldname, const char *newname, char **cause)
return (-1); return (-1);
} }
name = clean_name(newname, ""); name = clean_name(newname, 0);
if (name == NULL) { if (name == NULL) {
if (cause != NULL) if (cause != NULL)
xasprintf(cause, "invalid buffer name: %s", newname); xasprintf(cause, "invalid buffer name: %s", newname);
@@ -287,7 +287,7 @@ paste_set(char *data, size_t size, const char *name, char **cause)
return (-1); return (-1);
} }
newname = clean_name(name, ""); newname = clean_name(name, 0);
if (newname == NULL) { if (newname == NULL) {
if (cause != NULL) if (cause != NULL)
xasprintf(cause, "invalid buffer name: %s", name); xasprintf(cause, "invalid buffer name: %s", name);

View File

@@ -123,31 +123,28 @@ static enum screen_redraw_border_type
screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp, screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
int px, int py) int px, int py)
{ {
struct options *oo = wp->window->options; struct window *w = wp->window;
struct options *oo = w->options;
int ex = wp->xoff + wp->sx, ey = wp->yoff + wp->sy; int ex = wp->xoff + wp->sx, ey = wp->yoff + wp->sy;
int hsplit = 0, vsplit = 0, pane_status = ctx->pane_status; int hsplit = 0, vsplit = 0, pane_status = ctx->pane_status;
int pane_scrollbars = ctx->pane_scrollbars, sb_w = 0; int sb_w = 0;
int sb_pos, sx = wp->sx, sy = wp->sy, left, right; int sx = wp->sx, sy = wp->sy, left, right;
enum layout_type split_type; enum layout_type split_type;
if (pane_scrollbars != 0)
sb_pos = ctx->pane_scrollbars_pos;
else
sb_pos = 0;
/* Inside pane. */ /* Inside pane. */
if (px >= wp->xoff && px < ex && py >= wp->yoff && py < ey) if (px >= wp->xoff && px < ex && py >= wp->yoff && py < ey)
return (SCREEN_REDRAW_INSIDE); return (SCREEN_REDRAW_INSIDE);
/* Are scrollbars enabled? */ /* Are scrollbars enabled? */
if (window_pane_show_scrollbar(wp, pane_scrollbars)) if (window_pane_show_scrollbar(wp))
sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad;
/* Floating pane borders. */ /* Floating pane borders. */
if (window_pane_is_floating(wp)) { if (window_pane_is_floating(wp)) {
left = wp->xoff - 1; left = wp->xoff - 1;
right = wp->xoff + sx; right = wp->xoff + sx;
if (sb_pos == PANE_SCROLLBARS_LEFT) if (w->sb != PANE_SCROLLBARS_OFF &&
w->sb_pos == PANE_SCROLLBARS_LEFT)
left -= sb_w; left -= sb_w;
else else
right += sb_w; right += sb_w;
@@ -182,7 +179,8 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
* active window's border when there are two panes. * active window's border when there are two panes.
*/ */
if ((wp->yoff == 0 || py >= wp->yoff - 1) && py <= ey) { if ((wp->yoff == 0 || py >= wp->yoff - 1) && py <= ey) {
if (sb_pos == PANE_SCROLLBARS_LEFT) { if (w->sb != PANE_SCROLLBARS_OFF &&
w->sb_pos == PANE_SCROLLBARS_LEFT) {
if (wp->xoff - sb_w == 0 && px == sx + sb_w) { if (wp->xoff - sb_w == 0 && px == sx + sb_w) {
if (!hsplit || (hsplit && py <= sy / 2)) if (!hsplit || (hsplit && py <= sy / 2))
return (SCREEN_REDRAW_BORDER_RIGHT); return (SCREEN_REDRAW_BORDER_RIGHT);
@@ -194,7 +192,7 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
if (px == wp->xoff + sx + sb_w - 1) if (px == wp->xoff + sx + sb_w - 1)
return (SCREEN_REDRAW_BORDER_RIGHT); return (SCREEN_REDRAW_BORDER_RIGHT);
} }
} else { /* sb_pos == PANE_SCROLLBARS_RIGHT or disabled */ } else { /* w->sb_pos == PANE_SCROLLBARS_RIGHT or disabled */
if (wp->xoff == 0 && px == sx + sb_w) { if (wp->xoff == 0 && px == sx + sb_w) {
if (!hsplit || (hsplit && py <= sy / 2)) if (!hsplit || (hsplit && py <= sy / 2))
return (SCREEN_REDRAW_BORDER_RIGHT); return (SCREEN_REDRAW_BORDER_RIGHT);
@@ -216,7 +214,8 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
if (wp->yoff != 0 && py == wp->yoff - 1 && px > sx / 2) if (wp->yoff != 0 && py == wp->yoff - 1 && px > sx / 2)
return (SCREEN_REDRAW_BORDER_TOP); return (SCREEN_REDRAW_BORDER_TOP);
} else { } else {
if (sb_pos == PANE_SCROLLBARS_LEFT) { if (w->sb != PANE_SCROLLBARS_OFF &&
w->sb_pos == PANE_SCROLLBARS_LEFT) {
if ((wp->xoff - sb_w == 0 || px >= wp->xoff - sb_w) && if ((wp->xoff - sb_w == 0 || px >= wp->xoff - sb_w) &&
(px <= ex || (sb_w != 0 && px < ex + sb_w))) { (px <= ex || (sb_w != 0 && px < ex + sb_w))) {
if (pane_status != PANE_STATUS_BOTTOM && if (pane_status != PANE_STATUS_BOTTOM &&
@@ -225,7 +224,7 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
if (pane_status != PANE_STATUS_TOP && py == ey) if (pane_status != PANE_STATUS_TOP && py == ey)
return (SCREEN_REDRAW_BORDER_BOTTOM); return (SCREEN_REDRAW_BORDER_BOTTOM);
} }
} else { /* sb_pos == PANE_SCROLLBARS_RIGHT */ } else { /* w->sb_pos == PANE_SCROLLBARS_RIGHT */
if ((wp->xoff == 0 || px >= wp->xoff) && if ((wp->xoff == 0 || px >= wp->xoff) &&
(px <= ex || (sb_w != 0 && px < ex + sb_w))) { (px <= ex || (sb_w != 0 && px < ex + sb_w))) {
if (pane_status != PANE_STATUS_BOTTOM && if (pane_status != PANE_STATUS_BOTTOM &&
@@ -278,17 +277,15 @@ screen_redraw_cell_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
struct client *c = ctx->c; struct client *c = ctx->c;
struct window *w = c->session->curw->window; struct window *w = c->session->curw->window;
struct window_pane *wp2; struct window_pane *wp2;
int sx = w->sx, sy = w->sy, sb_w, sb_pos, n; int sx = w->sx, sy = w->sy, sb_w, n;
if (ctx->pane_scrollbars != 0)
sb_pos = ctx->pane_scrollbars_pos;
else
sb_pos = 0;
sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad;
/* For floating panes, only check the pane itself. */ /* For floating panes, only check the pane itself. */
if (window_pane_is_floating(wp)) { if (window_pane_is_floating(wp)) {
n = screen_redraw_cell_border1(ctx, sb_pos, sb_w, wp, px, py); n = screen_redraw_cell_border1(ctx,
w->sb != PANE_SCROLLBARS_OFF ? w->sb_pos : 0,
sb_w, wp, px, py);
if (n == -1) if (n == -1)
return (0); return (0);
return (n); return (n);
@@ -311,7 +308,9 @@ screen_redraw_cell_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
TAILQ_FOREACH(wp2, &w->z_index, zentry) { TAILQ_FOREACH(wp2, &w->z_index, zentry) {
if (!window_pane_visible(wp2) || window_pane_is_floating(wp2)) if (!window_pane_visible(wp2) || window_pane_is_floating(wp2))
continue; continue;
n = screen_redraw_cell_border1(ctx, sb_pos, sb_w, wp2, px, py); n = screen_redraw_cell_border1(ctx,
w->sb != PANE_SCROLLBARS_OFF ? w->sb_pos : 0,
sb_w, wp2, px, py);
if (n != -1) if (n != -1)
return (n); return (n);
} }
@@ -435,9 +434,9 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py,
struct window_pane *wp, *start; struct window_pane *wp, *start;
int sx = w->sx, sy = w->sy; int sx = w->sx, sy = w->sy;
int pane_status = ctx->pane_status; int pane_status = ctx->pane_status;
int border, pane_scrollbars = ctx->pane_scrollbars; int border;
int pane_status_line, tiled_only = 0, left, right; int pane_status_line, tiled_only = 0, left, right;
int sb_pos = ctx->pane_scrollbars_pos, sb_w; int sb_w;
*wpp = NULL; *wpp = NULL;
@@ -452,7 +451,8 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py,
continue; continue;
} }
sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad;
if (sb_pos == PANE_SCROLLBARS_LEFT) { if (w->sb != PANE_SCROLLBARS_OFF &&
w->sb_pos == PANE_SCROLLBARS_LEFT) {
if ((px >= wp->xoff - 1 - sb_w && if ((px >= wp->xoff - 1 - sb_w &&
px <= wp->xoff + (int)wp->sx) && px <= wp->xoff + (int)wp->sx) &&
(py >= wp->yoff - 1 && (py >= wp->yoff - 1 &&
@@ -492,7 +492,8 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py,
*wpp = wp; *wpp = wp;
sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad;
if (sb_pos == PANE_SCROLLBARS_LEFT) { if (w->sb != PANE_SCROLLBARS_OFF &&
w->sb_pos == PANE_SCROLLBARS_LEFT) {
if ((px < wp->xoff - 1 - sb_w || if ((px < wp->xoff - 1 - sb_w ||
px > wp->xoff + (int)wp->sx) && px > wp->xoff + (int)wp->sx) &&
(py < wp->yoff - 1 || (py < wp->yoff - 1 ||
@@ -524,7 +525,7 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py,
} }
/* Check if CELL_SCROLLBAR. */ /* Check if CELL_SCROLLBAR. */
if (window_pane_show_scrollbar(wp, pane_scrollbars)) { if (window_pane_show_scrollbar(wp)) {
/* /*
* Check if py could lie within a scrollbar. If the * Check if py could lie within a scrollbar. If the
* pane is at the top then py == 0 to sy; if the pane * pane is at the top then py == 0 to sy; if the pane
@@ -536,10 +537,10 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py,
(py >= wp->yoff && (py >= wp->yoff &&
py < wp->yoff + (int)wp->sy)) { py < wp->yoff + (int)wp->sy)) {
/* Check if px lies within a scrollbar. */ /* Check if px lies within a scrollbar. */
if ((sb_pos == PANE_SCROLLBARS_RIGHT && if ((w->sb_pos == PANE_SCROLLBARS_RIGHT &&
(px >= wp->xoff + (int)wp->sx && (px >= wp->xoff + (int)wp->sx &&
px < wp->xoff + (int)wp->sx + sb_w)) || px < wp->xoff + (int)wp->sx + sb_w)) ||
(sb_pos == PANE_SCROLLBARS_LEFT && (w->sb_pos == PANE_SCROLLBARS_LEFT &&
(px >= wp->xoff - sb_w && (px >= wp->xoff - sb_w &&
px < wp->xoff))) px < wp->xoff)))
return (CELL_SCROLLBAR); return (CELL_SCROLLBAR);
@@ -593,13 +594,12 @@ screen_redraw_make_pane_status(struct client *c, struct window_pane *wp,
struct style_line_entry *sle = &wp->border_status_line; struct style_line_entry *sle = &wp->border_status_line;
char *expanded; char *expanded;
int pane_status = rctx->pane_status, sb_w = 0; int pane_status = rctx->pane_status, sb_w = 0;
int pane_scrollbars = rctx->pane_scrollbars;
int max_width; int max_width;
u_int width, i, cell_type, px, py; u_int width, i, cell_type, px, py;
struct screen_write_ctx ctx; struct screen_write_ctx ctx;
struct screen old; struct screen old;
if (window_pane_show_scrollbar(wp, pane_scrollbars)) if (window_pane_show_scrollbar(wp))
sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad;
ft = format_create(c, NULL, FORMAT_PANE|wp->id, FORMAT_STATUS); ft = format_create(c, NULL, FORMAT_PANE|wp->id, FORMAT_STATUS);
@@ -791,10 +791,6 @@ screen_redraw_set_context(struct client *c, struct screen_redraw_ctx *ctx)
ctx->pane_status = options_get_number(wo, "pane-border-status"); ctx->pane_status = options_get_number(wo, "pane-border-status");
ctx->pane_lines = options_get_number(wo, "pane-border-lines"); ctx->pane_lines = options_get_number(wo, "pane-border-lines");
ctx->pane_scrollbars = options_get_number(wo, "pane-scrollbars");
ctx->pane_scrollbars_pos = options_get_number(wo,
"pane-scrollbars-position");
tty_window_offset(&c->tty, &ctx->ox, &ctx->oy, &ctx->sx, &ctx->sy); tty_window_offset(&c->tty, &ctx->ox, &ctx->oy, &ctx->sx, &ctx->sy);
log_debug("%s: %s @%u ox=%u oy=%u sx=%u sy=%u %u/%d", __func__, c->name, log_debug("%s: %s @%u ox=%u oy=%u sx=%u sy=%u %u/%d", __func__, c->name,
@@ -863,7 +859,7 @@ screen_redraw_pane(struct client *c, struct window_pane *wp,
if (!redraw_scrollbar_only) if (!redraw_scrollbar_only)
screen_redraw_draw_pane(&ctx, wp); screen_redraw_draw_pane(&ctx, wp);
if (window_pane_show_scrollbar(wp, ctx.pane_scrollbars)) if (window_pane_show_scrollbar(wp))
screen_redraw_draw_pane_scrollbar(&ctx, wp); screen_redraw_draw_pane_scrollbar(&ctx, wp);
tty_reset(&c->tty); tty_reset(&c->tty);
@@ -1142,7 +1138,7 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px,
struct window *w; struct window *w;
struct visible_range *ri; struct visible_range *ri;
static struct visible_ranges sr = { NULL, 0, 0 }; static struct visible_ranges sr = { NULL, 0, 0 };
int found_self, sb, sb_w, sb_pos; int found_self, sb_w;
int lb, rb, tb, bb, sx, ex; int lb, rb, tb, bb, sx, ex;
u_int i, s; u_int i, s;
@@ -1182,9 +1178,6 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px,
r->used = 1; r->used = 1;
} }
sb = options_get_number(w->options, "pane-scrollbars");
sb_pos = options_get_number(w->options, "pane-scrollbars-position");
found_self = 0; found_self = 0;
TAILQ_FOREACH_REVERSE(wp, &w->z_index, window_panes_zindex, zentry) { TAILQ_FOREACH_REVERSE(wp, &w->z_index, window_panes_zindex, zentry) {
if (wp == base_wp) { if (wp == base_wp) {
@@ -1203,12 +1196,12 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px,
continue; continue;
sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad;
if (!window_pane_show_scrollbar(wp, sb)) if (!window_pane_show_scrollbar(wp))
sb_w = sb_pos = 0; sb_w = 0;
for (i = 0; i < r->used; i++) { for (i = 0; i < r->used; i++) {
ri = &r->ranges[i]; ri = &r->ranges[i];
if (sb_pos == PANE_SCROLLBARS_LEFT) { if (w->sb_pos == PANE_SCROLLBARS_LEFT) {
if (wp->xoff > sb_w) if (wp->xoff > sb_w)
lb = wp->xoff - 1 - sb_w; lb = wp->xoff - 1 - sb_w;
else else
@@ -1219,7 +1212,7 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px,
else else
lb = 0; lb = 0;
} }
if (sb_pos == PANE_SCROLLBARS_LEFT) if (w->sb_pos == PANE_SCROLLBARS_LEFT)
rb = wp->xoff + wp->sx; rb = wp->xoff + wp->sx;
else /* PANE_SCROLLBARS_RIGHT or none. */ else /* PANE_SCROLLBARS_RIGHT or none. */
rb = wp->xoff + wp->sx + sb_w; rb = wp->xoff + wp->sx + sb_w;
@@ -1407,7 +1400,7 @@ screen_redraw_draw_pane_scrollbars(struct screen_redraw_ctx *ctx)
log_debug("%s: %s @%u", __func__, c->name, w->id); log_debug("%s: %s @%u", __func__, c->name, w->id);
TAILQ_FOREACH(wp, &w->panes, entry) { TAILQ_FOREACH(wp, &w->panes, entry) {
if (window_pane_show_scrollbar(wp, ctx->pane_scrollbars) && if (window_pane_show_scrollbar(wp) &&
window_pane_visible(wp)) window_pane_visible(wp))
screen_redraw_draw_pane_scrollbar(ctx, wp); screen_redraw_draw_pane_scrollbar(ctx, wp);
} }
@@ -1420,8 +1413,8 @@ screen_redraw_draw_pane_scrollbar(struct screen_redraw_ctx *ctx,
{ {
struct screen *s = wp->screen; struct screen *s = wp->screen;
double percent_view; double percent_view;
u_int sb = ctx->pane_scrollbars, total_height, sb_h = wp->sy; u_int sb = wp->window->sb, total_height, sb_h = wp->sy;
u_int sb_pos = ctx->pane_scrollbars_pos, slider_h, slider_y; u_int sb_pos = wp->window->sb_pos, slider_h, slider_y;
int sb_w = wp->scrollbar_style.width; int sb_w = wp->scrollbar_style.width;
int sb_pad = wp->scrollbar_style.pad; int sb_pad = wp->scrollbar_style.pad;
int cm_y, cm_size, xoff = wp->xoff; int cm_y, cm_size, xoff = wp->xoff;

View File

@@ -249,10 +249,7 @@ screen_set_title(struct screen *s, const char *title, int untrusted)
{ {
char *new_title; char *new_title;
if (untrusted) new_title = clean_name(title, untrusted);
new_title = clean_name(title, "#");
else
new_title = clean_name(title, "");
if (new_title == NULL) if (new_title == NULL)
return (0); return (0);
free(s->title); free(s->title);
@@ -266,10 +263,7 @@ screen_set_path(struct screen *s, const char *path, int untrusted)
{ {
char *new_path; char *new_path;
if (untrusted) new_path = clean_name(path, untrusted);
new_path = clean_name(path, "#");
else
new_path = clean_name(path, "");
if (new_path == NULL) if (new_path == NULL)
return (0); return (0);
free(s->path); free(s->path);

View File

@@ -603,17 +603,14 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
u_int *sl_mpos) u_int *sl_mpos)
{ {
struct window *w = wp->window; struct window *w = wp->window;
struct options *wo = w->options;
struct window_pane *fwp; struct window_pane *fwp;
int pane_status, sb, sb_pos, sb_w, sb_pad; int pane_status, sb_w, sb_pad;
int pane_status_line, sl_top, sl_bottom; int pane_status_line, sl_top, sl_bottom;
int bdr_bottom, bdr_top, bdr_left, bdr_right; int bdr_bottom, bdr_top, bdr_left, bdr_right;
sb = options_get_number(wo, "pane-scrollbars"); pane_status = options_get_number(w->options, "pane-border-status");
sb_pos = options_get_number(wo, "pane-scrollbars-position");
pane_status = options_get_number(wo, "pane-border-status");
if (window_pane_show_scrollbar(wp, sb)) { if (window_pane_show_scrollbar(wp)) {
sb_w = wp->scrollbar_style.width; sb_w = wp->scrollbar_style.width;
sb_pad = wp->scrollbar_style.pad; sb_pad = wp->scrollbar_style.pad;
} else { } else {
@@ -628,7 +625,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
else else
pane_status_line = -1; /* not used */ pane_status_line = -1; /* not used */
bdr_left = wp->xoff - 1; bdr_left = wp->xoff - 1;
if (sb_pos == PANE_SCROLLBARS_LEFT) if (w->sb_pos == PANE_SCROLLBARS_LEFT)
bdr_left -= sb_pad + sb_w; bdr_left -= sb_pad + sb_w;
/* Check if point is within the pane or scrollbar. */ /* Check if point is within the pane or scrollbar. */
@@ -636,15 +633,15 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
py != pane_status_line && py != wp->yoff + (int)wp->sy) || py != pane_status_line && py != wp->yoff + (int)wp->sy) ||
(wp->yoff == 0 && py < (int)wp->sy) || (wp->yoff == 0 && py < (int)wp->sy) ||
(py >= wp->yoff && py < wp->yoff + (int)wp->sy)) && (py >= wp->yoff && py < wp->yoff + (int)wp->sy)) &&
((sb_pos == PANE_SCROLLBARS_RIGHT && ((w->sb_pos == PANE_SCROLLBARS_RIGHT &&
px < wp->xoff + (int)wp->sx + sb_pad + sb_w) || px < wp->xoff + (int)wp->sx + sb_pad + sb_w) ||
(sb_pos == PANE_SCROLLBARS_LEFT && (w->sb_pos == PANE_SCROLLBARS_LEFT &&
px < wp->xoff + (int)wp->sx - sb_pad - sb_w))) { px < wp->xoff + (int)wp->sx - sb_pad - sb_w))) {
/* Check if in the scrollbar. */ /* Check if in the scrollbar. */
if ((sb_pos == PANE_SCROLLBARS_RIGHT && if ((w->sb_pos == PANE_SCROLLBARS_RIGHT &&
(px >= wp->xoff + (int)wp->sx + sb_pad && (px >= wp->xoff + (int)wp->sx + sb_pad &&
px < wp->xoff + (int)wp->sx + sb_pad + sb_w)) || px < wp->xoff + (int)wp->sx + sb_pad + sb_w)) ||
(sb_pos == PANE_SCROLLBARS_LEFT && (w->sb_pos == PANE_SCROLLBARS_LEFT &&
(px >= wp->xoff - sb_pad - sb_w && (px >= wp->xoff - sb_pad - sb_w &&
px < wp->xoff - sb_pad))) { px < wp->xoff - sb_pad))) {
/* Check where inside the scrollbar. */ /* Check where inside the scrollbar. */
@@ -674,7 +671,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
if ((w->flags & WINDOW_ZOOMED) && if ((w->flags & WINDOW_ZOOMED) &&
(~fwp->flags & PANE_ZOOMED)) (~fwp->flags & PANE_ZOOMED))
continue; continue;
if (window_pane_show_scrollbar(fwp, sb)) { if (window_pane_show_scrollbar(fwp)) {
sb_w = fwp->scrollbar_style.width; sb_w = fwp->scrollbar_style.width;
sb_pad = fwp->scrollbar_style.pad; sb_pad = fwp->scrollbar_style.pad;
} else { } else {
@@ -684,7 +681,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
bdr_top = fwp->yoff - 1; bdr_top = fwp->yoff - 1;
bdr_bottom = fwp->yoff + fwp->sy; bdr_bottom = fwp->yoff + fwp->sy;
bdr_left = fwp->xoff - 1; bdr_left = fwp->xoff - 1;
if (sb_pos == PANE_SCROLLBARS_LEFT) { if (w->sb_pos == PANE_SCROLLBARS_LEFT) {
bdr_left -= sb_pad + sb_w; bdr_left -= sb_pad + sb_w;
bdr_right = fwp->xoff + fwp->sx; bdr_right = fwp->xoff + fwp->sx;
} else { } else {

21
tmux.c
View File

@@ -282,15 +282,15 @@ get_timer(void)
} }
char * char *
clean_name(const char *name, const char* forbid) clean_name(const char *name, int untrusted)
{ {
char *copy, *cp, *new_name; char *copy, *cp, *new_name;
if (*name == '\0' || !utf8_isvalid(name)) if (!utf8_isvalid(name))
return (NULL); return (NULL);
copy = xstrdup(name); copy = xstrdup(name);
for (cp = copy; *cp != '\0'; cp++) { for (cp = copy; *cp != '\0'; cp++) {
if (strchr(forbid, *cp) != NULL) if (untrusted && cp[0] == '#' && cp[1] == '(')
*cp = '_'; *cp = '_';
} }
utf8_stravis(&new_name, copy, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL); utf8_stravis(&new_name, copy, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
@@ -298,22 +298,11 @@ clean_name(const char *name, const char* forbid)
return (new_name); return (new_name);
} }
/*
* Check a name given by a command: reject it if it is empty, not valid UTF-8,
* or contains a forbidden character. Other characters that clean_name would
* change (for example with utf8_stravis) are allowed and fixed silently.
*/
int int
check_name(const char *name, const char *forbid) check_name(const char *name)
{ {
const char *cp; if (!utf8_isvalid(name))
if (*name == '\0' || !utf8_isvalid(name))
return (0); return (0);
for (cp = name; *cp != '\0'; cp++) {
if (strchr(forbid, *cp) != NULL)
return (0);
}
return (1); return (1);
} }

17
tmux.h
View File

@@ -96,12 +96,6 @@ struct winlink;
#define TMUX_LOCK_CMD "lock -np" #define TMUX_LOCK_CMD "lock -np"
#endif #endif
/* Forbidden characters in names. */
#define WINDOW_NAME_FORBID ":."
#define WINDOW_NAME_FORBID_EXT ":.#"
#define SESSION_NAME_FORBID ":."
#define SESSION_NAME_FORBID_EXT ":.#"
/* Minimum layout cell size, NOT including border lines. */ /* Minimum layout cell size, NOT including border lines. */
#define PANE_MINIMUM 1 #define PANE_MINIMUM 1
@@ -1396,6 +1390,9 @@ struct window {
u_int last_new_pane_x; u_int last_new_pane_x;
u_int last_new_pane_y; u_int last_new_pane_y;
int sb;
int sb_pos;
struct utf8_data *fill_character; struct utf8_data *fill_character;
int flags; int flags;
#define WINDOW_BELL 0x1 #define WINDOW_BELL 0x1
@@ -2409,8 +2406,8 @@ int checkshell(const char *);
void setblocking(int, int); void setblocking(int, int);
char *shell_argv0(const char *, int); char *shell_argv0(const char *, int);
uint64_t get_timer(void); uint64_t get_timer(void);
char *clean_name(const char *, const char *); char *clean_name(const char *, int);
int check_name(const char *, const char *); int check_name(const char *);
const char *sig2name(int); const char *sig2name(int);
const char *find_cwd(void); const char *find_cwd(void);
const char *find_home(void); const char *find_home(void);
@@ -3487,7 +3484,7 @@ void window_pane_stack_push(struct window_panes *,
struct window_pane *); struct window_pane *);
void window_pane_stack_remove(struct window_panes *, void window_pane_stack_remove(struct window_panes *,
struct window_pane *); struct window_pane *);
void window_set_name(struct window *, const char *, const char *); void window_set_name(struct window *, const char *, int);
void window_add_ref(struct window *, const char *); void window_add_ref(struct window *, const char *);
void window_remove_ref(struct window *, const char *); void window_remove_ref(struct window *, const char *);
void winlink_clear_flags(struct winlink *); void winlink_clear_flags(struct winlink *);
@@ -3501,7 +3498,7 @@ void window_pane_update_used_data(struct window_pane *,
void window_set_fill_character(struct window *); void window_set_fill_character(struct window *);
void window_pane_default_cursor(struct window_pane *); void window_pane_default_cursor(struct window_pane *);
int window_pane_mode(struct window_pane *); int window_pane_mode(struct window_pane *);
int window_pane_show_scrollbar(struct window_pane *, int); int window_pane_show_scrollbar(struct window_pane *);
int window_pane_get_bg(struct window_pane *); int window_pane_get_bg(struct window_pane *);
int window_pane_get_fg(struct window_pane *); int window_pane_get_fg(struct window_pane *);
int window_pane_get_fg_control_client(struct window_pane *); int window_pane_get_fg_control_client(struct window_pane *);

View File

@@ -401,11 +401,11 @@ window_remove_ref(struct window *w, const char *from)
} }
void void
window_set_name(struct window *w, const char *new_name, const char *forbid) window_set_name(struct window *w, const char *new_name, int untrusted)
{ {
char *name; char *name;
name = clean_name(new_name, forbid); name = clean_name(new_name, untrusted);
if (name != NULL) { if (name != NULL) {
free(w->name); free(w->name);
w->name = name; w->name = name;
@@ -1471,20 +1471,16 @@ window_pane_full_size_offset(struct window_pane *wp, int *xoff, int *yoff,
u_int *sx, u_int *sy) u_int *sx, u_int *sy)
{ {
struct window *w = wp->window; struct window *w = wp->window;
int pane_scrollbars; u_int sb_w;
u_int sb_w, sb_pos;
pane_scrollbars = options_get_number(w->options, "pane-scrollbars"); if (window_pane_show_scrollbar(wp))
sb_pos = options_get_number(w->options, "pane-scrollbars-position");
if (window_pane_show_scrollbar(wp, pane_scrollbars))
sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad;
else else
sb_w = 0; sb_w = 0;
if (sb_pos == PANE_SCROLLBARS_LEFT) { if (w->sb_pos == PANE_SCROLLBARS_LEFT) {
*xoff = wp->xoff - sb_w; *xoff = wp->xoff - sb_w;
*sx = wp->sx + sb_w; *sx = wp->sx + sb_w;
} else { /* sb_pos == PANE_SCROLLBARS_RIGHT */ } else { /* w->sb_pos == PANE_SCROLLBARS_RIGHT */
*xoff = wp->xoff; *xoff = wp->xoff;
*sx = wp->sx + sb_w; *sx = wp->sx + sb_w;
} }
@@ -1899,12 +1895,14 @@ window_pane_mode(struct window_pane *wp)
/* Return 1 if scrollbar is or should be displayed. */ /* Return 1 if scrollbar is or should be displayed. */
int int
window_pane_show_scrollbar(struct window_pane *wp, int sb_option) window_pane_show_scrollbar(struct window_pane *wp)
{ {
struct window *w = wp->window;
if (SCREEN_IS_ALTERNATE(&wp->base)) if (SCREEN_IS_ALTERNATE(&wp->base))
return (0); return (0);
if (sb_option == PANE_SCROLLBARS_ALWAYS || if (w->sb == PANE_SCROLLBARS_ALWAYS ||
(sb_option == PANE_SCROLLBARS_MODAL && (w->sb == PANE_SCROLLBARS_MODAL &&
window_pane_mode(wp) != WINDOW_PANE_NO_MODE)) window_pane_mode(wp) != WINDOW_PANE_NO_MODE))
return (1); return (1);
return (0); return (0);