From c124d74fd27da4a8b77f8efaeb4c8feb8f39b7ed Mon Sep 17 00:00:00 2001 From: cache-miss Date: Wed, 10 Apr 2024 09:18:59 +0800 Subject: [PATCH] add new option `allow-rename-pane` to control whether pane-title should set by escape sequence --- cmd-select-pane.c | 1 - input.c | 3 ++- options-table.c | 8 ++++++++ tmux.h | 1 - 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd-select-pane.c b/cmd-select-pane.c index 6f4f6c5c..135729f5 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -212,7 +212,6 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) if (args_has(args, 'T')) { title = format_single_from_target(item, args_get(args, 'T')); if (screen_set_title(&wp->base, title)) { - wp->base.ignore_osc_2 = 1; notify_pane("pane-title-changed", wp); server_redraw_window_borders(wp->window); server_status_window(wp->window); diff --git a/input.c b/input.c index 2e453961..cc0d9a31 100644 --- a/input.c +++ b/input.c @@ -2372,7 +2372,8 @@ input_exit_osc(struct input_ctx *ictx) switch (option) { case 0: case 2: - if ( sctx->s->ignore_osc_2 == 0 && screen_set_title(sctx->s, p) && wp != NULL) { + if (options_get_number(ictx->wp->options, "allow-rename-pane") == 1 && + screen_set_title(sctx->s, p) && wp != NULL) { notify_pane("pane-title-changed", wp); server_redraw_window_borders(wp->window); server_status_window(wp->window); diff --git a/options-table.c b/options-table.c index 15018226..be61bc8c 100644 --- a/options-table.c +++ b/options-table.c @@ -875,6 +875,14 @@ const struct options_table_entry options_table[] = { "to rename windows." }, + { .name = "allow-rename-pane", + .type = OPTIONS_TABLE_FLAG, + .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, + .default_num = 0, + .text = "Whether applications are allowed to use the escape sequence " + "to rename pane." + }, + { .name = "alternate-screen", .type = OPTIONS_TABLE_FLAG, .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, diff --git a/tmux.h b/tmux.h index 95159186..a052b799 100644 --- a/tmux.h +++ b/tmux.h @@ -877,7 +877,6 @@ struct screen_sel; struct screen_titles; struct screen { char *title; - int ignore_osc_2; char *path; struct screen_titles *titles;