summaryrefslogtreecommitdiffstats
path: root/server-client.c
diff options
context:
space:
mode:
authornicm <nicm>2022-03-24 09:05:57 +0000
committernicm <nicm>2022-03-24 09:05:57 +0000
commit792d13af49f2550a9a8d11b0099528628957a1a0 (patch)
tree055dafc23a9ceb88e92a34ac67ad7cb70c7aca7b /server-client.c
parent6a1706a62fb2442326cd37d84ff8b0d39bf0b7a6 (diff)
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.
Diffstat (limited to 'server-client.c')
-rw-r--r--server-client.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/server-client.c b/server-client.c
index f8236066..a2a367be 100644
--- a/server-client.c
+++ b/server-client.c
@@ -43,6 +43,7 @@ static void server_client_check_exit(struct client *);
static void server_client_check_redraw(struct client *);
static void server_client_check_modes(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 int server_client_assume_paste(struct session *);
static void server_client_update_latest(struct client *);
@@ -2603,8 +2604,10 @@ server_client_check_redraw(struct client *c)
}
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_path(c);
+ }
screen_redraw_screen(c);
}
@@ -2650,6 +2653,26 @@ server_client_set_title(struct client *c)
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. */
static void
server_client_dispatch(struct imsg *imsg, void *arg)