Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2025-12-15 15:19:29 +00:00
7 changed files with 72 additions and 32 deletions

View File

@@ -758,7 +758,7 @@ static int
cmd_parse_expand_alias(struct cmd_parse_command *cmd, cmd_parse_expand_alias(struct cmd_parse_command *cmd,
struct cmd_parse_input *pi, struct cmd_parse_result *pr) struct cmd_parse_input *pi, struct cmd_parse_result *pr)
{ {
struct cmd_parse_argument *arg, *arg1, *first; struct cmd_parse_argument *first;
struct cmd_parse_commands *cmds; struct cmd_parse_commands *cmds;
struct cmd_parse_command *last; struct cmd_parse_command *last;
char *alias, *name, *cause; char *alias, *name, *cause;
@@ -798,10 +798,7 @@ cmd_parse_expand_alias(struct cmd_parse_command *cmd,
TAILQ_REMOVE(&cmd->arguments, first, entry); TAILQ_REMOVE(&cmd->arguments, first, entry);
cmd_parse_free_argument(first); cmd_parse_free_argument(first);
TAILQ_FOREACH_SAFE(arg, &cmd->arguments, entry, arg1) { TAILQ_CONCAT(&last->arguments, &cmd->arguments, entry);
TAILQ_REMOVE(&cmd->arguments, arg, entry);
TAILQ_INSERT_TAIL(&last->arguments, arg, entry);
}
cmd_parse_log_commands(cmds, __func__); cmd_parse_log_commands(cmds, __func__);
pi->flags |= CMD_PARSE_NOALIAS; pi->flags |= CMD_PARSE_NOALIAS;

View File

@@ -480,9 +480,9 @@ key_bindings_init(void)
"bind -n M-MouseDown3Pane { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", "bind -n M-MouseDown3Pane { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }",
/* Mouse on scrollbar. */ /* Mouse on scrollbar. */
"bind -n MouseDown1ScrollbarUp { copy-mode -u }", "bind -n MouseDown1ScrollbarUp { if -Ft= '#{pane_in_mode}' { send -X page-up } {copy-mode -u } }",
"bind -n MouseDown1ScrollbarDown { copy-mode -d }", "bind -n MouseDown1ScrollbarDown { if -Ft= '#{pane_in_mode}' { send -X page-down } {copy-mode -d } }",
"bind -n MouseDrag1ScrollbarSlider { copy-mode -S }", "bind -n MouseDrag1ScrollbarSlider { if -Ft= '#{pane_in_mode}' { send -X scroll-to-mouse } { copy-mode -S } }",
/* Copy mode (emacs) keys. */ /* Copy mode (emacs) keys. */
"bind -Tcopy-mode C-Space { send -X begin-selection }", "bind -Tcopy-mode C-Space { send -X begin-selection }",

View File

@@ -197,9 +197,11 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp,
} else { /* sb_pos == PANE_SCROLLBARS_RIGHT */ } else { /* 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 (wp->yoff != 0 && py == wp->yoff - 1) if (pane_status != PANE_STATUS_BOTTOM &&
wp->yoff != 0 &&
py == wp->yoff - 1)
return (SCREEN_REDRAW_BORDER_TOP); return (SCREEN_REDRAW_BORDER_TOP);
if (py == ey) if (pane_status != PANE_STATUS_TOP && py == ey)
return (SCREEN_REDRAW_BORDER_BOTTOM); return (SCREEN_REDRAW_BORDER_BOTTOM);
} }
} }
@@ -380,7 +382,6 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, u_int px, u_int py,
/* Check if CELL_SCROLLBAR */ /* Check if CELL_SCROLLBAR */
if (window_pane_show_scrollbar(wp, pane_scrollbars)) { if (window_pane_show_scrollbar(wp, pane_scrollbars)) {
if (pane_status == PANE_STATUS_TOP) if (pane_status == PANE_STATUS_TOP)
line = wp->yoff - 1; line = wp->yoff - 1;
else else

36
spawn.c
View File

@@ -211,7 +211,9 @@ spawn_pane(struct spawn_context *sc, char **cause)
struct environ *child; struct environ *child;
struct environ_entry *ee; struct environ_entry *ee;
char **argv, *cp, **argvp, *argv0, *cwd, *new_cwd; char **argv, *cp, **argvp, *argv0, *cwd, *new_cwd;
const char *cmd, *tmp; char path[PATH_MAX];
const char *cmd, *tmp, *home = find_home();
const char *actual_cwd = NULL;
int argc; int argc;
u_int idx; u_int idx;
struct termios now; struct termios now;
@@ -366,6 +368,16 @@ spawn_pane(struct spawn_context *sc, char **cause)
goto complete; goto complete;
} }
/* Store current working directory and change to new one. */
if (getcwd(path, sizeof path) != NULL) {
if (chdir(new_wp->cwd) == 0)
actual_cwd = new_wp->cwd;
else if (home != NULL && chdir(home) == 0)
actual_cwd = home;
else if (chdir("/") == 0)
actual_cwd = "/";
}
/* Fork the new process. */ /* Fork the new process. */
new_wp->pid = fdforkpty(ptm_fd, &new_wp->fd, new_wp->tty, NULL, &ws); new_wp->pid = fdforkpty(ptm_fd, &new_wp->fd, new_wp->tty, NULL, &ws);
if (new_wp->pid == -1) { if (new_wp->pid == -1) {
@@ -381,8 +393,15 @@ spawn_pane(struct spawn_context *sc, char **cause)
return (NULL); return (NULL);
} }
/* In the parent process, everything is done now. */ /*
* In the parent process, everything is done now. Change the working
* directory back.
*/
if (new_wp->pid != 0) { if (new_wp->pid != 0) {
if (actual_cwd != NULL &&
chdir(path) != 0 &&
(home == NULL || chdir(home) != 0))
chdir("/");
goto complete; goto complete;
} }
@@ -397,17 +416,10 @@ spawn_pane(struct spawn_context *sc, char **cause)
} }
#endif #endif
/* /*
* Child process. Change to the working directory or home if that * Child process. Set PWD to the working directory.
* fails.
*/ */
if (chdir(new_wp->cwd) == 0) if (actual_cwd != NULL)
environ_set(child, "PWD", 0, "%s", new_wp->cwd); environ_set(child, "PWD", 0, "%s", actual_cwd);
else if ((tmp = find_home()) != NULL && chdir(tmp) == 0)
environ_set(child, "PWD", 0, "%s", tmp);
else if (chdir("/") == 0)
environ_set(child, "PWD", 0, "/");
else
fatal("chdir failed");
/* /*
* Update terminal escape characters from the session if available and * Update terminal escape characters from the session if available and

15
tmux.1
View File

@@ -2213,6 +2213,13 @@ but also exit copy mode if the cursor reaches the bottom.
Scroll so that the current line becomes the middle one while keeping the Scroll so that the current line becomes the middle one while keeping the
cursor on that line. cursor on that line.
.It Xo .It Xo
.Ic scroll-to-mouse
.Xc
Scroll pane in copy-mode when bound to a mouse drag event.
.Fl e
causes copy mode to exit when at the bottom.
.Pp
.It Xo
.Ic scroll-top .Ic scroll-top
.Xc .Xc
Scroll down until the current line is at the top while keeping the cursor on Scroll down until the current line is at the top while keeping the cursor on
@@ -2449,12 +2456,10 @@ cancels copy mode and any other modes.
.Fl M .Fl M
begins a mouse drag (only valid if bound to a mouse key binding, see begins a mouse drag (only valid if bound to a mouse key binding, see
.Sx MOUSE SUPPORT ) . .Sx MOUSE SUPPORT ) .
.Pp
.Fl S .Fl S
scrolls when bound to a mouse drag event; for example, enters copy-mode and scrolls when bound to a mouse drag event; See
.Ic copy-mode -Se .Ic scroll-to-mouse .
is bound to
.Ar MouseDrag1ScrollbarSlider
by default.
.Pp .Pp
.Fl s .Fl s
copies from copies from

View File

@@ -909,10 +909,16 @@ first_key:
* used. termios should have a better idea. * used. termios should have a better idea.
*/ */
bspace = tty->tio.c_cc[VERASE]; bspace = tty->tio.c_cc[VERASE];
if (bspace != _POSIX_VDISABLE && key == bspace) { if (bspace != _POSIX_VDISABLE) {
log_debug("%s: key %#llx is backspace", c->name, key); if (key == bspace) {
log_debug("%s: key %#llx is BSpace", c->name, key);
key = KEYC_BSPACE; key = KEYC_BSPACE;
} }
if (key == (bspace|KEYC_META)) {
log_debug("%s: key %#llx is M-BSpace", c->name, key);
key = KEYC_BSPACE|KEYC_META;
}
}
/* /*
* Fix up all C0 control codes that don't have a dedicated key into * Fix up all C0 control codes that don't have a dedicated key into

View File

@@ -1479,6 +1479,20 @@ window_copy_cmd_scroll_middle(struct window_copy_cmd_state *cs)
return (window_copy_cmd_scroll_to(cs, mid_value)); return (window_copy_cmd_scroll_to(cs, mid_value));
} }
/* Scroll the pane to the mouse in the scrollbar. */
static enum window_copy_cmd_action
window_copy_cmd_scroll_to_mouse(struct window_copy_cmd_state *cs)
{
struct window_mode_entry *wme = cs->wme;
struct window_pane *wp = wme->wp;
struct client *c = cs->c;
struct mouse_event *m = cs->m;
int scroll_exit = args_has(cs->wargs, 'e');
window_copy_scroll(wp, c->tty.mouse_slider_mpos, m->y, scroll_exit);
return (WINDOW_COPY_CMD_NOTHING);
}
/* Scroll line containing the cursor to the top. */ /* Scroll line containing the cursor to the top. */
static enum window_copy_cmd_action static enum window_copy_cmd_action
window_copy_cmd_scroll_top(struct window_copy_cmd_state *cs) window_copy_cmd_scroll_top(struct window_copy_cmd_state *cs)
@@ -3044,6 +3058,11 @@ static const struct {
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS, .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
.f = window_copy_cmd_scroll_middle .f = window_copy_cmd_scroll_middle
}, },
{ .command = "scroll-to-mouse",
.args = { "e", 0, 0, NULL },
.clear = WINDOW_COPY_CMD_CLEAR_EMACS_ONLY,
.f = window_copy_cmd_scroll_to_mouse
},
{ .command = "scroll-top", { .command = "scroll-top",
.args = { "", 0, 0, NULL }, .args = { "", 0, 0, NULL },
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS, .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,