From 973de5a704d4858b7626fc7a07865c1ea8f71eac Mon Sep 17 00:00:00 2001 From: jmc Date: Sun, 2 Feb 2014 08:48:48 +0000 Subject: [PATCH 01/10] fix some minor formatting glitches; --- tmux.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmux.1 b/tmux.1 index e0b27b6d..d32a16d2 100644 --- a/tmux.1 +++ b/tmux.1 @@ -783,7 +783,7 @@ With .Fl t , display the log for .Ar target-client . -.Fl I, +.Fl I , .Fl J and .Fl T @@ -2499,7 +2499,7 @@ Display will be passed through .Xr strftime 3 and formats (see -.Sx FORMATS Ns ) +.Sx FORMATS ) will be expanded. It may also contain any of the following special character sequences: .Bl -column "Character pair" "Replaced with" -offset indent From c52548f6fd311e4df3076ba4cc6f6ab8849557ac Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 10 Feb 2014 11:20:41 +0000 Subject: [PATCH 02/10] The last fix to xterm keys meant that some keys such as \033OA were being wrongly treated as partial matches. So both check xterm keys after standard keys and only wildcard the minimum required ('1' to '8'). Problems reported by Ralf Horstmann and Tim van der Molen. --- tty-keys.c | 18 +++++++++--------- xterm-keys.c | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tty-keys.c b/tty-keys.c index 7de5ce59..4492df1e 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -479,6 +479,15 @@ tty_keys_next(struct tty *tty) goto partial_key; } + /* Look for matching key string and return if found. */ + tk = tty_keys_find(tty, buf, len, &size); + if (tk != NULL) { + if (tk->next != NULL) + goto partial_key; + key = tk->key; + goto complete_key; + } + /* Try to parse a key with an xterm-style modifier. */ switch (xterm_keys_find(buf, len, &size, &key)) { case 0: /* found */ @@ -489,15 +498,6 @@ tty_keys_next(struct tty *tty) goto partial_key; } - /* Look for matching key string and return if found. */ - tk = tty_keys_find(tty, buf, len, &size); - if (tk != NULL) { - if (tk->next != NULL) - goto partial_key; - key = tk->key; - goto complete_key; - } - first_key: /* Is this a meta key? */ if (len >= 2 && buf[0] == '\033') { diff --git a/xterm-keys.c b/xterm-keys.c index 9b5a0a21..0e20165b 100644 --- a/xterm-keys.c +++ b/xterm-keys.c @@ -131,7 +131,9 @@ xterm_keys_match(const char *template, const char *buf, size_t len) pos = 0; do { - if (*template != '_' && buf[pos] != *template) + if (*template == '_' && buf[pos] >= '1' && buf[pos] <= '8') + continue; + if (buf[pos] != *template) return (-1); } while (*++template != '\0' && ++pos != len); From 325396046a3906de02b8697377575caaa80546b5 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 12 Feb 2014 20:26:13 +0000 Subject: [PATCH 03/10] Avoid use of uninitialized variable, from Thomas Adam. --- cmd-switch-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-switch-client.c b/cmd-switch-client.c index d0544013..99a1ae64 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -61,7 +61,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct client *c; - struct session *s; + struct session *s = NULL; struct winlink *wl = NULL; struct window *w = NULL; struct window_pane *wp = NULL; From f58721a9e8831f5e47e05fceb7fa5558ddb612ff Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Feb 2014 12:35:58 +0000 Subject: [PATCH 04/10] Make C-j the same as C-m, from Simon Nicolussi. --- mode-key.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mode-key.c b/mode-key.c index 995ccdfa..80a943e4 100644 --- a/mode-key.c +++ b/mode-key.c @@ -153,6 +153,7 @@ const struct mode_key_entry mode_key_vi_edit[] = { { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE }, { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD }, { '\033' /* Escape */, 0, MODEKEYEDIT_SWITCHMODE }, + { '\n', 0, MODEKEYEDIT_ENTER }, { '\r', 0, MODEKEYEDIT_ENTER }, { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE }, { KEYC_DC, 0, MODEKEYEDIT_DELETE }, @@ -176,6 +177,7 @@ const struct mode_key_entry mode_key_vi_edit[] = { { 'X', 1, MODEKEYEDIT_BACKSPACE }, { '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL }, { '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE }, + { '\n', 1, MODEKEYEDIT_ENTER }, { '\r', 1, MODEKEYEDIT_ENTER }, { '^', 1, MODEKEYEDIT_STARTOFLINE }, { 'a', 1, MODEKEYEDIT_SWITCHMODEAPPEND }, @@ -219,6 +221,7 @@ const struct mode_key_entry mode_key_vi_choice[] = { { '\005' /* C-e */, 0, MODEKEYCHOICE_SCROLLDOWN }, { '\006' /* C-f */, 0, MODEKEYCHOICE_PAGEDOWN }, { '\031' /* C-y */, 0, MODEKEYCHOICE_SCROLLUP }, + { '\n', 0, MODEKEYCHOICE_CHOOSE }, { '\r', 0, MODEKEYCHOICE_CHOOSE }, { 'j', 0, MODEKEYCHOICE_DOWN }, { 'k', 0, MODEKEYCHOICE_UP }, @@ -281,6 +284,7 @@ const struct mode_key_entry mode_key_vi_copy[] = { { '\025' /* C-u */, 0, MODEKEYCOPY_HALFPAGEUP }, { '\031' /* C-y */, 0, MODEKEYCOPY_SCROLLUP }, { '\033' /* Escape */, 0, MODEKEYCOPY_CLEARSELECTION }, + { '\n', 0, MODEKEYCOPY_COPYSELECTION }, { '\r', 0, MODEKEYCOPY_COPYSELECTION }, { '^', 0, MODEKEYCOPY_BACKTOINDENTATION }, { 'b', 0, MODEKEYCOPY_PREVIOUSWORD }, @@ -329,6 +333,7 @@ const struct mode_key_entry mode_key_emacs_edit[] = { { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD }, { '\031' /* C-y */, 0, MODEKEYEDIT_PASTE }, { '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL }, + { '\n', 0, MODEKEYEDIT_ENTER }, { '\r', 0, MODEKEYEDIT_ENTER }, { 'b' | KEYC_ESCAPE, 0, MODEKEYEDIT_PREVIOUSWORD }, { 'f' | KEYC_ESCAPE, 0, MODEKEYEDIT_NEXTWORDEND }, @@ -363,6 +368,7 @@ const struct mode_key_entry mode_key_emacs_choice[] = { { '\020' /* C-p */, 0, MODEKEYCHOICE_UP }, { '\026' /* C-v */, 0, MODEKEYCHOICE_PAGEDOWN }, { '\033' /* Escape */, 0, MODEKEYCHOICE_CANCEL }, + { '\n', 0, MODEKEYCHOICE_CHOOSE }, { '\r', 0, MODEKEYCHOICE_CHOOSE }, { 'q', 0, MODEKEYCHOICE_CANCEL }, { 'v' | KEYC_ESCAPE, 0, MODEKEYCHOICE_PAGEUP }, From d0accdba884517c55a842dec59ef2c8db6c208b5 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Feb 2014 12:37:54 +0000 Subject: [PATCH 05/10] Check for NULL session and whatnot in status_replace, from Thomas Adam. --- status.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/status.c b/status.c index e14c1a81..6966aadf 100644 --- a/status.c +++ b/status.c @@ -445,11 +445,11 @@ status_replace(struct client *c, struct session *s, struct winlink *wl, if (fmt == NULL) return (xstrdup("")); - if (s == NULL) + if (s == NULL && c != NULL) s = c->session; - if (wl == NULL) + if (wl == NULL && s != NULL) wl = s->curw; - if (wp == NULL) + if (wp == NULL && wl != NULL) wp = wl->window->active; len = strftime(in, sizeof in, fmt, localtime(&t)); @@ -472,10 +472,14 @@ status_replace(struct client *c, struct session *s, struct winlink *wl, *optr = '\0'; ft = format_create(); - format_client(ft, c); - format_session(ft, s); - format_winlink(ft, s, wl); - format_window_pane(ft, wp); + if (c != NULL) + format_client(ft, c); + if (s != NULL) + format_session(ft, s); + if (s != NULL && wl != NULL) + format_winlink(ft, s, wl); + if (wp != NULL) + format_window_pane(ft, wp); expanded = format_expand(ft, out); format_free(ft); return (expanded); From bfb700cf4159c0d11c3137f1429eb1947f35cb77 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Feb 2014 12:44:45 +0000 Subject: [PATCH 06/10] Do not need to call winlink_find_by_window, from Filip Moc. --- server-window.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/server-window.c b/server-window.c index e82f0e36..39699c37 100644 --- a/server-window.c +++ b/server-window.c @@ -76,7 +76,7 @@ server_window_check_bell(struct session *s, struct winlink *wl) wl->flags |= WINLINK_BELL; if (s->flags & SESSION_UNATTACHED) return (0); - if (s->curw->window == wl->window) + if (s->curw->window == w) w->flags &= ~WINDOW_BELL; visual = options_get_number(&s->options, "visual-bell"); @@ -93,10 +93,8 @@ server_window_check_bell(struct session *s, struct winlink *wl) } if (c->session->curw->window == w) status_message_set(c, "Bell in current window"); - else if (action == BELL_ANY) { - status_message_set(c, "Bell in window %u", - winlink_find_by_window(&s->windows, w)->idx); - } + else if (action == BELL_ANY) + status_message_set(c, "Bell in window %u", wl->idx); } return (1); @@ -110,7 +108,7 @@ server_window_check_activity(struct session *s, struct winlink *wl) struct window *w = wl->window; u_int i; - if (s->curw->window == wl->window) + if (s->curw->window == w) w->flags &= ~WINDOW_ACTIVITY; if (!(w->flags & WINDOW_ACTIVITY) || wl->flags & WINLINK_ACTIVITY) @@ -130,8 +128,7 @@ server_window_check_activity(struct session *s, struct winlink *wl) c = ARRAY_ITEM(&clients, i); if (c == NULL || c->session != s) continue; - status_message_set(c, "Activity in window %u", - winlink_find_by_window(&s->windows, w)->idx); + status_message_set(c, "Activity in window %u", wl->idx); } } @@ -182,8 +179,7 @@ server_window_check_silence(struct session *s, struct winlink *wl) c = ARRAY_ITEM(&clients, i); if (c == NULL || c->session != s) continue; - status_message_set(c, "Silence in window %u", - winlink_find_by_window(&s->windows, w)->idx); + status_message_set(c, "Silence in window %u", wl->idx); } } @@ -225,8 +221,7 @@ server_window_check_content( c = ARRAY_ITEM(&clients, i); if (c == NULL || c->session != s) continue; - status_message_set(c, "Content in window %u", - winlink_find_by_window(&s->windows, w)->idx); + status_message_set(c, "Content in window %u", wl->idx); } } From f835be4bb25f629613bbb7e0195a5c4fb12abf3e Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Feb 2014 13:59:01 +0000 Subject: [PATCH 07/10] Style nit - no space between function name and bracket. --- cmd-load-buffer.c | 2 +- cmd-set-option.c | 2 +- cmd-show-messages.c | 28 ++++++++++++++-------------- grid.c | 2 +- server-client.c | 10 +++++----- server-fn.c | 6 +++--- status.c | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c index 85595285..eb6e0d0c 100644 --- a/cmd-load-buffer.c +++ b/cmd-load-buffer.c @@ -72,7 +72,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq) buffer_ptr = xmalloc(sizeof *buffer_ptr); *buffer_ptr = buffer; - error = server_set_stdin_callback (c, cmd_load_buffer_callback, + error = server_set_stdin_callback(c, cmd_load_buffer_callback, buffer_ptr, &cause); if (error != 0) { cmdq_error(cmdq, "%s: %s", path, cause); diff --git a/cmd-set-option.c b/cmd-set-option.c index b661913f..046bebd6 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -172,7 +172,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq) } /* Start or stop timers when automatic-rename changed. */ - if (strcmp (oe->name, "automatic-rename") == 0) { + if (strcmp(oe->name, "automatic-rename") == 0) { for (i = 0; i < ARRAY_LENGTH(&windows); i++) { if ((w = ARRAY_ITEM(&windows, i)) == NULL) continue; diff --git a/cmd-show-messages.c b/cmd-show-messages.c index a3938e0a..45358fde 100644 --- a/cmd-show-messages.c +++ b/cmd-show-messages.c @@ -49,12 +49,12 @@ const struct cmd_entry cmd_server_info_entry = { cmd_show_messages_exec }; -void cmd_show_messages_server (struct cmd_q *); -void cmd_show_messages_terminals (struct cmd_q *); -void cmd_show_messages_jobs (struct cmd_q *); +void cmd_show_messages_server(struct cmd_q *); +void cmd_show_messages_terminals(struct cmd_q *); +void cmd_show_messages_jobs(struct cmd_q *); void -cmd_show_messages_server (struct cmd_q *cmdq) +cmd_show_messages_server(struct cmd_q *cmdq) { char *tim; @@ -68,7 +68,7 @@ cmd_show_messages_server (struct cmd_q *cmdq) } void -cmd_show_messages_terminals (struct cmd_q *cmdq) +cmd_show_messages_terminals(struct cmd_q *cmdq) { struct tty_term *term; const struct tty_term_code_entry *ent; @@ -111,7 +111,7 @@ cmd_show_messages_terminals (struct cmd_q *cmdq) } void -cmd_show_messages_jobs (struct cmd_q *cmdq) +cmd_show_messages_jobs(struct cmd_q *cmdq) { struct job *job; u_int n; @@ -136,20 +136,20 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_q *cmdq) int done; done = 0; - if (args_has (args, 'I') || self->entry == &cmd_server_info_entry) { - cmd_show_messages_server (cmdq); + if (args_has(args, 'I') || self->entry == &cmd_server_info_entry) { + cmd_show_messages_server(cmdq); done = 1; } - if (args_has (args, 'T') || self->entry == &cmd_server_info_entry) { + if (args_has(args, 'T') || self->entry == &cmd_server_info_entry) { if (done) - cmdq_print (cmdq, "%s", ""); - cmd_show_messages_terminals (cmdq); + cmdq_print(cmdq, "%s", ""); + cmd_show_messages_terminals(cmdq); done = 1; } - if (args_has (args, 'J') || self->entry == &cmd_server_info_entry) { + if (args_has(args, 'J') || self->entry == &cmd_server_info_entry) { if (done) - cmdq_print (cmdq, "%s", ""); - cmd_show_messages_jobs (cmdq); + cmdq_print(cmdq, "%s", ""); + cmd_show_messages_jobs(cmdq); done = 1; } if (done) diff --git a/grid.c b/grid.c index fb838adf..7fb15dc3 100644 --- a/grid.c +++ b/grid.c @@ -749,7 +749,7 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl, dst_gl->flags |= GRID_LINE_WRAPPED; /* Copy the data. */ - memcpy (&dst_gl->celldata[0], &src_gl->celldata[offset], + memcpy(&dst_gl->celldata[0], &src_gl->celldata[offset], to_copy * sizeof dst_gl->celldata[0]); /* Move offset and reduce old line size. */ diff --git a/server-client.c b/server-client.c index 5a6cb7d9..5326f256 100644 --- a/server-client.c +++ b/server-client.c @@ -68,9 +68,9 @@ server_client_create(int fd) c->cmdq = cmdq_new(c); c->cmdq->client_exit = 1; - c->stdin_data = evbuffer_new (); - c->stdout_data = evbuffer_new (); - c->stderr_data = evbuffer_new (); + c->stdin_data = evbuffer_new(); + c->stdout_data = evbuffer_new(); + c->stderr_data = evbuffer_new(); c->tty.fd = -1; c->title = NULL; @@ -123,7 +123,7 @@ server_client_open(struct client *c, struct session *s, char **cause) return (0); if (!(c->flags & CLIENT_TERMINAL)) { - *cause = xstrdup ("not a terminal"); + *cause = xstrdup("not a terminal"); return (-1); } @@ -174,7 +174,7 @@ server_client_lost(struct client *c) evtimer_del(&c->identify_timer); free(c->message_string); - if (event_initialized (&c->message_timer)) + if (event_initialized(&c->message_timer)) evtimer_del(&c->message_timer); for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) { msg = &ARRAY_ITEM(&c->message_log, i); diff --git a/server-fn.c b/server-fn.c index d0747628..f585cb71 100644 --- a/server-fn.c +++ b/server-fn.c @@ -454,7 +454,7 @@ server_destroy_session(struct session *s) } void -server_check_unattached (void) +server_check_unattached(void) { struct session *s; @@ -480,7 +480,7 @@ server_set_identify(struct client *c) tv.tv_sec = delay / 1000; tv.tv_usec = (delay % 1000) * 1000L; - if (event_initialized (&c->identify_timer)) + if (event_initialized(&c->identify_timer)) evtimer_del(&c->identify_timer); evtimer_set(&c->identify_timer, server_callback_identify, c); evtimer_add(&c->identify_timer, &tv); @@ -592,7 +592,7 @@ server_set_stdin_callback(struct client *c, void (*cb)(struct client *, int, c->references++; if (c->stdin_closed) - c->stdin_callback (c, 1, c->stdin_callback_data); + c->stdin_callback(c, 1, c->stdin_callback_data); server_write_client(c, MSG_STDIN, NULL, 0); diff --git a/status.c b/status.c index 6966aadf..84589427 100644 --- a/status.c +++ b/status.c @@ -690,7 +690,7 @@ status_message_set(struct client *c, const char *fmt, ...) tv.tv_sec = delay / 1000; tv.tv_usec = (delay % 1000) * 1000L; - if (event_initialized (&c->message_timer)) + if (event_initialized(&c->message_timer)) evtimer_del(&c->message_timer); evtimer_set(&c->message_timer, status_message_callback, c); evtimer_add(&c->message_timer, &tv); From e9d32f901ac86986943cac3b391442ae5bce883f Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Feb 2014 14:00:18 +0000 Subject: [PATCH 08/10] Make status-interval of zero work as indented. --- server-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-client.c b/server-client.c index 5326f256..c2903a0d 100644 --- a/server-client.c +++ b/server-client.c @@ -280,7 +280,7 @@ server_client_status_timer(void) interval = options_get_number(&s->options, "status-interval"); difference = tv.tv_sec - c->status_timer.tv_sec; - if (difference >= interval) { + if (interval != 0 && difference >= interval) { status_update_jobs(c); c->flags |= CLIENT_STATUS; } From f2e54e1e2ff5a1902cdab4db50a503541186638e Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 14 Feb 2014 14:37:08 +0000 Subject: [PATCH 09/10] If the terminfo entry has colors#256, assume that setaf and setab work and use them for the 256 colour set. If the terminfo entry doesn't have colors#256 and the user gives -2 to the client, use a \033[38;5;Xm sequence as before. Should allow fbterm to work with it's weird setaf and setab. --- tty.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tty.c b/tty.c index f5a85992..20b7070a 100644 --- a/tty.c +++ b/tty.c @@ -1581,13 +1581,29 @@ tty_try_256(struct tty *tty, u_char colour, const char *type) { char s[32]; - if (!(tty->term->flags & TERM_256COLOURS) && - !(tty->term_flags & TERM_256COLOURS)) - return (-1); + /* + * If the terminfo entry has 256 colours, assume that setaf and setab + * work correctly. + */ + if (tty->term->flags & TERM_256COLOURS) { + if (*type == '3') + tty_putcode1(tty, TTYC_SETAF, colour); + else + tty_putcode1(tty, TTYC_SETAB, colour); + return (0); + } - xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour); - tty_puts(tty, s); - return (0); + /* + * If the user has specified -2 to the client, setaf and setab may not + * work, so send the usual sequence. + */ + if (tty->term_flags & TERM_256COLOURS) { + xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour); + tty_puts(tty, s); + return (0); + } + + return (-1); } void From 81db6bab91309e7cb42628048408c10504522a48 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 16 Feb 2014 12:45:17 +0000 Subject: [PATCH 10/10] Leftovers from removing 88 colour support, from Theo Buehler. --- tmux.1 | 6 +++--- tmux.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tmux.1 b/tmux.1 index d32a16d2..c0f04094 100644 --- a/tmux.1 +++ b/tmux.1 @@ -23,7 +23,7 @@ .Sh SYNOPSIS .Nm tmux .Bk -words -.Op Fl 28lCquv +.Op Fl 2lCquv .Op Fl c Ar shell-command .Op Fl f Ar file .Op Fl L Ar socket-name @@ -2637,9 +2637,9 @@ The terminal entry value is passed through before interpretation. The default value forcibly corrects the .Ql colors -entry for terminals which support 88 or 256 colours: +entry for terminals which support 256 colours: .Bd -literal -offset indent -"*88col*:colors=88,*256col*:colors=256,xterm*:XT" +"*256col*:colors=256,xterm*:XT" .Ed .It Ic update-environment Ar variables Set a space-separated string containing a list of environment variables to be diff --git a/tmux.c b/tmux.c index d4848396..6de96ce1 100644 --- a/tmux.c +++ b/tmux.c @@ -57,7 +57,7 @@ __dead void usage(void) { fprintf(stderr, - "usage: %s [-28lquv] [-c shell-command] [-f file] [-L socket-name]\n" + "usage: %s [-2lquv] [-c shell-command] [-f file] [-L socket-name]\n" " [-S socket-path] [command [flags]]\n", __progname); exit(1);