141 lines
5.7 KiB
Diff
141 lines
5.7 KiB
Diff
From f3dc38dcae472286c7d7c2708e4dbfe70a6c2d57 Mon Sep 17 00:00:00 2001
|
|
From: nicm <nicm>
|
|
Date: Fri, 15 Nov 2019 11:16:53 +0000
|
|
Subject: [PATCH] Handle OSC 7 (a VTE extension) and put the result in a new
|
|
format (pane_path).
|
|
|
|
---
|
|
format.c | 1 +
|
|
input.c | 7 +++++++
|
|
screen.c | 8 ++++++++
|
|
tmux.1 | 9 +++++----
|
|
tmux.h | 2 ++
|
|
5 files changed, 23 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/format.c b/format.c
|
|
index 485a3bc..49eed46 100644
|
|
--- a/format.c
|
|
+++ b/format.c
|
|
@@ -2026,6 +2026,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
|
|
format_add(ft, "pane_width", "%u", wp->sx);
|
|
format_add(ft, "pane_height", "%u", wp->sy);
|
|
format_add(ft, "pane_title", "%s", wp->base.title);
|
|
+ format_add(ft, "pane_path", "%s", wp->base.path);
|
|
format_add(ft, "pane_id", "%%%u", wp->id);
|
|
format_add(ft, "pane_active", "%d", wp == w->active);
|
|
format_add(ft, "pane_input_off", "%d", !!(wp->flags & PANE_INPUTOFF));
|
|
diff --git a/input.c b/input.c
|
|
index f959799..b4a534b 100644
|
|
--- a/input.c
|
|
+++ b/input.c
|
|
@@ -132,6 +132,7 @@ static void input_set_state(struct window_pane *,
|
|
static void input_reset_cell(struct input_ctx *);
|
|
|
|
static void input_osc_4(struct input_ctx *, const char *);
|
|
+static void input_osc_7(struct input_ctx *, const char *);
|
|
static void input_osc_10(struct input_ctx *, const char *);
|
|
static void input_osc_11(struct input_ctx *, const char *);
|
|
static void input_osc_52(struct input_ctx *, const char *);
|
|
@@ -2183,6 +2184,12 @@ input_exit_osc(struct input_ctx *ictx)
|
|
case 4:
|
|
input_osc_4(ictx, p);
|
|
break;
|
|
+ case 7:
|
|
+ if (utf8_isvalid(p)) {
|
|
+ screen_set_path(sctx->s, p);
|
|
+ server_status_window(ictx->wp->window);
|
|
+ }
|
|
+ break;
|
|
case 10:
|
|
input_osc_10(ictx, p);
|
|
break;
|
|
diff --git a/screen.c b/screen.c
|
|
index 9b67e7e..405932e 100644
|
|
--- a/screen.c
|
|
+++ b/screen.c
|
|
@@ -158,6 +158,14 @@ screen_set_title(struct screen *s, const char *title)
|
|
utf8_stravis(&s->title, title, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
|
|
}
|
|
|
|
+/* Set screen path. */
|
|
+void
|
|
+screen_set_path(struct screen *s, const char *path)
|
|
+{
|
|
+ free(s->path);
|
|
+ utf8_stravis(&s->path, path, VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL);
|
|
+}
|
|
+
|
|
/* Push the current title onto the stack. */
|
|
void
|
|
screen_push_title(struct screen *s)
|
|
diff --git a/tmux.1 b/tmux.1
|
|
index 3ba7077..a5f1f8f 100644
|
|
--- a/tmux.1
|
|
+++ b/tmux.1
|
|
@@ -3895,7 +3895,7 @@ The following variables are available, where appropriate:
|
|
.It Li "pane_current_path" Ta "" Ta "Current path if available"
|
|
.It Li "pane_dead" Ta "" Ta "1 if pane is dead"
|
|
.It Li "pane_dead_status" Ta "" Ta "Exit status of process in dead pane"
|
|
-.It Li "pane_format" Ta "" Ta "1 if format is for a pane (not assuming the current)"
|
|
+.It Li "pane_format" Ta "" Ta "1 if format is for a pane"
|
|
.It Li "pane_height" Ta "" Ta "Height of pane"
|
|
.It Li "pane_id" Ta "#D" Ta "Unique pane ID"
|
|
.It Li "pane_in_mode" Ta "" Ta "If pane is in a mode"
|
|
@@ -3903,6 +3903,7 @@ The following variables are available, where appropriate:
|
|
.It Li "pane_index" Ta "#P" Ta "Index of pane"
|
|
.It Li "pane_left" Ta "" Ta "Left of pane"
|
|
.It Li "pane_mode" Ta "" Ta "Name of pane mode, if any."
|
|
+.It Li "pane_path" Ta "#T" Ta "Path of pane (can be set by application)"
|
|
.It Li "pane_pid" Ta "" Ta "PID of first process in pane"
|
|
.It Li "pane_pipe" Ta "" Ta "1 if pane is being piped"
|
|
.It Li "pane_right" Ta "" Ta "Right of pane"
|
|
@@ -3910,7 +3911,7 @@ The following variables are available, where appropriate:
|
|
.It Li "pane_start_command" Ta "" Ta "Command pane started with"
|
|
.It Li "pane_synchronized" Ta "" Ta "If pane is synchronized"
|
|
.It Li "pane_tabs" Ta "" Ta "Pane tab positions"
|
|
-.It Li "pane_title" Ta "#T" Ta "Title of pane"
|
|
+.It Li "pane_title" Ta "#T" Ta "Title of pane (can be set by application)"
|
|
.It Li "pane_top" Ta "" Ta "Top of pane"
|
|
.It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane"
|
|
.It Li "pane_width" Ta "" Ta "Width of pane"
|
|
@@ -3924,7 +3925,7 @@ The following variables are available, where appropriate:
|
|
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
|
|
.It Li "session_activity" Ta "" Ta "Time of session last activity"
|
|
.It Li "session_created" Ta "" Ta "Time session created"
|
|
-.It Li "session_format" Ta "" Ta "1 if format is for a session (not assuming the current)"
|
|
+.It Li "session_format" Ta "" Ta "1 if format is for a session"
|
|
.It Li "session_last_attached" Ta "" Ta "Time session last attached"
|
|
.It Li "session_group" Ta "" Ta "Name of session group"
|
|
.It Li "session_group_size" Ta "" Ta "Size of session group"
|
|
@@ -3945,7 +3946,7 @@ The following variables are available, where appropriate:
|
|
.It Li "window_bigger" Ta "" Ta "1 if window is larger than client"
|
|
.It Li "window_end_flag" Ta "" Ta "1 if window has the highest index"
|
|
.It Li "window_flags" Ta "#F" Ta "Window flags"
|
|
-.It Li "window_format" Ta "" Ta "1 if format is for a window (not assuming the current)"
|
|
+.It Li "window_format" Ta "" Ta "1 if format is for a window"
|
|
.It Li "window_height" Ta "" Ta "Height of window"
|
|
.It Li "window_id" Ta "" Ta "Unique window ID"
|
|
.It Li "window_index" Ta "#I" Ta "Index of window"
|
|
diff --git a/tmux.h b/tmux.h
|
|
index d7f3819..0998e29 100644
|
|
--- a/tmux.h
|
|
+++ b/tmux.h
|
|
@@ -699,6 +699,7 @@ struct screen_sel;
|
|
struct screen_titles;
|
|
struct screen {
|
|
char *title;
|
|
+ char *path;
|
|
struct screen_titles *titles;
|
|
|
|
struct grid *grid; /* grid data */
|
|
@@ -2194,6 +2195,7 @@ void screen_reset_tabs(struct screen *);
|
|
void screen_set_cursor_style(struct screen *, u_int);
|
|
void screen_set_cursor_colour(struct screen *, const char *);
|
|
void screen_set_title(struct screen *, const char *);
|
|
+void screen_set_path(struct screen *, const char *);
|
|
void screen_push_title(struct screen *);
|
|
void screen_pop_title(struct screen *);
|
|
void screen_resize(struct screen *, u_int, u_int, int);
|
|
--
|
|
2.27.0
|