mirror of https://github.com/tmux/tmux.git
Add a capability for OSC 7 and use it similarly to how the title is set
(and controlled by the same set-titles option). GitHub issue 3127.pull/3160/head
parent
60a0a904e0
commit
89a0046ad3
|
@ -40,6 +40,7 @@ static void server_client_check_exit(struct client *);
|
||||||
static void server_client_check_redraw(struct client *);
|
static void server_client_check_redraw(struct client *);
|
||||||
static void server_client_check_modes(struct client *);
|
static void server_client_check_modes(struct client *);
|
||||||
static void server_client_set_title(struct client *);
|
static void server_client_set_title(struct client *);
|
||||||
|
static void server_client_set_path(struct client *);
|
||||||
static void server_client_reset_state(struct client *);
|
static void server_client_reset_state(struct client *);
|
||||||
static int server_client_assume_paste(struct session *);
|
static int server_client_assume_paste(struct session *);
|
||||||
static void server_client_update_latest(struct client *);
|
static void server_client_update_latest(struct client *);
|
||||||
|
@ -2600,8 +2601,10 @@ server_client_check_redraw(struct client *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->flags & CLIENT_ALLREDRAWFLAGS) {
|
if (c->flags & CLIENT_ALLREDRAWFLAGS) {
|
||||||
if (options_get_number(s->options, "set-titles"))
|
if (options_get_number(s->options, "set-titles")) {
|
||||||
server_client_set_title(c);
|
server_client_set_title(c);
|
||||||
|
server_client_set_path(c);
|
||||||
|
}
|
||||||
screen_redraw_screen(c);
|
screen_redraw_screen(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2647,6 +2650,26 @@ server_client_set_title(struct client *c)
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set client path. */
|
||||||
|
static void
|
||||||
|
server_client_set_path(struct client *c)
|
||||||
|
{
|
||||||
|
struct session *s = c->session;
|
||||||
|
const char *path;
|
||||||
|
|
||||||
|
if (s->curw == NULL)
|
||||||
|
return;
|
||||||
|
if (s->curw->window->active->base.path == NULL)
|
||||||
|
path = "";
|
||||||
|
else
|
||||||
|
path = s->curw->window->active->base.path;
|
||||||
|
if (c->path == NULL || strcmp(path, c->path) != 0) {
|
||||||
|
free(c->path);
|
||||||
|
c->path = xstrdup(path);
|
||||||
|
tty_set_path(&c->tty, c->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Dispatch message from client. */
|
/* Dispatch message from client. */
|
||||||
static void
|
static void
|
||||||
server_client_dispatch(struct imsg *imsg, void *arg)
|
server_client_dispatch(struct imsg *imsg, void *arg)
|
||||||
|
|
7
tmux.1
7
tmux.1
|
@ -3627,6 +3627,8 @@ Supports DECSLRM margins.
|
||||||
Supports
|
Supports
|
||||||
.Xr xterm 1
|
.Xr xterm 1
|
||||||
mouse sequences.
|
mouse sequences.
|
||||||
|
.It osc7
|
||||||
|
Supports the OSC 7 working directory extension.
|
||||||
.It overline
|
.It overline
|
||||||
Supports the overline SGR attribute.
|
Supports the overline SGR attribute.
|
||||||
.It rectfill
|
.It rectfill
|
||||||
|
@ -6394,6 +6396,11 @@ $ printf '\e033[4 q'
|
||||||
If
|
If
|
||||||
.Em Se
|
.Em Se
|
||||||
is not set, \&Ss with argument 0 will be used to reset the cursor style instead.
|
is not set, \&Ss with argument 0 will be used to reset the cursor style instead.
|
||||||
|
.It Em \&Swd
|
||||||
|
Set the opening sequence for the working directory notification.
|
||||||
|
The sequence is terminated using the standard
|
||||||
|
.Em fsl
|
||||||
|
capability.
|
||||||
.It Em \&Sync
|
.It Em \&Sync
|
||||||
Start (parameter is 1) or end (parameter is 2) a synchronized update.
|
Start (parameter is 1) or end (parameter is 2) a synchronized update.
|
||||||
.It Em \&Tc
|
.It Em \&Tc
|
||||||
|
|
3
tmux.h
3
tmux.h
|
@ -540,6 +540,7 @@ enum tty_code_code {
|
||||||
TTYC_SMULX,
|
TTYC_SMULX,
|
||||||
TTYC_SMXX,
|
TTYC_SMXX,
|
||||||
TTYC_SS,
|
TTYC_SS,
|
||||||
|
TTYC_SWD,
|
||||||
TTYC_SYNC,
|
TTYC_SYNC,
|
||||||
TTYC_TC,
|
TTYC_TC,
|
||||||
TTYC_TSL,
|
TTYC_TSL,
|
||||||
|
@ -1709,6 +1710,7 @@ struct client {
|
||||||
struct format_job_tree *jobs;
|
struct format_job_tree *jobs;
|
||||||
|
|
||||||
char *title;
|
char *title;
|
||||||
|
char *path;
|
||||||
const char *cwd;
|
const char *cwd;
|
||||||
|
|
||||||
char *term_name;
|
char *term_name;
|
||||||
|
@ -2259,6 +2261,7 @@ void tty_start_tty(struct tty *);
|
||||||
void tty_send_requests(struct tty *);
|
void tty_send_requests(struct tty *);
|
||||||
void tty_stop_tty(struct tty *);
|
void tty_stop_tty(struct tty *);
|
||||||
void tty_set_title(struct tty *, const char *);
|
void tty_set_title(struct tty *, const char *);
|
||||||
|
void tty_set_path(struct tty *, const char *);
|
||||||
void tty_update_mode(struct tty *, int, struct screen *);
|
void tty_update_mode(struct tty *, int, struct screen *);
|
||||||
void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int,
|
void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int,
|
||||||
u_int, u_int, const struct grid_cell *, struct colour_palette *);
|
u_int, u_int, const struct grid_cell *, struct colour_palette *);
|
||||||
|
|
|
@ -53,6 +53,18 @@ static const struct tty_feature tty_feature_title = {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Terminal has OSC 7 working directory. */
|
||||||
|
static const char *tty_feature_osc7_capabilities[] = {
|
||||||
|
"Swd=\\E]7;",
|
||||||
|
"fsl=\\a",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
static const struct tty_feature tty_feature_osc7 = {
|
||||||
|
"osc7",
|
||||||
|
tty_feature_osc7_capabilities,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
/* Terminal has mouse support. */
|
/* Terminal has mouse support. */
|
||||||
static const char *tty_feature_mouse_capabilities[] = {
|
static const char *tty_feature_mouse_capabilities[] = {
|
||||||
"kmous=\\E[M",
|
"kmous=\\E[M",
|
||||||
|
@ -249,6 +261,7 @@ static const struct tty_feature *tty_features[] = {
|
||||||
&tty_feature_focus,
|
&tty_feature_focus,
|
||||||
&tty_feature_margins,
|
&tty_feature_margins,
|
||||||
&tty_feature_mouse,
|
&tty_feature_mouse,
|
||||||
|
&tty_feature_osc7,
|
||||||
&tty_feature_overline,
|
&tty_feature_overline,
|
||||||
&tty_feature_rectfill,
|
&tty_feature_rectfill,
|
||||||
&tty_feature_rgb,
|
&tty_feature_rgb,
|
||||||
|
|
|
@ -277,6 +277,7 @@ static const struct tty_term_code_entry tty_term_codes[] = {
|
||||||
[TTYC_SMUL] = { TTYCODE_STRING, "smul" },
|
[TTYC_SMUL] = { TTYCODE_STRING, "smul" },
|
||||||
[TTYC_SMXX] = { TTYCODE_STRING, "smxx" },
|
[TTYC_SMXX] = { TTYCODE_STRING, "smxx" },
|
||||||
[TTYC_SS] = { TTYCODE_STRING, "Ss" },
|
[TTYC_SS] = { TTYCODE_STRING, "Ss" },
|
||||||
|
[TTYC_SWD] = { TTYCODE_STRING, "Swd" },
|
||||||
[TTYC_SYNC] = { TTYCODE_STRING, "Sync" },
|
[TTYC_SYNC] = { TTYCODE_STRING, "Sync" },
|
||||||
[TTYC_TC] = { TTYCODE_FLAG, "Tc" },
|
[TTYC_TC] = { TTYCODE_FLAG, "Tc" },
|
||||||
[TTYC_TSL] = { TTYCODE_STRING, "tsl" },
|
[TTYC_TSL] = { TTYCODE_STRING, "tsl" },
|
||||||
|
|
12
tty.c
12
tty.c
|
@ -655,6 +655,18 @@ tty_set_title(struct tty *tty, const char *title)
|
||||||
tty_putcode(tty, TTYC_FSL);
|
tty_putcode(tty, TTYC_FSL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_set_path(struct tty *tty, const char *title)
|
||||||
|
{
|
||||||
|
if (!tty_term_has(tty->term, TTYC_SWD) ||
|
||||||
|
!tty_term_has(tty->term, TTYC_FSL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
tty_putcode(tty, TTYC_SWD);
|
||||||
|
tty_puts(tty, title);
|
||||||
|
tty_putcode(tty, TTYC_FSL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tty_force_cursor_colour(struct tty *tty, int c)
|
tty_force_cursor_colour(struct tty *tty, int c)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue