From b95e5827c1d2af3cc1fe1f9feda8edbc230ebb18 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 29 May 2017 20:41:29 +0000 Subject: [PATCH 1/2] Store a copy of the old status line, will be needed soon for new choose mode. --- options-table.c | 8 ++++---- server-client.c | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/options-table.c b/options-table.c index 8af4d934..4d646f73 100644 --- a/options-table.c +++ b/options-table.c @@ -125,7 +125,7 @@ const struct options_table_entry options_table[] = { .type = OPTIONS_TABLE_ARRAY, .scope = OPTIONS_TABLE_SERVER, .default_str = "xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007" - ":Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007" + ":Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007" ":Ss=\\E[%p1%d q:Se=\\E[2 q,screen*:XT", .separator = "," }, @@ -485,7 +485,7 @@ const struct options_table_entry options_table[] = { .type = OPTIONS_TABLE_ARRAY, .scope = OPTIONS_TABLE_SESSION, .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID " - "SSH_CONNECTION WINDOWID XAUTHORITY" + "SSH_CONNECTION WINDOWID XAUTHORITY" }, { .name = "visual-activity", @@ -540,7 +540,7 @@ const struct options_table_entry options_table[] = { .type = OPTIONS_TABLE_STRING, .scope = OPTIONS_TABLE_WINDOW, .default_str = "#{?pane_in_mode,[tmux],#{pane_current_command}}" - "#{?pane_dead,[dead],}" + "#{?pane_dead,[dead],}" }, { .name = "clock-mode-colour", @@ -698,7 +698,7 @@ const struct options_table_entry options_table[] = { .type = OPTIONS_TABLE_STRING, .scope = OPTIONS_TABLE_WINDOW, .default_str = "#{?pane_active,#[reverse],}#{pane_index}#[default] " - "\"#{pane_title}\"" + "\"#{pane_title}\"" }, { .name = "pane-border-status", diff --git a/server-client.c b/server-client.c index 18e9d935..8de4f6bd 100644 --- a/server-client.c +++ b/server-client.c @@ -275,6 +275,10 @@ server_client_lost(struct client *c) if (event_initialized(&c->status_timer)) evtimer_del(&c->status_timer); screen_free(&c->status); + if (c->old_status != NULL) { + screen_free(c->old_status); + free(c->old_status); + } free(c->title); free((void *)c->cwd); From 64552ae304109c00a47e4f62875f6e1ce707e099 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 29 May 2017 20:42:53 +0000 Subject: [PATCH 2/2] Add a flag to stop the prompt input being expanded. --- status.c | 28 ++++++++++++++++++++++++++-- tmux.h | 3 +++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/status.c b/status.c index 1833d459..b7d24715 100644 --- a/status.c +++ b/status.c @@ -301,6 +301,13 @@ status_redraw(struct client *c) size_t llen, rlen, seplen; int larrow, rarrow; + /* Delete the saved status line, if any. */ + if (c->old_status != NULL) { + screen_free(c->old_status); + free(c->old_status); + c->old_status = NULL; + } + /* No status line? */ if (c->tty.sy == 0 || !options_get_number(s->options, "status")) return (1); @@ -568,6 +575,12 @@ status_message_set(struct client *c, const char *fmt, ...) status_message_clear(c); + if (c->old_status == NULL) { + c->old_status = xmalloc(sizeof *c->old_status); + memcpy(c->old_status, &c->status, sizeof *c->old_status); + screen_init(&c->status, c->tty.sx, 1, 0); + } + va_start(ap, fmt); xvasprintf(&c->message_string, fmt, ap); va_end(ap); @@ -664,13 +677,24 @@ status_prompt_set(struct client *c, const char *msg, const char *input, ft = format_create(c, NULL, FORMAT_NONE, 0); format_defaults(ft, c, NULL, NULL, NULL); - t = time(NULL); - tmp = format_expand_time(ft, input, t); + + if (input == NULL) + input = ""; + if (flags & PROMPT_NOFORMAT) + tmp = xstrdup(input); + else + tmp = format_expand_time(ft, input, t); status_message_clear(c); status_prompt_clear(c); + if (c->old_status == NULL) { + c->old_status = xmalloc(sizeof *c->old_status); + memcpy(c->old_status, &c->status, sizeof *c->old_status); + screen_init(&c->status, c->tty.sx, 1, 0); + } + c->prompt_string = format_expand_time(ft, msg, t); c->prompt_buffer = utf8_fromcstr(tmp); diff --git a/tmux.h b/tmux.h index 9c25bcc9..3f62683f 100644 --- a/tmux.h +++ b/tmux.h @@ -1328,6 +1328,8 @@ struct client { struct event status_timer; struct screen status; + struct screen *old_status; + #define CLIENT_TERMINAL 0x1 #define CLIENT_LOGIN 0x2 #define CLIENT_EXIT 0x4 @@ -1376,6 +1378,7 @@ struct client { #define PROMPT_SINGLE 0x1 #define PROMPT_NUMERIC 0x2 #define PROMPT_INCREMENTAL 0x4 +#define PROMPT_NOFORMAT 0x8 int prompt_flags; struct session *session;