From 982354765bc6f0bfb225d7c1f96e5b73f9880533 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 27 Mar 2013 11:17:12 +0000 Subject: [PATCH 01/36] Remove tmux's (already minimal) 88 colour support. Such terminals are few and unnecessary. --- colour.c | 26 -------------------------- options-table.c | 2 +- server-client.c | 2 -- tmux.h | 6 ++---- tty-term.c | 4 +--- tty.c | 32 ++++---------------------------- 6 files changed, 8 insertions(+), 64 deletions(-) diff --git a/colour.c b/colour.c index ff492687..9e90596f 100644 --- a/colour.c +++ b/colour.c @@ -287,29 +287,3 @@ colour_256to16(u_char c) return (table[c]); } - -/* Convert 256 colour palette to 88. */ -u_char -colour_256to88(u_char c) -{ - static const u_char table[256] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 17, 18, 18, 19, 20, 21, 21, 22, 22, 23, 20, 21, 21, 22, - 22, 23, 24, 25, 25, 26, 26, 27, 24, 25, 25, 26, 26, 27, 28, 29, - 29, 30, 30, 31, 32, 33, 33, 34, 34, 35, 36, 37, 37, 38, 38, 39, - 36, 37, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43, 40, 41, 41, 42, - 42, 43, 44, 45, 45, 46, 46, 47, 32, 33, 33, 34, 34, 35, 36, 37, - 37, 38, 38, 39, 36, 37, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43, - 40, 41, 41, 42, 42, 43, 44, 45, 45, 46, 46, 47, 48, 49, 49, 50, - 50, 51, 52, 53, 53, 54, 54, 55, 52, 53, 53, 54, 54, 55, 56, 57, - 57, 58, 58, 59, 56, 57, 57, 58, 58, 59, 60, 61, 61, 62, 62, 63, - 48, 49, 49, 50, 50, 51, 52, 53, 53, 54, 54, 55, 52, 53, 53, 54, - 54, 55, 56, 57, 57, 58, 58, 59, 56, 57, 57, 58, 58, 59, 60, 61, - 61, 62, 62, 63, 64, 65, 65, 66, 66, 67, 68, 69, 69, 70, 70, 71, - 68, 69, 69, 70, 70, 71, 72, 73, 73, 74, 74, 75, 72, 73, 73, 74, - 74, 75, 76, 77, 77, 78, 78, 79, 0, 0, 80, 80, 80, 81, 81, 81, - 82, 82, 82, 83, 83, 83, 84, 84, 84, 85, 85, 85, 86, 86, 86, 87 - }; - - return (table[c]); -} diff --git a/options-table.c b/options-table.c index ae711882..c4ada1f2 100644 --- a/options-table.c +++ b/options-table.c @@ -414,7 +414,7 @@ const struct options_table_entry session_options_table[] = { { .name = "terminal-overrides", .type = OPTIONS_TABLE_STRING, - .default_str = "*88col*:colors=88,*256col*:colors=256" + .default_str = "*256col*:colors=256" ",xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007" ":Cc=\\E]12;%p1%s\\007:Cr=\\E]112\\007" ":Cs=\\E[%p1%d q:Csr=\\E[2 q,screen*:XT" diff --git a/server-client.c b/server-client.c index f61912bc..ac4ecf29 100644 --- a/server-client.c +++ b/server-client.c @@ -981,8 +981,6 @@ server_client_msg_identify( c->tty.flags |= TTY_UTF8; if (data->flags & IDENTIFY_256COLOURS) c->tty.term_flags |= TERM_256COLOURS; - else if (data->flags & IDENTIFY_88COLOURS) - c->tty.term_flags |= TERM_88COLOURS; tty_resize(&c->tty); diff --git a/tmux.h b/tmux.h index 10da2bee..053b574e 100644 --- a/tmux.h +++ b/tmux.h @@ -481,7 +481,7 @@ struct msg_identify_data { #define IDENTIFY_UTF8 0x1 #define IDENTIFY_256COLOURS 0x2 -#define IDENTIFY_88COLOURS 0x4 +/* 0x4 unused */ #define IDENTIFY_CONTROL 0x8 #define IDENTIFY_TERMIOS 0x10 int flags; @@ -1141,8 +1141,7 @@ struct tty_term { struct tty_code codes[NTTYCODE]; #define TERM_256COLOURS 0x1 -#define TERM_88COLOURS 0x2 -#define TERM_EARLYWRAP 0x4 +#define TERM_EARLYWRAP 0x2 int flags; LIST_ENTRY(tty_term) entry; @@ -1986,7 +1985,6 @@ void colour_set_bg(struct grid_cell *, int); const char *colour_tostring(int); int colour_fromstring(const char *); u_char colour_256to16(u_char); -u_char colour_256to88(u_char); /* attributes.c */ const char *attributes_tostring(u_char); diff --git a/tty-term.c b/tty-term.c index c827a444..254569f6 100644 --- a/tty-term.c +++ b/tty-term.c @@ -404,11 +404,9 @@ tty_term_find(char *name, int fd, const char *overrides, char **cause) goto error; } - /* Figure out if we have 256 or 88 colours. */ + /* Figure out if we have 256. */ if (tty_term_number(term, TTYC_COLORS) == 256) term->flags |= TERM_256COLOURS; - if (tty_term_number(term, TTYC_COLORS) == 88) - term->flags |= TERM_88COLOURS; /* * Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1 diff --git a/tty.c b/tty.c index 75a2f657..bffddac6 100644 --- a/tty.c +++ b/tty.c @@ -35,7 +35,6 @@ void tty_read_callback(struct bufferevent *, void *); void tty_error_callback(struct bufferevent *, short, void *); int tty_try_256(struct tty *, u_char, const char *); -int tty_try_88(struct tty *, u_char, const char *); void tty_colours(struct tty *, const struct grid_cell *); void tty_check_fg(struct tty *, struct grid_cell *); @@ -1446,9 +1445,7 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc) /* Is this a 256-colour colour? */ if (gc->flags & GRID_FLAG_FG256) { /* And not a 256 colour mode? */ - if (!(tty->term->flags & TERM_88COLOURS) && - !(tty->term_flags & TERM_88COLOURS) && - !(tty->term->flags & TERM_256COLOURS) && + if (!(tty->term->flags & TERM_256COLOURS) && !(tty->term_flags & TERM_256COLOURS)) { gc->fg = colour_256to16(gc->fg); if (gc->fg & 8) { @@ -1481,9 +1478,7 @@ tty_check_bg(struct tty *tty, struct grid_cell *gc) * palette. Bold background doesn't exist portably, so just * discard the bold bit if set. */ - if (!(tty->term->flags & TERM_88COLOURS) && - !(tty->term_flags & TERM_88COLOURS) && - !(tty->term->flags & TERM_256COLOURS) && + if (!(tty->term->flags & TERM_256COLOURS) && !(tty->term_flags & TERM_256COLOURS)) { gc->bg = colour_256to16(gc->bg); if (gc->bg & 8) @@ -1511,11 +1506,9 @@ tty_colours_fg(struct tty *tty, const struct grid_cell *gc) /* Is this a 256-colour colour? */ if (gc->flags & GRID_FLAG_FG256) { - /* Try as 256 colours or translating to 88. */ + /* Try as 256 colours. */ if (tty_try_256(tty, fg, "38") == 0) goto save_fg; - if (tty_try_88(tty, fg, "38") == 0) - goto save_fg; /* Else already handled by tty_check_fg. */ return; } @@ -1546,11 +1539,9 @@ tty_colours_bg(struct tty *tty, const struct grid_cell *gc) /* Is this a 256-colour colour? */ if (gc->flags & GRID_FLAG_BG256) { - /* Try as 256 colours or translating to 88. */ + /* Try as 256 colours. */ if (tty_try_256(tty, bg, "48") == 0) goto save_bg; - if (tty_try_88(tty, bg, "48") == 0) - goto save_bg; /* Else already handled by tty_check_bg. */ return; } @@ -1591,21 +1582,6 @@ tty_try_256(struct tty *tty, u_char colour, const char *type) return (0); } -int -tty_try_88(struct tty *tty, u_char colour, const char *type) -{ - char s[32]; - - if (!(tty->term->flags & TERM_88COLOURS) && - !(tty->term_flags & TERM_88COLOURS)) - return (-1); - colour = colour_256to88(colour); - - xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour); - tty_puts(tty, s); - return (0); -} - void tty_bell(struct tty *tty) { From 5e4d9a3197a229ecb30d51f5b7e6756ef31dc1d2 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 27 Mar 2013 11:19:19 +0000 Subject: [PATCH 02/36] Move the cursor back into the last column on CUU/CUD to match xterm behaviour. From George Nachman. --- screen-write.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/screen-write.c b/screen-write.c index 348065c6..c0935c95 100644 --- a/screen-write.c +++ b/screen-write.c @@ -488,6 +488,8 @@ screen_write_cursorup(struct screen_write_ctx *ctx, u_int ny) if (ny > s->cy - s->rupper) ny = s->cy - s->rupper; } + if (s->cx == screen_size_x(s)) + s->cx--; if (ny == 0) return; @@ -512,6 +514,8 @@ screen_write_cursordown(struct screen_write_ctx *ctx, u_int ny) if (ny > s->rlower - s->cy) ny = s->rlower - s->cy; } + if (s->cx == screen_size_x(s)) + s->cx--; if (ny == 0) return; From 7f636587098593c6c0efd3feaecb970aa7170116 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 27 Mar 2013 11:24:18 +0000 Subject: [PATCH 03/36] Add TMUX_TMPDIR variable to put the socket directory outside TMPDIR. From Ben Boeckel. --- tmux.1 | 13 +++++-------- tmux.c | 15 ++++++--------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/tmux.1 b/tmux.1 index 0dc68bfe..9b1488fc 100644 --- a/tmux.1 +++ b/tmux.1 @@ -98,10 +98,6 @@ The options are as follows: Force .Nm to assume the terminal supports 256 colours. -.It Fl 8 -Like -.Fl 2 , -but indicates that the terminal supports 88 colours. .It Fl C Start in control mode. Given twice @@ -145,11 +141,12 @@ session created, and continues to process the rest of the configuration file. .It Fl L Ar socket-name .Nm stores the server socket in a directory under -.Pa /tmp -(or +.Ev TMUX_TMPDIR , .Ev TMPDIR -if set); -the default socket is named +if it is unset, or +.Pa /tmp +if both are unset. +The default socket is named .Em default . This option allows a different socket name to be specified, allowing several independent diff --git a/tmux.c b/tmux.c index 368562f8..1f4057dc 100644 --- a/tmux.c +++ b/tmux.c @@ -164,10 +164,12 @@ makesocketpath(const char *label) u_int uid; uid = getuid(); - if ((s = getenv("TMPDIR")) == NULL || *s == '\0') - xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid); - else + if ((s = getenv("TMUX_TMPDIR")) != NULL && *s != '\0') + xsnprintf(base, sizeof base, "%s/", s); + else if ((s = getenv("TMPDIR")) != NULL && *s != '\0') xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid); + else + xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid); if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) return (NULL); @@ -244,15 +246,10 @@ main(int argc, char **argv) quiet = flags = 0; label = path = NULL; login_shell = (**argv == '-'); - while ((opt = getopt(argc, argv, "28c:Cdf:lL:qS:uUv")) != -1) { + while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUv")) != -1) { switch (opt) { case '2': flags |= IDENTIFY_256COLOURS; - flags &= ~IDENTIFY_88COLOURS; - break; - case '8': - flags |= IDENTIFY_88COLOURS; - flags &= ~IDENTIFY_256COLOURS; break; case 'c': free(shell_cmd); From 66afcf5be092ed0ab86d1d4059426823e72c63d5 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 28 Mar 2013 15:07:42 +0000 Subject: [PATCH 04/36] Make copy-mode -u still scroll up if already in copy mode, handy for people who bind it with -n. --- cmd-copy-mode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index 59b5a9e5..883a9376 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -54,9 +54,11 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq) if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL) return (CMD_RETURN_ERROR); - if (window_pane_set_mode(wp, &window_copy_mode) != 0) - return (CMD_RETURN_NORMAL); - window_copy_init_from_pane(wp); + if (wp->mode != &window_copy_mode) { + if (window_pane_set_mode(wp, &window_copy_mode) != 0) + return (CMD_RETURN_NORMAL); + window_copy_init_from_pane(wp); + } if (wp->mode == &window_copy_mode && args_has(self->args, 'u')) window_copy_pageup(wp); From 738e789dbd7712ab94073036cf4e903abc68447f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 28 Mar 2013 15:08:12 +0000 Subject: [PATCH 05/36] If -s to swap-pane is not given, use the current pane. --- cmd-swap-pane.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c index e7ea6242..e6b46d67 100644 --- a/cmd-swap-pane.c +++ b/cmd-swap-pane.c @@ -75,8 +75,12 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq) src_wp = TAILQ_PREV(dst_wp, window_panes, entry); if (src_wp == NULL) src_wp = TAILQ_LAST(&dst_w->panes, window_panes); - } else - return (CMD_RETURN_NORMAL); + } else { + src_wl = cmd_find_pane(cmdq, NULL, NULL, &src_wp); + if (src_wl == NULL) + return (CMD_RETURN_ERROR); + src_w = src_wl->window; + } } else { src_wl = cmd_find_pane(cmdq, args_get(args, 's'), NULL, &src_wp); if (src_wl == NULL) From 69c86379e39476013205fce627951dd733d647b3 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 10 Apr 2013 11:51:16 +0000 Subject: [PATCH 06/36] Remove some code not needed on OpenBSD. --- server-client.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/server-client.c b/server-client.c index ac4ecf29..6cacefa7 100644 --- a/server-client.c +++ b/server-client.c @@ -534,18 +534,8 @@ server_client_check_resize(struct window_pane *wp) ws.ws_col = wp->sx; ws.ws_row = wp->sy; - if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) { -#ifdef __sun - /* - * Some versions of Solaris apparently can return an error when - * resizing; don't know why this happens, can't reproduce on - * other platforms and ignoring it doesn't seem to cause any - * issues. - */ - if (errno != EINVAL) -#endif + if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) fatal("ioctl failed"); - } wp->flags &= ~PANE_RESIZE; } From e312db140868754358d40ec17595327a8fbbf180 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 10 Apr 2013 13:04:19 +0100 Subject: [PATCH 07/36] Add wait-for to tmux.vim from Ben Boeckel. --- examples/tmux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tmux.vim b/examples/tmux.vim index 076115c1..e85f8ff6 100644 --- a/examples/tmux.vim +++ b/examples/tmux.vim @@ -56,7 +56,7 @@ syn keyword tmuxCmds \ list-buffers loadb load-buffer pasteb paste-buffer saveb save-buffer \ setb set-buffer showb show-buffer \ clock-mode if[-shell] lock[-server] run[-shell] server-info info - \ choose-list + \ choose-list wait-for syn keyword tmuxOptsSet \ buffer-limit escape-time exit-unattached exit-unattached quiet From 20f0d917beb0f774af2628ed7efe2a33cf59f42a Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 10 Apr 2013 12:07:18 +0000 Subject: [PATCH 08/36] Missed -o from set-window-option, from Ben Boeckel. --- tmux.1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tmux.1 b/tmux.1 index 9b1488fc..b38b43bb 100644 --- a/tmux.1 +++ b/tmux.1 @@ -2645,7 +2645,7 @@ The default is .Ql \ -_@ . .El .It Xo Ic set-window-option -.Op Fl agqu +.Op Fl agoqu .Op Fl t Ar target-window .Ar option Ar value .Xc @@ -2654,6 +2654,7 @@ Set a window option. The .Fl a , .Fl g , +.Fl o , .Fl q and .Fl u From 7ada64d5f8a0df39229c41b992c0ee8ac9f0a1d7 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 10 Apr 2013 12:15:36 +0000 Subject: [PATCH 09/36] Fix bug where end guard in control mode was not printed after session destroyed, from George Nachman. --- cmd-queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-queue.c b/cmd-queue.c index b1c0a4eb..a64d332c 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -158,7 +158,7 @@ cmdq_guard(struct cmd_q *cmdq, const char *guard) { struct client *c = cmdq->client; - if (c == NULL || c->session == NULL) + if (c == NULL) return 0; if (!(c->flags & CLIENT_CONTROL)) return 0; From 9fcda95a6f55f017536cdf24366754a2304c1059 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 10 Apr 2013 12:20:35 +0000 Subject: [PATCH 10/36] Set EV_WRITE for jobs or run/if-shell jobs can hang. From Chris Johnsen. --- job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/job.c b/job.c index b76b3345..291e000e 100644 --- a/job.c +++ b/job.c @@ -109,7 +109,7 @@ job_run(const char *cmd, struct session *s, job->event = bufferevent_new(job->fd, NULL, job_write_callback, job_callback, job); - bufferevent_enable(job->event, EV_READ); + bufferevent_enable(job->event, EV_READ|EV_WRITE); log_debug("run job %p: %s, pid %ld", job, job->cmd, (long) job->pid); return (job); From cbee283c26968304b473e2191d2bb5f52208b58d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 11 Apr 2013 07:27:27 +0000 Subject: [PATCH 11/36] Send an SGR0 after turning on modifyOtherKeys to fix Terminal.app which treats \033[>4;1m and \033[4;1m (bold+underline). Reported & tested by otto@. --- tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tty.c b/tty.c index bffddac6..74988eb3 100644 --- a/tty.c +++ b/tty.c @@ -220,7 +220,7 @@ tty_start_tty(struct tty *tty) tty_puts(tty, "\033[?1000l\033[?1006l\033[?1005l"); if (tty_term_has(tty->term, TTYC_XT)) - tty_puts(tty, "\033[c\033[>4;1m\033[?1004h"); + tty_puts(tty, "\033[c\033[>4;1m\033[?1004h\033[m"); tty->cx = UINT_MAX; tty->cy = UINT_MAX; @@ -283,7 +283,7 @@ tty_stop_tty(struct tty *tty) tty_raw(tty, "\033[?1000l\033[?1006l\033[?1005l"); if (tty_term_has(tty->term, TTYC_XT)) - tty_raw(tty, "\033[>4m\033[?1004l"); + tty_raw(tty, "\033[>4m\033[?1004l\033[m"); tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP)); From 4ccb2e2c218a10a8039ca801231aaf09b6bf3bce Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 11 Apr 2013 22:45:05 +0100 Subject: [PATCH 12/36] TODO tweaks. --- TODO | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index d3e3b46b..92b60a9a 100644 --- a/TODO +++ b/TODO @@ -47,7 +47,7 @@ - hooks! - warts on current naming: - * display-time but message-fg/bg/attr + * display-time but message-fg/bg/attr * list-* vs show-* * server-info * split-window -> split-pane?? @@ -55,6 +55,7 @@ - way to keep a job running just read its last line of output for #() - better UTF-8 support: + * #22T can split in the middle of UTF-8 characters! * window names and titles * message display * prompt input From 7f9b225cc269211b86a4c4d2168146c217d63118 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 11 Apr 2013 21:52:18 +0000 Subject: [PATCH 13/36] Call setlocale(LC_TIME) at startup. --- clock.c | 15 +++++++++++---- tmux.c | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/clock.c b/clock.c index 00d818be..283a4a1e 100644 --- a/clock.c +++ b/clock.c @@ -103,13 +103,20 @@ clock_draw(struct screen_write_ctx *ctx, int colour, int style) struct grid_cell gc; char tim[64], *ptr; time_t t; + struct tm *tm; u_int i, j, x, y, idx; t = time(NULL); - if (style == 0) - strftime(tim, sizeof tim, "%l:%M %p", localtime(&t)); - else - strftime(tim, sizeof tim, "%H:%M", localtime(&t)); + tm = localtime(&t); + if (style == 0) { + strftime(tim, sizeof tim, "%l:%M ", localtime(&t)); + if (tm->tm_hour >= 12) + strlcat(tim, "PM", sizeof tim); + else + strlcat(tim, "AM", sizeof tim); + } else + strftime(tim, sizeof tim, "%H:%M", tm); + screen_write_clearscreen(ctx); diff --git a/tmux.c b/tmux.c index 1f4057dc..e9b28d7e 100644 --- a/tmux.c +++ b/tmux.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -243,6 +244,8 @@ main(int argc, char **argv) malloc_options = (char *) "AFGJPX"; #endif + setlocale(LC_TIME, ""); + quiet = flags = 0; label = path = NULL; login_shell = (**argv == '-'); From caa8290510244990b26106e027aa253237ada629 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 12 Apr 2013 12:44:31 +0000 Subject: [PATCH 14/36] Copy the client into the new cmdq in source-file so commands that work on it (such as new-session) can work. Fixes issue reported by oss-adv at users dot sf dot net. --- cmd-source-file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd-source-file.c b/cmd-source-file.c index 1bd2bb0a..f50efbe3 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -49,6 +49,7 @@ cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq) char *cause; cmdq1 = cmdq_new(NULL); + cmdq1->client = cmdq->client; cmdq1->emptyfn = cmd_source_file_done; cmdq1->data = cmdq; From 27dcf470dc4aa5901ac7f01b3a9f971e02f2229e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 12 Apr 2013 12:50:36 +0000 Subject: [PATCH 15/36] Remove some Korean characters from the zero-width list that apparently shouldn't be there, from Jeong Mok Cho. --- utf8.c | 1 - 1 file changed, 1 deletion(-) diff --git a/utf8.c b/utf8.c index b276d872..1c81392b 100644 --- a/utf8.c +++ b/utf8.c @@ -171,7 +171,6 @@ struct utf8_width_entry utf8_width_table[] = { { 0x30000, 0x3fffd, 2, NULL, NULL }, { 0x00711, 0x00711, 0, NULL, NULL }, { 0x0fe00, 0x0fe0f, 0, NULL, NULL }, - { 0x01160, 0x011ff, 0, NULL, NULL }, { 0x0180b, 0x0180d, 0, NULL, NULL }, { 0x10a3f, 0x10a3f, 0, NULL, NULL }, { 0x00981, 0x00981, 0, NULL, NULL }, From 2c4543b9e9bd38bcc45393dad94930bcde872e6c Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sun, 14 Apr 2013 18:07:08 +0100 Subject: [PATCH 16/36] Add back missing -V flag This went walkies from a previous git commit. --- tmux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmux.c b/tmux.c index e8fd98b2..e6de5cfe 100644 --- a/tmux.c +++ b/tmux.c @@ -253,7 +253,7 @@ main(int argc, char **argv) quiet = flags = 0; label = path = NULL; login_shell = (**argv == '-'); - while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUv")) != -1) { + while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUVv")) != -1) { switch (opt) { case '2': flags |= IDENTIFY_256COLOURS; From c24b58e2ee8691870736959deb252c225b205b4d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 16 Apr 2013 11:33:53 +0100 Subject: [PATCH 17/36] Generate tmux.1 using mdoc2man.awk on Solaris, issue brought up and changes tested by Dagobert Michelsen. --- .gitignore | 1 + Makefile.am | 14 +- configure.ac | 5 + mdoc2man.awk | 370 ++++++++++++++++++++++++++++++++++++++++++++ tmux.1 => tmux.1.in | 0 5 files changed, 388 insertions(+), 2 deletions(-) create mode 100644 mdoc2man.awk rename tmux.1 => tmux.1.in (100%) diff --git a/.gitignore b/.gitignore index c3906ada..3b400861 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ tmux Makefile Makefile.in configure +tmux.1 diff --git a/Makefile.am b/Makefile.am index 2ce54b1a..b85eae0c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,12 +2,14 @@ # Obvious program stuff. bin_PROGRAMS = tmux -dist_man1_MANS = tmux.1 +nodist_man1_MANS = tmux.1 +CLEANFILES = tmux.1 # Distribution tarball options. EXTRA_DIST = \ CHANGES FAQ README TODO examples compat \ - array.h compat.h tmux.h osdep-*.c + array.h compat.h tmux.h osdep-*.c mdoc2man.awk \ + tmux.1.in dist-hook: grep "^#found_debug=" configure find $(distdir) -name .svn -type d|xargs rm -Rf @@ -232,6 +234,14 @@ if NO_B64_NTOP nodist_tmux_SOURCES += compat/b64_ntop.c endif +# Build tmux.1 in the right format. +tmux.1: tmux.1.in + if test x@MANFORMAT@ = xmdoc; then \ + cp tmux.1.in tmux.1; \ + else \ + $(AWK) -fmdoc2man.awk tmux.1.in >tmux.1; \ + fi + # Update SF web site. upload-index.html: update-index.html scp www/index.html www/main.css www/images/*.png \ diff --git a/configure.ac b/configure.ac index f00937f0..b4f76f5f 100644 --- a/configure.ac +++ b/configure.ac @@ -416,6 +416,10 @@ else AC_MSG_RESULT(no) fi +# Man page defaults to mdoc. +MANFORMAT=mdoc +AC_SUBST(MANFORMAT) + # Figure out the platform for osdep-*.c and forkpty-*.c. AC_MSG_CHECKING(platform) case "$host_os" in @@ -455,6 +459,7 @@ case "$host_os" in *solaris*) AC_MSG_RESULT(sunos) PLATFORM=sunos + MANFORMAT=man ;; *hpux*) AC_MSG_RESULT(hpux) diff --git a/mdoc2man.awk b/mdoc2man.awk new file mode 100644 index 00000000..80e8d5ff --- /dev/null +++ b/mdoc2man.awk @@ -0,0 +1,370 @@ +#!/usr/bin/awk +# +# $Id: mdoc2man.awk,v 1.9 2009/10/24 00:52:42 dtucker Exp $ +# +# Version history: +# v4+ Adapted for OpenSSH Portable (see cvs Id and history) +# v3, I put the program under a proper license +# Dan Nelson added .An, .Aq and fixed a typo +# v2, fixed to work on GNU awk --posix and MacOS X +# v1, first attempt, didn't work on MacOS X +# +# Copyright (c) 2003 Peter Stuge +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + +BEGIN { + optlist=0 + oldoptlist=0 + nospace=0 + synopsis=0 + reference=0 + block=0 + ext=0 + extopt=0 + literal=0 + prenl=0 + breakw=0 + line="" +} + +function wtail() { + retval="" + while(w0;i--) { + add(refauthors[i]) + if(i>1) + add(", ") + } + if(nrefauthors>1) + add(" and ") + if(nrefauthors>0) + add(refauthors[0] ", ") + add("\\fI" reftitle "\\fP") + if(length(refissue)) + add(", " refissue) + if(length(refreport)) { + add(", " refreport) + } + if(length(refdate)) + add(", " refdate) + if(length(refopt)) + add(", " refopt) + add(".") + reference=0 + } else if(reference) { + if(match(words[w],"^%A$")) { refauthors[nrefauthors++]=wtail() } + if(match(words[w],"^%T$")) { + reftitle=wtail() + sub("^\"","",reftitle) + sub("\"$","",reftitle) + } + if(match(words[w],"^%N$")) { refissue=wtail() } + if(match(words[w],"^%D$")) { refdate=wtail() } + if(match(words[w],"^%O$")) { refopt=wtail() } + if(match(words[w],"^%R$")) { refreport=wtail() } + } else if(match(words[w],"^Nm$")) { + if(synopsis) { + add(".br") + prenl++ + } + n=words[++w] + if(!length(name)) + name=n + if(!length(n)) + n=name + add("\\fB" n "\\fP") + if(!nospace&&match(words[w+1],"^[\\.,]")) + nospace=1 + } else if(match(words[w],"^Nd$")) { + add("\\- " wtail()) + } else if(match(words[w],"^Fl$")) { + add("\\fB\\-" words[++w] "\\fP") + if(!nospace&&match(words[w+1],"^[\\.,]")) + nospace=1 + } else if(match(words[w],"^Ar$")) { + add("\\fI") + if(w==nwords) + add("file ...\\fP") + else { + add(words[++w] "\\fP") + while(match(words[w+1],"^\\|$")) + add(OFS words[++w] " \\fI" words[++w] "\\fP") + } + if(!nospace&&match(words[w+1],"^[\\.,]")) + nospace=1 + } else if(match(words[w],"^Cm$")) { + add("\\fB" words[++w] "\\fP") + while(w") + if(option) + add("]") + if(ext&&!extopt&&!match(line," $")) + add(OFS) + if(!ext&&!extopt&&length(line)) { + print line + prenl=0 + line="" + } +} diff --git a/tmux.1 b/tmux.1.in similarity index 100% rename from tmux.1 rename to tmux.1.in From 88428cff3a0ef2e2013e990679dc746c58a99d12 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 17 Apr 2013 08:41:41 +0000 Subject: [PATCH 18/36] %zu format for size_t. --- job.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/job.c b/job.c index 291e000e..0ae03b31 100644 --- a/job.c +++ b/job.c @@ -144,8 +144,8 @@ job_write_callback(unused struct bufferevent *bufev, void *data) struct job *job = data; size_t len = EVBUFFER_LENGTH(EVBUFFER_OUTPUT(job->event)); - log_debug("job write %p: %s, pid %ld, output left %lu", job, job->cmd, - (long) job->pid, (unsigned long) len); + log_debug("job write %p: %s, pid %ld, output left %zu", job, job->cmd, + (long) job->pid, len); if (len == 0) { shutdown(job->fd, SHUT_WR); From 55640a31b3fbe5fd9b3eb4537779e2ffac58f47d Mon Sep 17 00:00:00 2001 From: Theo Deraadt Date: Wed, 17 Apr 2013 14:52:31 +0000 Subject: [PATCH 19/36] (long long) and %lld for time_t output ok nicm --- format.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/format.c b/format.c index b357876e..9918cfe8 100644 --- a/format.c +++ b/format.c @@ -288,7 +288,7 @@ format_session(struct format_tree *ft, struct session *s) format_add(ft, "session_group", "%u", session_group_index(sg)); t = s->creation_time.tv_sec; - format_add(ft, "session_created", "%ld", (long) t); + format_add(ft, "session_created", "%lld", (long long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "session_created_string", "%s", tim); @@ -314,13 +314,13 @@ format_client(struct format_tree *ft, struct client *c) format_add(ft, "client_termname", "%s", c->tty.termname); t = c->creation_time.tv_sec; - format_add(ft, "client_created", "%ld", (long) t); + format_add(ft, "client_created", "%lld", (long long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "client_created_string", "%s", tim); t = c->activity_time.tv_sec; - format_add(ft, "client_activity", "%ld", (long) t); + format_add(ft, "client_activity", "%lld", (long long) t); tim = ctime(&t); *strchr(tim, '\n') = '\0'; format_add(ft, "client_activity_string", "%s", tim); From 5dda1abc32b7b1eb59901a5592569e21d88c6ad2 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 21 Apr 2013 21:32:00 +0000 Subject: [PATCH 20/36] Don't let server_client_check_focus use a dead bufferevent, from Romain Francoise. --- server-client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server-client.c b/server-client.c index 6cacefa7..3b7b988a 100644 --- a/server-client.c +++ b/server-client.c @@ -514,8 +514,10 @@ server_client_loop(void) w->flags &= ~WINDOW_REDRAW; TAILQ_FOREACH(wp, &w->panes, entry) { - server_client_check_focus(wp); - server_client_check_resize(wp); + if (wp->fd != -1) { + server_client_check_focus(wp); + server_client_check_resize(wp); + } wp->flags &= ~PANE_REDRAW; } } @@ -527,7 +529,7 @@ server_client_check_resize(struct window_pane *wp) { struct winsize ws; - if (wp->fd == -1 || !(wp->flags & PANE_RESIZE)) + if (!(wp->flags & PANE_RESIZE)) return; memset(&ws, 0, sizeof ws); From a46ccbd883495d2acb3eab89e5bcdb61c0c7e195 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 22 Apr 2013 09:39:21 +0100 Subject: [PATCH 21/36] -paths.h. Fixes Solaris, from Dagobert Michelsen. --- tmux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tmux.c b/tmux.c index e6de5cfe..2916bbb5 100644 --- a/tmux.c +++ b/tmux.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include From d89b35e6826ecaccc4d2f421c8013f35ec5854a0 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 22 Apr 2013 08:42:19 +0000 Subject: [PATCH 22/36] Use lockf which is more portable than flock, from Dagobert Michelsen. --- client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 70e7f1ec..0c8657eb 100644 --- a/client.c +++ b/client.c @@ -78,8 +78,8 @@ client_get_lock(char *lockfile) if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1) fatal("open failed"); - if (flock(lockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) { - while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR) + if (lockf(lockfd, F_TLOCK, 0) == -1 && errno == EAGAIN) { + while (lockf(lockfd, F_LOCK, 0) == -1 && errno == EINTR) /* nothing */; close(lockfd); return (-1); From 792e2856c9774cca262929f81b9adbbac0fa1d13 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 22 Apr 2013 09:44:15 +0100 Subject: [PATCH 23/36] Add compat for cfmakeraw, from Dagobert Michelsen. --- Makefile.am | 3 +++ compat.h | 5 +++++ compat/cfmakeraw.c | 32 ++++++++++++++++++++++++++++++++ configure.ac | 8 ++++++++ 4 files changed, 48 insertions(+) create mode 100644 compat/cfmakeraw.c diff --git a/Makefile.am b/Makefile.am index b85eae0c..c5369fd9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -233,6 +233,9 @@ endif if NO_B64_NTOP nodist_tmux_SOURCES += compat/b64_ntop.c endif +if NO_CFMAKERAW +nodist_tmux_SOURCES += compat/cfmakeraw.c +endif # Build tmux.1 in the right format. tmux.1: tmux.1.in diff --git a/compat.h b/compat.h index 622006e1..d3973797 100644 --- a/compat.h +++ b/compat.h @@ -236,6 +236,11 @@ int setenv(const char *, const char *, int); int unsetenv(const char *); #endif +#ifndef HAVE_CFMAKERAW +/* cfmakeraw.c */ +void cfmakeraw(struct termios *tio); +#endif + #ifdef HAVE_GETOPT #include #else diff --git a/compat/cfmakeraw.c b/compat/cfmakeraw.c new file mode 100644 index 00000000..3f8dc7e5 --- /dev/null +++ b/compat/cfmakeraw.c @@ -0,0 +1,32 @@ +/* $Id$ */ + +/* + * Copyright (c) 2013 Dagobert Michelsen + * Copyright (c) 2013 Nicholas Marriott + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include "tmux.h" + +void +cfmakeraw(struct termios *tio) +{ + tio->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); + tio->c_oflag &= ~OPOST; + tio->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + tio->c_cflag &= ~(CSIZE|PARENB); + tio->c_cflag |= CS8; +} diff --git a/configure.ac b/configure.ac index b4f76f5f..80cf1266 100644 --- a/configure.ac +++ b/configure.ac @@ -313,6 +313,13 @@ if test "x$found_strnvis" = xyes; then fi AM_CONDITIONAL(NO_VIS, [test "x$found_strnvis" = xno]) +# Look for cfmakeraw, compat/cfmakeraw.c used if missing. +AC_CHECK_FUNC(cfmakeraw, found_cfmakeraw=yes, found_cfmakeraw=no) +if test "x$found_cfmakeraw" = xyes; then + AC_DEFINE(HAVE_CFMAKERAW) +fi +AM_CONDITIONAL(NO_CFMAKERAW, [test "x$found_cfmakeraw" = xno]) + # Look for getopt. glibc's getopt does not enforce argument order and the ways # of making it do so are stupid, so just use our own instead. AC_CHECK_FUNC(getopt, found_getopt=yes, found_getopt=no) @@ -345,6 +352,7 @@ AC_CHECK_FUNCS( dirfd \ setproctitle \ sysconf \ + cfmakeraw \ ] ) From 11b90bc9591b4b101efef1f8a9a0d9656d2953c9 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 22 Apr 2013 14:04:40 +0100 Subject: [PATCH 24/36] Pass tmux.1.in to awk on stdin rather than as an argument. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index c5369fd9..c131940a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -242,7 +242,7 @@ tmux.1: tmux.1.in if test x@MANFORMAT@ = xmdoc; then \ cp tmux.1.in tmux.1; \ else \ - $(AWK) -fmdoc2man.awk tmux.1.in >tmux.1; \ + $(AWK) -fmdoc2man.awk tmux.1; \ fi # Update SF web site. From 46c7dbef0f7803dad39db355ee866ecab8db696c Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 22 Apr 2013 13:35:18 +0000 Subject: [PATCH 25/36] Call recalculate_sizes() after killing window in case it is in a grouped session, from Daniel Ralston. --- server-fn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/server-fn.c b/server-fn.c index c0b005e8..d92754e1 100644 --- a/server-fn.c +++ b/server-fn.c @@ -283,6 +283,7 @@ server_kill_window(struct window *w) if (options_get_number(&s->options, "renumber-windows")) session_renumber_windows(s); } + recalculate_sizes(); } int From 04f54ab38f9a5f32e6fb89b57380cc7150c08006 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 22 Apr 2013 16:34:53 +0000 Subject: [PATCH 26/36] Get session of -t window rather than client's window. --- cmd-choose-tree.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index f22f17c2..db0333e7 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ -89,10 +89,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_ERROR); } - if ((s = c->session) == NULL) - return (CMD_RETURN_ERROR); - - if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL) + if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL) return (CMD_RETURN_ERROR); if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) From 3d2b7d5bce9532cedd647ace319afbf95ebe0e20 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 22 Apr 2013 22:17:29 +0000 Subject: [PATCH 27/36] When using choose-tree -u, start with the current window highlighted. From Thomas Adam. --- cmd-choose-tree.c | 5 ++++- tmux.h | 2 ++ window-choose.c | 14 +++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c index db0333e7..601d24f1 100644 --- a/cmd-choose-tree.c +++ b/cmd-choose-tree.c @@ -228,9 +228,12 @@ windows_only: free(final_win_template_last); window_choose_ready(wl->window->active, cur_win, NULL); + window_choose_collapse_all(wl->window->active); - if (args_has(args, 'u')) + if (args_has(args, 'u')) { window_choose_expand_all(wl->window->active); + window_choose_set_current(wl->window->active, cur_win); + } return (CMD_RETURN_NORMAL); } diff --git a/tmux.h b/tmux.h index 053b574e..8fb06223 100644 --- a/tmux.h +++ b/tmux.h @@ -2257,6 +2257,8 @@ struct window_choose_data *window_choose_add_item(struct window_pane *, struct client *, struct winlink *, const char *, const char *, u_int); void window_choose_expand_all(struct window_pane *); +void window_choose_collapse_all(struct window_pane *); +void window_choose_set_current(struct window_pane *, u_int); /* names.c */ void queue_window_name(struct window *); diff --git a/window-choose.c b/window-choose.c index 792224c1..38773605 100644 --- a/window-choose.c +++ b/window-choose.c @@ -44,7 +44,6 @@ void window_choose_scroll_down(struct window_pane *); void window_choose_collapse(struct window_pane *, struct session *); void window_choose_expand(struct window_pane *, struct session *, u_int); -void window_choose_collapse_all(struct window_pane *); enum window_choose_input_type { WINDOW_CHOOSE_NORMAL = -1, @@ -102,8 +101,7 @@ window_choose_add(struct window_pane *wp, struct window_choose_data *wcd) } void -window_choose_ready(struct window_pane *wp, u_int cur, - void (*callbackfn)(struct window_choose_data *)) +window_choose_set_current(struct window_pane *wp, u_int cur) { struct window_choose_mode_data *data = wp->modedata; struct screen *s = &data->screen; @@ -112,12 +110,22 @@ window_choose_ready(struct window_pane *wp, u_int cur, if (data->selected > screen_size_y(s) - 1) data->top = ARRAY_LENGTH(&data->list) - screen_size_y(s); + window_choose_redraw_screen(wp); +} + +void +window_choose_ready(struct window_pane *wp, u_int cur, + void (*callbackfn)(struct window_choose_data *)) +{ + struct window_choose_mode_data *data = wp->modedata; + data->callbackfn = callbackfn; if (data->callbackfn == NULL) data->callbackfn = window_choose_default_callback; ARRAY_CONCAT(&data->old_list, &data->list); + window_choose_set_current(wp, cur); window_choose_collapse_all(wp); } From 4f3c31a6b63f4489bfc672b510036fd8d9491595 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 24 Apr 2013 10:57:03 +0100 Subject: [PATCH 28/36] Use sysconfdir for the location of global tmux.conf (but default it to /etc), based on changes from Dagobert Michelsen. --- Makefile.am | 7 ++++--- configure.ac | 3 +++ server.c | 8 ++++---- tmux.1.in | 6 +++--- tmux.c | 2 +- tmux.h | 4 ---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile.am b/Makefile.am index c131940a..726582a5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,7 @@ dist-hook: find $(distdir) -name .svn -type d|xargs rm -Rf # Preprocessor flags. -CPPFLAGS += @XOPEN_DEFINES@ +CPPFLAGS += @XOPEN_DEFINES@ -DTMUX_CONF="\"$(sysconfdir)/tmux.conf\"" # glibc as usual does things ass-backwards and hides useful things by default, # so everyone has to add this. @@ -240,9 +240,10 @@ endif # Build tmux.1 in the right format. tmux.1: tmux.1.in if test x@MANFORMAT@ = xmdoc; then \ - cp tmux.1.in tmux.1; \ + sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" tmux.1.in >tmux.1; \ else \ - $(AWK) -fmdoc2man.awk tmux.1; \ + sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" tmux.1.in| \ + $(AWK) -fmdoc2man.awk >tmux.1; \ fi # Update SF web site. diff --git a/configure.ac b/configure.ac index 80cf1266..590b9db0 100644 --- a/configure.ac +++ b/configure.ac @@ -18,6 +18,9 @@ AC_PROG_CC AM_PROG_CC_C_O AC_PROG_INSTALL +# Default tmux.conf goes in /etc not ${prefix}/etc. +test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc + # Check for various headers. Alternatives included from compat.h. AC_CHECK_HEADERS( [ \ diff --git a/server.c b/server.c index 4bfa9185..bd28d517 100644 --- a/server.c +++ b/server.c @@ -170,13 +170,13 @@ server_start(int lockfd, char *lockfile) cfg_references = 1; ARRAY_INIT(&cfg_causes); - if (access(SYSTEM_CFG, R_OK) == 0) { - if (load_cfg(SYSTEM_CFG, cfg_cmd_q, &cause) == -1) { - xasprintf(&cause, "%s: %s", SYSTEM_CFG, cause); + if (access(TMUX_CONF, R_OK) == 0) { + if (load_cfg(TMUX_CONF, cfg_cmd_q, &cause) == -1) { + xasprintf(&cause, "%s: %s", TMUX_CONF, cause); ARRAY_ADD(&cfg_causes, cause); } } else if (errno != ENOENT) { - xasprintf(&cause, "%s: %s", SYSTEM_CFG, strerror(errno)); + xasprintf(&cause, "%s: %s", TMUX_CONF, strerror(errno)); ARRAY_ADD(&cfg_causes, cause); } if (cfg_file != NULL) { diff --git a/tmux.1.in b/tmux.1.in index 98bf9574..7f783b86 100644 --- a/tmux.1.in +++ b/tmux.1.in @@ -122,7 +122,7 @@ Specify an alternative configuration file. By default, .Nm loads the system configuration file from -.Pa /etc/tmux.conf , +.Pa @SYSCONFDIR@/tmux.conf , if present, then looks for a user configuration file at .Pa ~/.tmux.conf . .Pp @@ -3705,12 +3705,12 @@ was renamed to .Ar name . .El .Sh FILES -.Bl -tag -width "/etc/tmux.confXXX" -compact +.Bl -tag -width "@SYSCONFDIR@/tmux.confXXX" -compact .It Pa ~/.tmux.conf Default .Nm configuration file. -.It Pa /etc/tmux.conf +.It Pa @SYSCONFDIR@/tmux.conf System-wide configuration file. .El .Sh EXAMPLES diff --git a/tmux.c b/tmux.c index 2916bbb5..606c574f 100644 --- a/tmux.c +++ b/tmux.c @@ -363,7 +363,7 @@ main(int argc, char **argv) if (pw != NULL) home = pw->pw_dir; } - xasprintf(&cfg_file, "%s/%s", home, DEFAULT_CFG); + xasprintf(&cfg_file, "%s/.tmux.conf", home); if (access(cfg_file, R_OK) != 0 && errno == ENOENT) { free(cfg_file); cfg_file = NULL; diff --git a/tmux.h b/tmux.h index f0b9edf0..fc5561b5 100644 --- a/tmux.h +++ b/tmux.h @@ -39,10 +39,6 @@ extern char *__progname; extern char **environ; -/* Default configuration files. */ -#define DEFAULT_CFG ".tmux.conf" -#define SYSTEM_CFG "/etc/tmux.conf" - /* Default prompt history length. */ #define PROMPT_HISTORY 100 From e323101edede281b65e3c7141d79afdb2501a8ea Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 24 Apr 2013 10:01:32 +0000 Subject: [PATCH 29/36] Rename global configuration define. --- server.c | 8 ++++---- tmux.c | 2 +- tmux.h | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/server.c b/server.c index a07fa1fd..ffc25db0 100644 --- a/server.c +++ b/server.c @@ -169,13 +169,13 @@ server_start(int lockfd, char *lockfile) cfg_references = 1; ARRAY_INIT(&cfg_causes); - if (access(SYSTEM_CFG, R_OK) == 0) { - if (load_cfg(SYSTEM_CFG, cfg_cmd_q, &cause) == -1) { - xasprintf(&cause, "%s: %s", SYSTEM_CFG, cause); + if (access(TMUX_CONF, R_OK) == 0) { + if (load_cfg(TMUX_CONF, cfg_cmd_q, &cause) == -1) { + xasprintf(&cause, "%s: %s", TMUX_CONF, cause); ARRAY_ADD(&cfg_causes, cause); } } else if (errno != ENOENT) { - xasprintf(&cause, "%s: %s", SYSTEM_CFG, strerror(errno)); + xasprintf(&cause, "%s: %s", TMUX_CONF, strerror(errno)); ARRAY_ADD(&cfg_causes, cause); } if (cfg_file != NULL) { diff --git a/tmux.c b/tmux.c index e9b28d7e..b229967d 100644 --- a/tmux.c +++ b/tmux.c @@ -357,7 +357,7 @@ main(int argc, char **argv) if (pw != NULL) home = pw->pw_dir; } - xasprintf(&cfg_file, "%s/%s", home, DEFAULT_CFG); + xasprintf(&cfg_file, "%s/.tmux.conf", home); if (access(cfg_file, R_OK) != 0 && errno == ENOENT) { free(cfg_file); cfg_file = NULL; diff --git a/tmux.h b/tmux.h index 8fb06223..7404b27f 100644 --- a/tmux.h +++ b/tmux.h @@ -43,9 +43,8 @@ extern char *__progname; extern char **environ; -/* Default configuration files. */ -#define DEFAULT_CFG ".tmux.conf" -#define SYSTEM_CFG "/etc/tmux.conf" +/* Default global configuration file. */ +#define TMUX_CONF "/etc/tmux.conf" /* Default prompt history length. */ #define PROMPT_HISTORY 100 From 2555ac58ccc9b5e9c188dcb3a3a4cce6aa4821d1 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 24 Apr 2013 10:15:47 +0000 Subject: [PATCH 30/36] .Op Fl b not .Fl b for run-shell synopsis, from Ben Boeckel. --- tmux.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmux.1 b/tmux.1 index b38b43bb..9b874f7b 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3536,7 +3536,7 @@ Lock each client individually by running the command specified by the .Ic lock-command option. .It Xo Ic run-shell -.Fl b +.Op Fl b .Op Fl t Ar target-pane .Ar shell-command .Xc From fce095665c62eb38826f42ae55a0fbe998f18be0 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 28 Apr 2013 15:37:02 +0100 Subject: [PATCH 31/36] Use $(srcdir) for generating tmux.1, reported by fasta_ on IRC. --- Makefile.am | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 726582a5..3eb3190f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -240,10 +240,11 @@ endif # Build tmux.1 in the right format. tmux.1: tmux.1.in if test x@MANFORMAT@ = xmdoc; then \ - sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" tmux.1.in >tmux.1; \ + sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1.in \ + >$(srcdir)/tmux.1; \ else \ - sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" tmux.1.in| \ - $(AWK) -fmdoc2man.awk >tmux.1; \ + sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1.in| \ + $(AWK) -fmdoc2man.awk >$(srcdir)/tmux.1; \ fi # Update SF web site. From 66f4c60a8477e0cf9eb059e7687ca524f135e442 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 7 May 2013 11:00:16 +0000 Subject: [PATCH 32/36] Don't limit width and height to 222 in standard mouse mode. --- input-keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input-keys.c b/input-keys.c index d7e8513d..2de48e97 100644 --- a/input-keys.c +++ b/input-keys.c @@ -227,7 +227,7 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m) len += utf8_split2(m->x + 33, &buf[len]); len += utf8_split2(m->y + 33, &buf[len]); } else { - if (m->xb > 223 || m->x >= 222 || m->y > 222) + if (m->xb > 223) return; len = xsnprintf(buf, sizeof buf, "\033[M"); buf[len++] = m->xb + 32; From 5b1cf02f2ea224922661495af32d46b024e28eef Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 15 May 2013 16:27:30 +0100 Subject: [PATCH 33/36] Rename tmux.1.in back to tmux.1 and generate tmux.1.{mdoc,man} instead. --- Makefile.am | 16 ++++++++-------- tmux.1.in => tmux.1 | 0 2 files changed, 8 insertions(+), 8 deletions(-) rename tmux.1.in => tmux.1 (100%) diff --git a/Makefile.am b/Makefile.am index c131940a..c746b3d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,14 +2,12 @@ # Obvious program stuff. bin_PROGRAMS = tmux -nodist_man1_MANS = tmux.1 -CLEANFILES = tmux.1 +CLEANFILES = tmux.1.mdoc tmux.1.man # Distribution tarball options. EXTRA_DIST = \ CHANGES FAQ README TODO examples compat \ - array.h compat.h tmux.h osdep-*.c mdoc2man.awk \ - tmux.1.in + array.h compat.h tmux.h osdep-*.c mdoc2man.awk tmux.1 dist-hook: grep "^#found_debug=" configure find $(distdir) -name .svn -type d|xargs rm -Rf @@ -237,13 +235,15 @@ if NO_CFMAKERAW nodist_tmux_SOURCES += compat/cfmakeraw.c endif -# Build tmux.1 in the right format. -tmux.1: tmux.1.in +# Install tmux.1 in the right format. +install-exec-hook: if test x@MANFORMAT@ = xmdoc; then \ - cp tmux.1.in tmux.1; \ + cp tmux.1 tmux.1.mdoc; \ else \ - $(AWK) -fmdoc2man.awk tmux.1; \ + $(AWK) -fmdoc2man.awk tmux.1.man; \ fi + $(MKDIR_P) $(DESTDIR)$(mandir)/man1 + $(INSTALL_DATA) tmux.1.@MANFORMAT@ $(DESTDIR)$(mandir)/man1/tmux.1 # Update SF web site. upload-index.html: update-index.html diff --git a/tmux.1.in b/tmux.1 similarity index 100% rename from tmux.1.in rename to tmux.1 From 772d61f3ed762a50ea4436b7fb70e7024674e6c6 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 15 May 2013 15:32:14 +0000 Subject: [PATCH 34/36] RIS should reset focus reporting, from Hayaki Saito. --- screen-write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen-write.c b/screen-write.c index c0935c95..7fcfc5ee 100644 --- a/screen-write.c +++ b/screen-write.c @@ -56,7 +56,7 @@ screen_write_reset(struct screen_write_ctx *ctx) screen_reset_tabs(s); screen_write_scrollregion(ctx, 0, screen_size_y(s) - 1); - s->mode &= ~(MODE_INSERT|MODE_KCURSOR|MODE_KKEYPAD); + s->mode &= ~(MODE_INSERT|MODE_KCURSOR|MODE_KKEYPAD|MODE_FOCUSON); s->mode &= ~(ALL_MOUSE_MODES|MODE_MOUSE_UTF8|MODE_MOUSE_SGR); screen_write_clearscreen(ctx); From 25c430b1cd25d64c52d1c14834957abfaaeb69b6 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 15 May 2013 15:34:09 +0000 Subject: [PATCH 35/36] Reserve space for \0 in cmd_print, from George Nachman. --- cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd.c b/cmd.c index d0348704..e7290f26 100644 --- a/cmd.c +++ b/cmd.c @@ -295,8 +295,8 @@ cmd_print(struct cmd *cmd, char *buf, size_t len) size_t off, used; off = xsnprintf(buf, len, "%s ", cmd->entry->name); - if (off < len) { - used = args_print(cmd->args, buf + off, len - off); + if (off + 1 < len) { + used = args_print(cmd->args, buf + off, len - off - 1); if (used == 0) off--; else From 88a4da97478ec6b4b2f361315a5a183333d0aa3f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 15 May 2013 15:39:51 +0000 Subject: [PATCH 36/36] Don't let cursor position overflow when reflowing, from Christopher Collins. --- screen.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/screen.c b/screen.c index 754effc2..76aa91c6 100644 --- a/screen.c +++ b/screen.c @@ -365,7 +365,13 @@ void screen_reflow(struct screen *s, u_int new_x) { struct grid *old = s->grid; + u_int change; s->grid = grid_create(old->sx, old->sy, old->hlimit); - s->cy -= grid_reflow(s->grid, old, new_x); + + change = grid_reflow(s->grid, old, new_x); + if (change < s->cy) + s->cy -= change; + else + s->cy = 0; }