From cfb78654c2b9a9f0c2f90c22228563d5385c510c Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 2 Jan 2016 17:16:25 +0000 Subject: [PATCH 01/47] clock-mode needs CMD_PANE. --- cmd-copy-mode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index 1a006ebb1..49f5b30cc 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -46,6 +46,8 @@ const struct cmd_entry cmd_clock_mode_entry = { .args = { "t:", 0, 0 }, .usage = CMD_TARGET_PANE_USAGE, + .tflag = CMD_PANE, + .flags = 0, .exec = cmd_copy_mode_exec }; From 68d797587ef2acf1464a9390912e4a22e4db6482 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 15 Jan 2016 11:31:47 +0000 Subject: [PATCH 02/47] A couple of missing printflike attributes, from Andrey Starodubtsev. --- input.c | 2 +- tmux.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/input.c b/input.c index ed1ebffc4..19fd48b76 100644 --- a/input.c +++ b/input.c @@ -100,7 +100,7 @@ struct input_ctx { struct input_transition; int input_split(struct input_ctx *); int input_get(struct input_ctx *, u_int, int, int); -void input_reply(struct input_ctx *, const char *, ...); +void printflike(2, 3) input_reply(struct input_ctx *, const char *, ...); void input_set_state(struct window_pane *, const struct input_transition *); void input_reset_cell(struct input_ctx *); diff --git a/tmux.h b/tmux.h index 194d01d8a..dbea85bfc 100644 --- a/tmux.h +++ b/tmux.h @@ -1540,7 +1540,7 @@ extern struct client *cfg_client; void start_cfg(void); int load_cfg(const char *, struct cmd_q *, char **); void set_cfg_file(const char *); -void cfg_add_cause(const char *, ...); +void printflike(1, 2) cfg_add_cause(const char *, ...); void cfg_print_causes(struct cmd_q *); void cfg_show_causes(struct session *); From d551ab8e5cfb00fbb7a79e7f0c3f4f2780fc6824 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 15 Jan 2016 11:33:41 +0000 Subject: [PATCH 03/47] Clear the environment properly by looping until it is empty rather than looping over it (which may skip entries), from Brad King. --- environ.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/environ.c b/environ.c index de5608969..101dfafd7 100644 --- a/environ.c +++ b/environ.c @@ -196,10 +196,10 @@ void environ_push(struct environ *env) { struct environ_entry *envent; - char **vp, *v; + char *v; - for (vp = environ; *vp != NULL; vp++) { - v = xstrdup(*vp); + while (*environ != NULL) { + v = xstrdup(*environ); v[strcspn(v, "=")] = '\0'; unsetenv(v); From c9815307ebe8b729504d383904ae3ef3b862cf11 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 16 Jan 2016 00:36:53 +0000 Subject: [PATCH 04/47] Add hooks for alerts (bell, silence, activity), from Thomas Adam. --- alerts.c | 23 ++++++++++++++++++++--- cmd-find.c | 16 ++++++++++++++++ tmux.1 | 10 ++++++++++ tmux.h | 2 ++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/alerts.c b/alerts.c index 536ea750d..d1fb0fce7 100644 --- a/alerts.c +++ b/alerts.c @@ -29,6 +29,7 @@ int alerts_enabled(struct window *, int); void alerts_callback(int, short, void *); void alerts_reset(struct window *); +void alerts_run_hook(struct session *, struct winlink *, int); int alerts_check_all(struct session *, struct winlink *); int alerts_check_bell(struct session *, struct winlink *); int alerts_check_activity(struct session *, struct winlink *); @@ -55,8 +56,6 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg) RB_FOREACH(w, windows, &windows) { RB_FOREACH(s, sessions, &sessions) { - if (s->flags & SESSION_UNATTACHED) - continue; RB_FOREACH(wl, winlinks, &s->windows) { if (wl->window != w) continue; @@ -73,6 +72,22 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg) alerts_fired = 0; } +void +alerts_run_hook(struct session *s, struct winlink *wl, int flags) +{ + struct cmd_find_state fs; + + if (cmd_find_from_winlink(&fs, s, wl) != 0) + return; + + if (flags & WINDOW_BELL) + hooks_run(s->hooks, NULL, &fs, "alert-bell"); + if (flags & WINDOW_SILENCE) + hooks_run(s->hooks, NULL, &fs, "alert-silence"); + if (flags & WINDOW_ACTIVITY) + hooks_run(s->hooks, NULL, &fs, "alert-activity"); +} + int alerts_check_all(struct session *s, struct winlink *wl) { @@ -81,8 +96,10 @@ alerts_check_all(struct session *s, struct winlink *wl) alerts = alerts_check_bell(s, wl); alerts |= alerts_check_activity(s, wl); alerts |= alerts_check_silence(s, wl); - if (alerts != 0) + if (alerts != 0) { + alerts_run_hook(s, wl, alerts); server_status_session(s); + } return (alerts); } diff --git a/cmd-find.c b/cmd-find.c index 9b1ca5174..68aaf121b 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -879,6 +879,22 @@ cmd_find_from_session(struct cmd_find_state *fs, struct session *s) return (0); } +/* Find state from a winlink. */ +int +cmd_find_from_winlink(struct cmd_find_state *fs, struct session *s, + struct winlink *wl) +{ + cmd_find_clear_state(fs, NULL, 0); + + fs->s = s; + fs->wl = wl; + fs->w = wl->window; + fs->wp = wl->window->active; + + cmd_find_log_state(__func__, fs); + return (0); +} + /* Find state from a window. */ int cmd_find_from_window(struct cmd_find_state *fs, struct window *w) diff --git a/tmux.1 b/tmux.1 index 9017b4e78..159a4bd97 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3224,6 +3224,16 @@ Each hook has a .Em name . The following hooks are available: .Bl -tag -width "XXXXXXXXXXXXXXXX" +.It alert-activity +Run when a window has activity. +See +.Ic monitor-activity . +.It alert-bell +Run when a window has received a bell. +.It alert-silence +Run when a window has been silent. +See +.Ic monitor-silence . .It client-attached Run when a client is attached. .It client-detached diff --git a/tmux.h b/tmux.h index dbea85bfc..55fe407f8 100644 --- a/tmux.h +++ b/tmux.h @@ -1780,6 +1780,8 @@ void cmd_find_copy_state(struct cmd_find_state *, void cmd_find_log_state(const char *, struct cmd_find_state *); int cmd_find_from_session(struct cmd_find_state *, struct session *); +int cmd_find_from_winlink(struct cmd_find_state *, + struct session *, struct winlink *); int cmd_find_from_window(struct cmd_find_state *, struct window *); int cmd_find_from_pane(struct cmd_find_state *, struct window_pane *); From 995af0e2b72aec54ba3685b1a8ce5e78d279d8ff Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 19 Jan 2016 15:59:12 +0000 Subject: [PATCH 05/47] I no longer use my SourceForge address so replace it. --- alerts.c | 2 +- arguments.c | 2 +- array.h | 2 +- cfg.c | 2 +- client.c | 2 +- cmd-attach-session.c | 2 +- cmd-bind-key.c | 2 +- cmd-break-pane.c | 2 +- cmd-choose-buffer.c | 2 +- cmd-choose-client.c | 2 +- cmd-clear-history.c | 2 +- cmd-command-prompt.c | 2 +- cmd-copy-mode.c | 2 +- cmd-detach-client.c | 2 +- cmd-display-panes.c | 2 +- cmd-find-window.c | 2 +- cmd-find.c | 2 +- cmd-join-pane.c | 2 +- cmd-kill-pane.c | 2 +- cmd-kill-server.c | 2 +- cmd-kill-session.c | 2 +- cmd-kill-window.c | 2 +- cmd-list-buffers.c | 2 +- cmd-list-clients.c | 2 +- cmd-list-keys.c | 2 +- cmd-list-panes.c | 2 +- cmd-list-sessions.c | 2 +- cmd-list-windows.c | 2 +- cmd-list.c | 2 +- cmd-lock-server.c | 2 +- cmd-move-window.c | 2 +- cmd-new-session.c | 2 +- cmd-new-window.c | 2 +- cmd-paste-buffer.c | 2 +- cmd-pipe-pane.c | 2 +- cmd-queue.c | 2 +- cmd-refresh-client.c | 2 +- cmd-rename-session.c | 2 +- cmd-rename-window.c | 2 +- cmd-resize-pane.c | 2 +- cmd-respawn-pane.c | 2 +- cmd-respawn-window.c | 2 +- cmd-rotate-window.c | 2 +- cmd-select-layout.c | 2 +- cmd-select-pane.c | 2 +- cmd-select-window.c | 2 +- cmd-send-keys.c | 2 +- cmd-set-buffer.c | 2 +- cmd-set-environment.c | 2 +- cmd-set-option.c | 2 +- cmd-show-environment.c | 2 +- cmd-show-messages.c | 2 +- cmd-show-options.c | 2 +- cmd-split-window.c | 2 +- cmd-string.c | 2 +- cmd-swap-pane.c | 2 +- cmd-swap-window.c | 2 +- cmd-switch-client.c | 2 +- cmd-unbind-key.c | 2 +- cmd-wait-for.c | 2 +- cmd.c | 2 +- colour.c | 2 +- control-notify.c | 2 +- control.c | 2 +- environ.c | 2 +- format.c | 2 +- grid-view.c | 2 +- grid.c | 2 +- input-keys.c | 2 +- input.c | 2 +- job.c | 2 +- key-bindings.c | 2 +- key-string.c | 2 +- layout-custom.c | 2 +- layout-set.c | 2 +- layout.c | 2 +- log.c | 2 +- mode-key.c | 2 +- names.c | 2 +- options-table.c | 2 +- options.c | 2 +- paste.c | 2 +- proc.c | 2 +- procname.c | 2 +- resize.c | 2 +- screen-redraw.c | 2 +- screen-write.c | 2 +- screen.c | 2 +- server-client.c | 2 +- server-fn.c | 2 +- server.c | 2 +- session.c | 2 +- signal.c | 2 +- status.c | 2 +- style.c | 2 +- tmux.1 | 4 ++-- tmux.c | 2 +- tmux.h | 2 +- tty-acs.c | 2 +- tty-keys.c | 2 +- tty-term.c | 2 +- tty.c | 2 +- utf8.c | 2 +- window-choose.c | 2 +- window-clock.c | 2 +- window-copy.c | 2 +- window.c | 2 +- xterm-keys.c | 2 +- 108 files changed, 109 insertions(+), 109 deletions(-) diff --git a/alerts.c b/alerts.c index d1fb0fce7..cca0d815e 100644 --- a/alerts.c +++ b/alerts.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2015 Nicholas Marriott + * Copyright (c) 2015 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 diff --git a/arguments.c b/arguments.c index 0a42cc38c..501f38dfe 100644 --- a/arguments.c +++ b/arguments.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2010 Nicholas Marriott + * Copyright (c) 2010 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 diff --git a/array.h b/array.h index 671bea42a..209de0c51 100644 --- a/array.h +++ b/array.h @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2006 Nicholas Marriott + * Copyright (c) 2006 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 diff --git a/cfg.c b/cfg.c index 136c94d1e..c5c21b949 100644 --- a/cfg.c +++ b/cfg.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/client.c b/client.c index 516ed3bf9..ed15bc80d 100644 --- a/client.c +++ b/client.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-attach-session.c b/cmd-attach-session.c index 993f4c750..53c1df314 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-bind-key.c b/cmd-bind-key.c index df3285f79..a829a2c57 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-break-pane.c b/cmd-break-pane.c index c2b021fc5..b5a2743f7 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c index 1f8fbfb2e..90872e903 100644 --- a/cmd-choose-buffer.c +++ b/cmd-choose-buffer.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2010 Nicholas Marriott + * Copyright (c) 2010 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 diff --git a/cmd-choose-client.c b/cmd-choose-client.c index 7d5fc606a..b9a24be6a 100644 --- a/cmd-choose-client.c +++ b/cmd-choose-client.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-clear-history.c b/cmd-clear-history.c index 1236e7f18..62683ff64 100644 --- a/cmd-clear-history.c +++ b/cmd-clear-history.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index 9200ada1c..3ec228651 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index 49f5b30cc..beb4d7c83 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-detach-client.c b/cmd-detach-client.c index daf9a5c6d..80c6555ff 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-display-panes.c b/cmd-display-panes.c index d8db40665..eed3611ee 100644 --- a/cmd-display-panes.c +++ b/cmd-display-panes.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-find-window.c b/cmd-find-window.c index eb940d8c7..6324f26ac 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-find.c b/cmd-find.c index 68aaf121b..c76dc4a2d 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2015 Nicholas Marriott + * Copyright (c) 2015 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 diff --git a/cmd-join-pane.c b/cmd-join-pane.c index 8b4117fa8..d630dd45c 100644 --- a/cmd-join-pane.c +++ b/cmd-join-pane.c @@ -2,7 +2,7 @@ /* * Copyright (c) 2011 George Nachman - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c index f843bc582..ebb2b8d61 100644 --- a/cmd-kill-pane.c +++ b/cmd-kill-pane.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-kill-server.c b/cmd-kill-server.c index 6f84e9599..d1940c339 100644 --- a/cmd-kill-server.c +++ b/cmd-kill-server.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-kill-session.c b/cmd-kill-session.c index 4ca4e2c8f..c77e45bb6 100644 --- a/cmd-kill-session.c +++ b/cmd-kill-session.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-kill-window.c b/cmd-kill-window.c index 7a8e9fa60..9d388ce54 100644 --- a/cmd-kill-window.c +++ b/cmd-kill-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-list-buffers.c b/cmd-list-buffers.c index a6007c337..238b27762 100644 --- a/cmd-list-buffers.c +++ b/cmd-list-buffers.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-list-clients.c b/cmd-list-clients.c index 75c6f5703..f318ac18f 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-list-keys.c b/cmd-list-keys.c index 4abe24734..c3ace8de6 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-list-panes.c b/cmd-list-panes.c index da0e09627..76e06a715 100644 --- a/cmd-list-panes.c +++ b/cmd-list-panes.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c index 1fde7f868..27e80dbc0 100644 --- a/cmd-list-sessions.c +++ b/cmd-list-sessions.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-list-windows.c b/cmd-list-windows.c index dd05ea85b..11a5fddfc 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-list.c b/cmd-list.c index 59fc77969..e999c3704 100644 --- a/cmd-list.c +++ b/cmd-list.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-lock-server.c b/cmd-lock-server.c index 9cdd816f0..01597169e 100644 --- a/cmd-lock-server.c +++ b/cmd-lock-server.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/cmd-move-window.c b/cmd-move-window.c index bb33ab389..e756a638c 100644 --- a/cmd-move-window.c +++ b/cmd-move-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/cmd-new-session.c b/cmd-new-session.c index f96003c72..b4bb37d59 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-new-window.c b/cmd-new-window.c index 33f68935c..2a647b9ff 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-paste-buffer.c b/cmd-paste-buffer.c index 0728743ae..8025975f7 100644 --- a/cmd-paste-buffer.c +++ b/cmd-paste-buffer.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c index a2653dc51..e59fc5867 100644 --- a/cmd-pipe-pane.c +++ b/cmd-pipe-pane.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-queue.c b/cmd-queue.c index 5bc3226ab..fcca7eb62 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2013 Nicholas Marriott + * 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 diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index 444e83fcd..79e5aad02 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-rename-session.c b/cmd-rename-session.c index 7fc6193da..b40f44f7b 100644 --- a/cmd-rename-session.c +++ b/cmd-rename-session.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-rename-window.c b/cmd-rename-window.c index 36c1bf31e..a1f15eef1 100644 --- a/cmd-rename-window.c +++ b/cmd-rename-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index bb29cef93..2b4f1c177 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-respawn-pane.c b/cmd-respawn-pane.c index bff6c11b8..ba2c1cd23 100644 --- a/cmd-respawn-pane.c +++ b/cmd-respawn-pane.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 Nicholas Marriott * Copyright (c) 2011 Marcel P. Partap * * Permission to use, copy, modify, and distribute this software for any diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c index da9a365a4..95fc0cb4d 100644 --- a/cmd-respawn-window.c +++ b/cmd-respawn-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/cmd-rotate-window.c b/cmd-rotate-window.c index 014c1f2f0..94eca37d6 100644 --- a/cmd-rotate-window.c +++ b/cmd-rotate-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-select-layout.c b/cmd-select-layout.c index e6ede1afd..44f01bb72 100644 --- a/cmd-select-layout.c +++ b/cmd-select-layout.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-select-pane.c b/cmd-select-pane.c index 02385a41d..14d53d488 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-select-window.c b/cmd-select-window.c index 82acc859e..782280673 100644 --- a/cmd-select-window.c +++ b/cmd-select-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-send-keys.c b/cmd-send-keys.c index 7b0b952c1..92c75ec38 100644 --- a/cmd-send-keys.c +++ b/cmd-send-keys.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c index 1494cf261..1f0cf3d81 100644 --- a/cmd-set-buffer.c +++ b/cmd-set-buffer.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-set-environment.c b/cmd-set-environment.c index f701d7d9c..55bdaa9ae 100644 --- a/cmd-set-environment.c +++ b/cmd-set-environment.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-set-option.c b/cmd-set-option.c index 13de02a39..7fc812865 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-show-environment.c b/cmd-show-environment.c index 54baafe42..83661c440 100644 --- a/cmd-show-environment.c +++ b/cmd-show-environment.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-show-messages.c b/cmd-show-messages.c index 68ef66743..3131184d8 100644 --- a/cmd-show-messages.c +++ b/cmd-show-messages.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-show-options.c b/cmd-show-options.c index e99574f8c..fec2f1deb 100644 --- a/cmd-show-options.c +++ b/cmd-show-options.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-split-window.c b/cmd-split-window.c index aee323eba..8382d78ed 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-string.c b/cmd-string.c index 51554800d..757d4cdb8 100644 --- a/cmd-string.c +++ b/cmd-string.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c index 84332c2fa..aec7753de 100644 --- a/cmd-swap-pane.c +++ b/cmd-swap-pane.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/cmd-swap-window.c b/cmd-swap-window.c index e18358200..14907d2d2 100644 --- a/cmd-swap-window.c +++ b/cmd-swap-window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-switch-client.c b/cmd-switch-client.c index bc9f5585b..6e2ee2a0b 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c index 8e89f21af..7452fd9f6 100644 --- a/cmd-unbind-key.c +++ b/cmd-unbind-key.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/cmd-wait-for.c b/cmd-wait-for.c index 59f7dbfbc..81b01627b 100644 --- a/cmd-wait-for.c +++ b/cmd-wait-for.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2013 Nicholas Marriott + * Copyright (c) 2013 Nicholas Marriott * Copyright (c) 2013 Thiago de Arruda * * Permission to use, copy, modify, and distribute this software for any diff --git a/cmd.c b/cmd.c index 4f1e1b90c..052c095ba 100644 --- a/cmd.c +++ b/cmd.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/colour.c b/colour.c index a56ddce93..b349e2a59 100644 --- a/colour.c +++ b/colour.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/control-notify.c b/control-notify.c index a40f8d7c5..c28d0fc8d 100644 --- a/control-notify.c +++ b/control-notify.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2012 Nicholas Marriott + * Copyright (c) 2012 Nicholas Marriott * Copyright (c) 2012 George Nachman * * Permission to use, copy, modify, and distribute this software for any diff --git a/control.c b/control.c index e799a4cbd..f6dedca84 100644 --- a/control.c +++ b/control.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2012 Nicholas Marriott + * Copyright (c) 2012 Nicholas Marriott * Copyright (c) 2012 George Nachman * * Permission to use, copy, modify, and distribute this software for any diff --git a/environ.c b/environ.c index 101dfafd7..d855f8b5d 100644 --- a/environ.c +++ b/environ.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/format.c b/format.c index 79445936f..efa9d1e11 100644 --- a/format.c +++ b/format.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2011 Nicholas Marriott + * Copyright (c) 2011 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 diff --git a/grid-view.c b/grid-view.c index f6708c898..0989f8005 100644 --- a/grid-view.c +++ b/grid-view.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/grid.c b/grid.c index 579eb966e..c24e6c6a4 100644 --- a/grid.c +++ b/grid.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/input-keys.c b/input-keys.c index 3bc1f8126..254845cba 100644 --- a/input-keys.c +++ b/input-keys.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/input.c b/input.c index 19fd48b76..1772a4cde 100644 --- a/input.c +++ b/input.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/job.c b/job.c index e9799956a..d6541709d 100644 --- a/job.c +++ b/job.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/key-bindings.c b/key-bindings.c index 47a7d8672..a922eb183 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/key-string.c b/key-string.c index 1ff3ca307..dc2116969 100644 --- a/key-string.c +++ b/key-string.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/layout-custom.c b/layout-custom.c index 57503518c..99c6c3ceb 100644 --- a/layout-custom.c +++ b/layout-custom.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2010 Nicholas Marriott + * Copyright (c) 2010 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 diff --git a/layout-set.c b/layout-set.c index 852ec0f69..bd1304ce3 100644 --- a/layout-set.c +++ b/layout-set.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/layout.c b/layout.c index c448814aa..31dce95c7 100644 --- a/layout.c +++ b/layout.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/log.c b/log.c index 46f1673cb..9729a4dd8 100644 --- a/log.c +++ b/log.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/mode-key.c b/mode-key.c index a47cda0b7..f38ebf661 100644 --- a/mode-key.c +++ b/mode-key.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/names.c b/names.c index 3c25e2155..a03f6f5bd 100644 --- a/names.c +++ b/names.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/options-table.c b/options-table.c index 63e7ab61b..af0f41ed0 100644 --- a/options-table.c +++ b/options-table.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2011 Nicholas Marriott + * Copyright (c) 2011 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 diff --git a/options.c b/options.c index 02f0f9577..df79ac4bd 100644 --- a/options.c +++ b/options.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/paste.c b/paste.c index 5f60914f5..f57024384 100644 --- a/paste.c +++ b/paste.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/proc.c b/proc.c index 5f51b0ac5..bc27b4ff9 100644 --- a/proc.c +++ b/proc.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2015 Nicholas Marriott + * Copyright (c) 2015 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 diff --git a/procname.c b/procname.c index 97a78d717..42f5f4739 100644 --- a/procname.c +++ b/procname.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/resize.c b/resize.c index c7805e058..831302b1b 100644 --- a/resize.c +++ b/resize.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/screen-redraw.c b/screen-redraw.c index 9958d04af..952a8515f 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/screen-write.c b/screen-write.c index e53d37990..05315b3f8 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/screen.c b/screen.c index db9f52a67..e002b96e9 100644 --- a/screen.c +++ b/screen.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/server-client.c b/server-client.c index 9b88a1658..bb54643a3 100644 --- a/server-client.c +++ b/server-client.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/server-fn.c b/server-fn.c index 0f35aaaf7..39d31f3c6 100644 --- a/server-fn.c +++ b/server-fn.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/server.c b/server.c index 170244c77..890743f6f 100644 --- a/server.c +++ b/server.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/session.c b/session.c index b3ae2b429..7f2c3d975 100644 --- a/session.c +++ b/session.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/signal.c b/signal.c index 9a4d58c2f..19938638b 100644 --- a/signal.c +++ b/signal.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 Nicholas Marriott * Copyright (c) 2010 Romain Francoise * * Permission to use, copy, modify, and distribute this software for any diff --git a/status.c b/status.c index cbacfe4cd..1bd02c43a 100644 --- a/status.c +++ b/status.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/style.c b/style.c index c00b0feeb..151c29127 100644 --- a/style.c +++ b/style.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 Nicholas Marriott * Copyright (c) 2014 Tiago Cunha * * Permission to use, copy, modify, and distribute this software for any diff --git a/tmux.1 b/tmux.1 index 159a4bd97..e41ba7981 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1,6 +1,6 @@ .\" $OpenBSD$ .\" -.\" Copyright (c) 2007 Nicholas Marriott +.\" Copyright (c) 2007 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 @@ -4248,4 +4248,4 @@ bind-key S command-prompt "new-window -n %1 'ssh %1'" .Sh SEE ALSO .Xr pty 4 .Sh AUTHORS -.An Nicholas Marriott Aq Mt nicm@users.sourceforge.net +.An Nicholas Marriott Aq Mt nicholas.marriott@gmail.com diff --git a/tmux.c b/tmux.c index fe5e54a52..1ee2a269a 100644 --- a/tmux.c +++ b/tmux.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/tmux.h b/tmux.h index 55fe407f8..941548d04 100644 --- a/tmux.h +++ b/tmux.h @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/tty-acs.c b/tty-acs.c index 5d03c3eb1..7fd265d4d 100644 --- a/tty-acs.c +++ b/tty-acs.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2010 Nicholas Marriott + * Copyright (c) 2010 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 diff --git a/tty-keys.c b/tty-keys.c index 86839a171..2b9987781 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/tty-term.c b/tty-term.c index 27c904a46..8716a1a95 100644 --- a/tty-term.c +++ b/tty-term.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/tty.c b/tty.c index 304e13786..52521be9c 100644 --- a/tty.c +++ b/tty.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/utf8.c b/utf8.c index 2210675a4..b03c425df 100644 --- a/utf8.c +++ b/utf8.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/window-choose.c b/window-choose.c index fdfc47a09..7a727aacb 100644 --- a/window-choose.c +++ b/window-choose.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/window-clock.c b/window-clock.c index e8451f223..4cc58684f 100644 --- a/window-clock.c +++ b/window-clock.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/window-copy.c b/window-copy.c index e09a504ca..c8e38fd18 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/window.c b/window.c index cfb44ae30..201942a37 100644 --- a/window.c +++ b/window.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/xterm-keys.c b/xterm-keys.c index f1490fcc1..7bfefd157 100644 --- a/xterm-keys.c +++ b/xterm-keys.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 From b5b5221c13ded5b141fa35f60c707c9c403b83a6 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 19 Jan 2016 16:01:30 +0000 Subject: [PATCH 06/47] Split out getting the current state from the target search so it can be replaced if we already know the current. --- cmd-find.c | 29 ++++++++------ cmd-queue.c | 2 +- cmd.c | 106 +++++++++++++++++++++++++++++++++++++--------------- tmux.h | 10 +++-- 4 files changed, 100 insertions(+), 47 deletions(-) diff --git a/cmd-find.c b/cmd-find.c index c76dc4a2d..7ffc5f15d 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -923,15 +923,27 @@ cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp) return (0); } +/* Find current state. */ +int +cmd_find_current(struct cmd_find_state *fs, struct cmd_q *cmdq, int flags) +{ + cmd_find_clear_state(fs, cmdq, flags); + if (cmd_find_current_session(fs) != 0) { + if (~flags & CMD_FIND_QUIET) + cmdq_error(cmdq, "no current session"); + return (-1); + } + return (0); +} + /* * Split target into pieces and resolve for the given type. Fills in the given * state. Returns 0 on success or -1 on error. */ int -cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq, - const char *target, enum cmd_find_type type, int flags) +cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current, + struct cmd_q *cmdq, const char *target, enum cmd_find_type type, int flags) { - struct cmd_find_state current; struct mouse_event *m; char *colon, *period, *copy = NULL; const char *session, *window, *pane; @@ -951,15 +963,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq, fs->current = &marked_pane; else if (cmd_find_valid_state(&cmdq->current)) fs->current = &cmdq->current; - else { - cmd_find_clear_state(¤t, cmdq, flags); - if (cmd_find_current_session(¤t) != 0) { - if (~flags & CMD_FIND_QUIET) - cmdq_error(cmdq, "no current session"); - goto error; - } - fs->current = ¤t; - } + else + fs->current = current; /* An empty or NULL target is the current. */ if (target == NULL || *target == '\0') diff --git a/cmd-queue.c b/cmd-queue.c index fcca7eb62..1c80c59d5 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -199,7 +199,7 @@ cmdq_continue_one(struct cmd_q *cmdq) cmdq_guard(cmdq, "begin", flags); - if (cmd_prepare_state(cmd, cmdq) != 0) + if (cmd_prepare_state(cmd, cmdq, NULL) != 0) goto error; retval = cmd->entry->exec(cmd, cmdq); if (retval == CMD_RETURN_ERROR) diff --git a/cmd.c b/cmd.c index 052c095ba..005f2a0f3 100644 --- a/cmd.c +++ b/cmd.c @@ -389,10 +389,23 @@ cmd_parse(int argc, char **argv, const char *file, u_int line, char **cause) } static int -cmd_prepare_state_flag(struct cmd_find_state *fs, enum cmd_entry_flag flag, - const char *target, struct cmd_q *cmdq) +cmd_prepare_state_flag(char c, const char *target, enum cmd_entry_flag flag, + struct cmd_q *cmdq, struct cmd_q *parent) { - int targetflags, error; + int targetflags, error; + struct cmd_find_state *fs = NULL; + struct cmd_find_state *current = NULL; + struct cmd_find_state tmp; + + if (flag == CMD_NONE || + flag == CMD_CLIENT || + flag == CMD_CLIENT_CANFAIL) + return (0); + + if (c == 't') + fs = &cmdq->state.tflag; + else if (c == 's') + fs = &cmdq->state.sflag; if (flag == CMD_SESSION_WITHPANE) { if (target != NULL && target[strcspn(target, ":.")] != '\0') @@ -401,70 +414,101 @@ cmd_prepare_state_flag(struct cmd_find_state *fs, enum cmd_entry_flag flag, flag = CMD_SESSION; } + targetflags = 0; switch (flag) { - case CMD_NONE: - case CMD_CLIENT: - case CMD_CLIENT_CANFAIL: - return (0); case CMD_SESSION: case CMD_SESSION_CANFAIL: case CMD_SESSION_PREFERUNATTACHED: - case CMD_SESSION_WITHPANE: - targetflags = 0; if (flag == CMD_SESSION_CANFAIL) targetflags |= CMD_FIND_QUIET; if (flag == CMD_SESSION_PREFERUNATTACHED) targetflags |= CMD_FIND_PREFER_UNATTACHED; - - error = cmd_find_target(fs, cmdq, target, CMD_FIND_SESSION, - targetflags); - if (error != 0 && flag != CMD_SESSION_CANFAIL) - return (-1); break; case CMD_MOVEW_R: - error = cmd_find_target(fs, cmdq, target, CMD_FIND_SESSION, - CMD_FIND_QUIET); - if (error == 0) - break; flag = CMD_WINDOW_INDEX; /* FALLTHROUGH */ case CMD_WINDOW: case CMD_WINDOW_CANFAIL: case CMD_WINDOW_MARKED: case CMD_WINDOW_INDEX: - targetflags = 0; if (flag == CMD_WINDOW_CANFAIL) targetflags |= CMD_FIND_QUIET; if (flag == CMD_WINDOW_MARKED) targetflags |= CMD_FIND_DEFAULT_MARKED; if (flag == CMD_WINDOW_INDEX) targetflags |= CMD_FIND_WINDOW_INDEX; - - error = cmd_find_target(fs, cmdq, target, CMD_FIND_WINDOW, - targetflags); - if (error != 0 && flag != CMD_WINDOW_CANFAIL) - return (-1); break; case CMD_PANE: case CMD_PANE_CANFAIL: case CMD_PANE_MARKED: - targetflags = 0; if (flag == CMD_PANE_CANFAIL) targetflags |= CMD_FIND_QUIET; if (flag == CMD_PANE_MARKED) targetflags |= CMD_FIND_DEFAULT_MARKED; + break; + default: + fatalx("unknown %cflag %d", c, flag); + } - error = cmd_find_target(fs, cmdq, target, CMD_FIND_PANE, - targetflags); - if (error != 0 && flag != CMD_PANE_CANFAIL) + log_debug("%s: flag %c %d %#x", __func__, c, flag, targetflags); + if (parent != NULL) { + if (c == 't') + current = &parent->state.tflag; + else if (c == 's') + current = &parent->state.sflag; + } else { + error = cmd_find_current(&tmp, cmdq, targetflags); + if (error != 0 && ~targetflags & CMD_FIND_QUIET) + return (-1); + current = &tmp; + } + + switch (flag) { + case CMD_NONE: + case CMD_CLIENT: + case CMD_CLIENT_CANFAIL: + return (0); + case CMD_SESSION: + case CMD_SESSION_CANFAIL: + case CMD_SESSION_PREFERUNATTACHED: + case CMD_SESSION_WITHPANE: + error = cmd_find_target(fs, current, cmdq, target, + CMD_FIND_SESSION, targetflags); + if (error != 0 && ~targetflags & CMD_FIND_QUIET) return (-1); break; + case CMD_MOVEW_R: + error = cmd_find_target(fs, current, cmdq, target, + CMD_FIND_SESSION, CMD_FIND_QUIET); + if (error == 0) + break; + flag = CMD_WINDOW_INDEX; + /* FALLTHROUGH */ + case CMD_WINDOW: + case CMD_WINDOW_CANFAIL: + case CMD_WINDOW_MARKED: + case CMD_WINDOW_INDEX: + error = cmd_find_target(fs, current, cmdq, target, + CMD_FIND_WINDOW, targetflags); + if (error != 0 && ~targetflags & CMD_FIND_QUIET) + return (-1); + break; + case CMD_PANE: + case CMD_PANE_CANFAIL: + case CMD_PANE_MARKED: + error = cmd_find_target(fs, current, cmdq, target, + CMD_FIND_PANE, targetflags); + if (error != 0 && ~targetflags & CMD_FIND_QUIET) + return (-1); + break; + default: + fatalx("unknown %cflag %d", c, flag); } return (0); } int -cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq) +cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq, struct cmd_q *parent) { const struct cmd_entry *entry = cmd->entry; struct cmd_state *state = &cmdq->state; @@ -504,14 +548,14 @@ cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq) s = args_get(cmd->args, 't'); log_debug("preparing -t state: target %s", s == NULL ? "none" : s); - error = cmd_prepare_state_flag(&state->tflag, entry->tflag, s, cmdq); + error = cmd_prepare_state_flag('t', s, entry->tflag, cmdq, parent); if (error != 0) return (error); s = args_get(cmd->args, 's'); log_debug("preparing -s state: target %s", s == NULL ? "none" : s); - error = cmd_prepare_state_flag(&state->sflag, entry->sflag, s, cmdq); + error = cmd_prepare_state_flag('s', s, entry->sflag, cmdq, parent); if (error != 0) return (error); diff --git a/tmux.h b/tmux.h index 941548d04..eb3373da9 100644 --- a/tmux.h +++ b/tmux.h @@ -1769,8 +1769,11 @@ long long args_strtonum(struct args *, u_char, long long, long long, char **); /* cmd-find.c */ -int cmd_find_target(struct cmd_find_state *, struct cmd_q *, - const char *, enum cmd_find_type, int); +int cmd_find_current(struct cmd_find_state *, struct cmd_q *, + int); +int cmd_find_target(struct cmd_find_state *, + struct cmd_find_state *, struct cmd_q *, const char *, + enum cmd_find_type, int); struct client *cmd_find_client(struct cmd_q *, const char *, int); void cmd_find_clear_state(struct cmd_find_state *, struct cmd_q *, int); @@ -1793,7 +1796,8 @@ char **cmd_copy_argv(int, char **); void cmd_free_argv(int, char **); char *cmd_stringify_argv(int, char **); struct cmd *cmd_parse(int, char **, const char *, u_int, char **); -int cmd_prepare_state(struct cmd *, struct cmd_q *); +int cmd_prepare_state(struct cmd *, struct cmd_q *, + struct cmd_q *); char *cmd_print(struct cmd *); int cmd_mouse_at(struct window_pane *, struct mouse_event *, u_int *, u_int *, int); From ca29dc9abc5c90da1a56d06ecb692b35a3766bc0 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 19 Jan 2016 18:07:25 +0000 Subject: [PATCH 07/47] Update my email address. --- compat.h | 2 +- compat/asprintf.c | 2 +- compat/cfmakeraw.c | 2 +- compat/forkpty-aix.c | 2 +- compat/forkpty-hpux.c | 2 +- compat/forkpty-sunos.c | 2 +- compat/openat.c | 2 +- compat/setenv.c | 2 +- osdep-aix.c | 2 +- osdep-cygwin.c | 2 +- osdep-dragonfly.c | 2 +- osdep-freebsd.c | 2 +- osdep-hpux.c | 2 +- osdep-linux.c | 2 +- osdep-netbsd.c | 2 +- osdep-unknown.c | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/compat.h b/compat.h index 6812e9a54..b2267d379 100644 --- a/compat.h +++ b/compat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Nicholas Marriott + * Copyright (c) 2007 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 diff --git a/compat/asprintf.c b/compat/asprintf.c index 09020b356..5ed1c48c1 100644 --- a/compat/asprintf.c +++ b/compat/asprintf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006 Nicholas Marriott + * Copyright (c) 2006 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 diff --git a/compat/cfmakeraw.c b/compat/cfmakeraw.c index 85b2c9bc9..d87940816 100644 --- a/compat/cfmakeraw.c +++ b/compat/cfmakeraw.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2013 Dagobert Michelsen - * Copyright (c) 2013 Nicholas Marriott + * 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 diff --git a/compat/forkpty-aix.c b/compat/forkpty-aix.c index 6894aa448..2557ebf79 100644 --- a/compat/forkpty-aix.c +++ b/compat/forkpty-aix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/compat/forkpty-hpux.c b/compat/forkpty-hpux.c index 59130e1bd..09b27d088 100644 --- a/compat/forkpty-hpux.c +++ b/compat/forkpty-hpux.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/compat/forkpty-sunos.c b/compat/forkpty-sunos.c index 554e51ac8..9abda46ca 100644 --- a/compat/forkpty-sunos.c +++ b/compat/forkpty-sunos.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Nicholas Marriott + * Copyright (c) 2008 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 diff --git a/compat/openat.c b/compat/openat.c index 6b04eedcd..d003e53dd 100644 --- a/compat/openat.c +++ b/compat/openat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Nicholas Marriott + * 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 diff --git a/compat/setenv.c b/compat/setenv.c index 6c7d29ecb..b16b08cf7 100644 --- a/compat/setenv.c +++ b/compat/setenv.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2010 Dagobert Michelsen - * Copyright (c) 2010 Nicholas Marriott + * Copyright (c) 2010 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 diff --git a/osdep-aix.c b/osdep-aix.c index ef7d6c7ef..e1ce49180 100644 --- a/osdep-aix.c +++ b/osdep-aix.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2011 Nicholas Marriott + * Copyright (c) 2011 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 diff --git a/osdep-cygwin.c b/osdep-cygwin.c index 9a3ea408a..60630b335 100644 --- a/osdep-cygwin.c +++ b/osdep-cygwin.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/osdep-dragonfly.c b/osdep-dragonfly.c index f9b0efcf9..879034e80 100644 --- a/osdep-dragonfly.c +++ b/osdep-dragonfly.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/osdep-freebsd.c b/osdep-freebsd.c index d7f419b87..067ba5653 100644 --- a/osdep-freebsd.c +++ b/osdep-freebsd.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/osdep-hpux.c b/osdep-hpux.c index a6d75f948..16993b93d 100644 --- a/osdep-hpux.c +++ b/osdep-hpux.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/osdep-linux.c b/osdep-linux.c index 00501efb0..42712dea3 100644 --- a/osdep-linux.c +++ b/osdep-linux.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/osdep-netbsd.c b/osdep-netbsd.c index 156868605..d8aa41b55 100644 --- a/osdep-netbsd.c +++ b/osdep-netbsd.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 diff --git a/osdep-unknown.c b/osdep-unknown.c index 9465db97e..bc59f5699 100644 --- a/osdep-unknown.c +++ b/osdep-unknown.c @@ -1,7 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2009 Nicholas Marriott + * Copyright (c) 2009 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 From 1d6bd50343f4395879169868e47bb59f5b2f3811 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 29 Jan 2016 10:58:08 +0000 Subject: [PATCH 08/47] libevent.org URL. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 6a78fa2bf..88d77b5f4 100644 --- a/README +++ b/README @@ -8,7 +8,7 @@ This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris. tmux depends on libevent 2.x. Download it from: - http://www.monkey.org/~provos/libevent/ + http://libevent.org To build tmux from a release tarball, do: From 427b8204268af5548d09b830e101c59daa095df9 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 29 Jan 2016 11:13:56 +0000 Subject: [PATCH 09/47] Support for RGB colour, using the extended cell mechanism to avoid wasting unnecessary space. The 'Tc' flag must be set in the external TERM entry (using terminal-overrides or a custom terminfo entry), if not tmux will map to the closest of the 256 or 16 colour palettes. Mostly from Suraj N Kurapati, based on a diff originally by someone else. --- grid.c | 11 +++- input.c | 35 ++++++---- tmux.1 | 12 ++-- tmux.h | 20 +++++- tty-term.c | 1 + tty.c | 185 ++++++++++++++++++++++++++++++++++++++++++++--------- 6 files changed, 209 insertions(+), 55 deletions(-) diff --git a/grid.c b/grid.c index c24e6c6a4..782032f40 100644 --- a/grid.c +++ b/grid.c @@ -37,7 +37,7 @@ /* Default grid cell data. */ const struct grid_cell grid_default_cell = { - 0, 0, 8, 8, { { ' ' }, 0, 1, 1 } + 0, 0, { .fg = 8 }, { .bg = 8 }, { { ' ' }, 0, 1, 1 } }; const struct grid_cell_entry grid_default_entry = { 0, { .data = { 0, 8, 8, ' ' } } @@ -284,6 +284,7 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) struct grid_line *gl; struct grid_cell_entry *gce; struct grid_cell *gcp; + int extended; if (grid_check_y(gd, py) != 0) return; @@ -293,8 +294,12 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) gl = &gd->linedata[py]; gce = &gl->celldata[px]; - if ((gce->flags & GRID_FLAG_EXTENDED) || gc->data.size != 1 || - gc->data.width != 1) { + extended = (gce->flags & GRID_FLAG_EXTENDED); + if (!extended && (gc->data.size != 1 || gc->data.width != 1)) + extended = 1; + if (!extended && (gc->flags & (GRID_FLAG_FGRGB|GRID_FLAG_BGRGB))) + extended = 1; + if (extended) { if (~gce->flags & GRID_FLAG_EXTENDED) { gl->extddata = xreallocarray(gl->extddata, gl->extdsize + 1, sizeof *gl->extddata); diff --git a/input.c b/input.c index 1772a4cde..ae2050241 100644 --- a/input.c +++ b/input.c @@ -1629,18 +1629,20 @@ input_csi_dispatch_sgr_256(struct input_ctx *ictx, int fgbg, u_int *i) c = input_get(ictx, *i, 0, -1); if (c == -1) { if (fgbg == 38) { - gc->flags &= ~GRID_FLAG_FG256; + gc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB); gc->fg = 8; } else if (fgbg == 48) { - gc->flags &= ~GRID_FLAG_BG256; + gc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB); gc->bg = 8; } } else { if (fgbg == 38) { gc->flags |= GRID_FLAG_FG256; + gc->flags &= ~GRID_FLAG_FGRGB; gc->fg = c; } else if (fgbg == 48) { gc->flags |= GRID_FLAG_BG256; + gc->flags &= ~GRID_FLAG_BGRGB; gc->bg = c; } } @@ -1651,7 +1653,7 @@ void input_csi_dispatch_sgr_rgb(struct input_ctx *ictx, int fgbg, u_int *i) { struct grid_cell *gc = &ictx->cell.cell; - int c, r, g, b; + int r, g, b; (*i)++; r = input_get(ictx, *i, 0, -1); @@ -1666,13 +1668,18 @@ input_csi_dispatch_sgr_rgb(struct input_ctx *ictx, int fgbg, u_int *i) if (b == -1 || b > 255) return; - c = colour_find_rgb(r, g, b); if (fgbg == 38) { - gc->flags |= GRID_FLAG_FG256; - gc->fg = c; + gc->flags &= ~GRID_FLAG_FG256; + gc->flags |= GRID_FLAG_FGRGB; + gc->fg_rgb.r = r; + gc->fg_rgb.g = g; + gc->fg_rgb.b = b; } else if (fgbg == 48) { - gc->flags |= GRID_FLAG_BG256; - gc->bg = c; + gc->flags &= ~GRID_FLAG_BG256; + gc->flags |= GRID_FLAG_BGRGB; + gc->bg_rgb.r = r; + gc->bg_rgb.g = g; + gc->bg_rgb.b = b; } } @@ -1754,11 +1761,11 @@ input_csi_dispatch_sgr(struct input_ctx *ictx) case 35: case 36: case 37: - gc->flags &= ~GRID_FLAG_FG256; + gc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB); gc->fg = n - 30; break; case 39: - gc->flags &= ~GRID_FLAG_FG256; + gc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB); gc->fg = 8; break; case 40: @@ -1769,11 +1776,11 @@ input_csi_dispatch_sgr(struct input_ctx *ictx) case 45: case 46: case 47: - gc->flags &= ~GRID_FLAG_BG256; + gc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB); gc->bg = n - 40; break; case 49: - gc->flags &= ~GRID_FLAG_BG256; + gc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB); gc->bg = 8; break; case 90: @@ -1784,7 +1791,7 @@ input_csi_dispatch_sgr(struct input_ctx *ictx) case 95: case 96: case 97: - gc->flags &= ~GRID_FLAG_FG256; + gc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB); gc->fg = n; break; case 100: @@ -1795,7 +1802,7 @@ input_csi_dispatch_sgr(struct input_ctx *ictx) case 105: case 106: case 107: - gc->flags &= ~GRID_FLAG_BG256; + gc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB); gc->bg = n - 10; break; } diff --git a/tmux.1 b/tmux.1 index e41ba7981..e70b07c34 100644 --- a/tmux.1 +++ b/tmux.1 @@ -2921,7 +2921,7 @@ and poor for interactive programs such as shells. .Op Ic on | off .Xc Allow programs to change the window name using a terminal escape -sequence (\\033k...\\033\\\\). +sequence (\eek...\ee\e\e). The default is on. .Pp .It Xo Ic alternate-screen @@ -4024,7 +4024,7 @@ This command only works from outside .El .Sh TERMINFO EXTENSIONS .Nm -understands some extensions to +understands some unofficial extensions to .Xr terminfo 5 : .Bl -tag -width Ds .It Em Cs , Cr @@ -4048,10 +4048,12 @@ $ printf '\e033[4 q' If .Em Se is not set, \&Ss with argument 0 will be used to reset the cursor style instead. +.It Em \&Tc +Indicate that the terminal supports the +.Ql direct colour +RGB escape sequence (for example, \ee[38;2;255;255;255m). .It Em \&Ms -This sequence can be used by -.Nm -to store the current buffer in the host terminal's selection (clipboard). +Store the current buffer in the host terminal's selection (clipboard). See the .Em set-clipboard option above and the diff --git a/tmux.h b/tmux.h index eb3373da9..8edb92090 100644 --- a/tmux.h +++ b/tmux.h @@ -385,6 +385,7 @@ enum tty_code_code { TTYC_SMSO, /* enter_standout_mode, so */ TTYC_SMUL, /* enter_underline_mode, us */ TTYC_SS, /* set cursor style, Ss */ + TTYC_TC, /* 24-bit "true" colour, Tc */ TTYC_TSL, /* to_status_line, tsl */ TTYC_VPA, /* row_address, cv */ TTYC_XENL, /* eat_newline_glitch, xn */ @@ -641,16 +642,31 @@ enum utf8_state { #define GRID_FLAG_BG256 0x2 #define GRID_FLAG_PADDING 0x4 #define GRID_FLAG_EXTENDED 0x8 +#define GRID_FLAG_FGRGB 0x10 +#define GRID_FLAG_BGRGB 0x20 /* Grid line flags. */ #define GRID_LINE_WRAPPED 0x1 +/* Grid cell RGB colours. */ +struct grid_cell_rgb { + u_char r; + u_char g; + u_char b; +}; + /* Grid cell data. */ struct grid_cell { u_char flags; u_char attr; - u_char fg; - u_char bg; + union { + u_char fg; + struct grid_cell_rgb fg_rgb; + }; + union { + u_char bg; + struct grid_cell_rgb bg_rgb; + }; struct utf8_data data; }; diff --git a/tty-term.c b/tty-term.c index 8716a1a95..05ef01e78 100644 --- a/tty-term.c +++ b/tty-term.c @@ -251,6 +251,7 @@ const struct tty_term_code_entry tty_term_codes[] = { [TTYC_SMSO] = { TTYCODE_STRING, "smso" }, [TTYC_SMUL] = { TTYCODE_STRING, "smul" }, [TTYC_SS] = { TTYCODE_STRING, "Ss" }, + [TTYC_TC] = { TTYCODE_FLAG, "Tc" }, [TTYC_TSL] = { TTYCODE_STRING, "tsl" }, [TTYC_VPA] = { TTYCODE_STRING, "vpa" }, [TTYC_XENL] = { TTYCODE_FLAG, "xenl" }, diff --git a/tty.c b/tty.c index 52521be9c..c6fc22134 100644 --- a/tty.c +++ b/tty.c @@ -36,8 +36,15 @@ static int tty_log_fd = -1; void tty_read_callback(struct bufferevent *, void *); void tty_error_callback(struct bufferevent *, short, void *); +static int tty_same_fg(const struct grid_cell *, const struct grid_cell *); +static int tty_same_bg(const struct grid_cell *, const struct grid_cell *); +static int tty_same_colours(const struct grid_cell *, const struct grid_cell *); +static int tty_is_fg(const struct grid_cell *, int); +static int tty_is_bg(const struct grid_cell *, int); + void tty_set_italics(struct tty *); int tty_try_256(struct tty *, u_char, const char *); +int tty_try_rgb(struct tty *, const struct grid_cell_rgb *, const char *); void tty_colours(struct tty *, const struct grid_cell *); void tty_check_fg(struct tty *, struct grid_cell *); @@ -61,6 +68,74 @@ void tty_default_colours(struct grid_cell *, const struct window_pane *); #define tty_pane_full_width(tty, ctx) \ ((ctx)->xoff == 0 && screen_size_x((ctx)->wp->screen) >= (tty)->sx) +static int +tty_same_fg(const struct grid_cell *gc1, const struct grid_cell *gc2) +{ + int flags1, flags2; + + flags1 = (gc1->flags & (GRID_FLAG_FG256|GRID_FLAG_FGRGB)); + flags2 = (gc2->flags & (GRID_FLAG_FG256|GRID_FLAG_FGRGB)); + + if (flags1 != flags2) + return (0); + + if (flags1 & GRID_FLAG_FGRGB) { + if (gc1->fg_rgb.r != gc2->fg_rgb.r) + return (0); + if (gc1->fg_rgb.g != gc2->fg_rgb.g) + return (0); + if (gc1->fg_rgb.b != gc2->fg_rgb.b) + return (0); + return (1); + } + return (gc1->fg == gc2->fg); +} + +static int +tty_same_bg(const struct grid_cell *gc1, const struct grid_cell *gc2) +{ + int flags1, flags2; + + flags1 = (gc1->flags & (GRID_FLAG_BG256|GRID_FLAG_BGRGB)); + flags2 = (gc2->flags & (GRID_FLAG_BG256|GRID_FLAG_BGRGB)); + + if (flags1 != flags2) + return (0); + + if (flags1 & GRID_FLAG_BGRGB) { + if (gc1->bg_rgb.r != gc2->bg_rgb.r) + return (0); + if (gc1->bg_rgb.g != gc2->bg_rgb.g) + return (0); + if (gc1->bg_rgb.b != gc2->bg_rgb.b) + return (0); + return (1); + } + return (gc1->bg == gc2->bg); +} + +static int +tty_same_colours(const struct grid_cell *gc1, const struct grid_cell *gc2) +{ + return (tty_same_fg(gc1, gc2) && tty_same_bg(gc1, gc2)); +} + +static int +tty_is_fg(const struct grid_cell *gc, int c) +{ + if (gc->flags & (GRID_FLAG_FG256|GRID_FLAG_FGRGB)) + return (0); + return (gc->fg == c); +} + +static int +tty_is_bg(const struct grid_cell *gc, int c) +{ + if (gc->flags & (GRID_FLAG_BG256|GRID_FLAG_BGRGB)) + return (0); + return (gc->bg == c); +} + void tty_create_log(void) { @@ -1423,12 +1498,10 @@ void tty_colours(struct tty *tty, const struct grid_cell *gc) { struct grid_cell *tc = &tty->cell; - u_char fg = gc->fg, bg = gc->bg, flags = gc->flags; int have_ax, fg_default, bg_default; /* No changes? Nothing is necessary. */ - if (fg == tc->fg && bg == tc->bg && - ((flags ^ tc->flags) & (GRID_FLAG_FG256|GRID_FLAG_BG256)) == 0) + if (tty_same_colours(gc, tc)) return; /* @@ -1437,8 +1510,8 @@ tty_colours(struct tty *tty, const struct grid_cell *gc) * case if only one is default need to fall onward to set the other * colour. */ - fg_default = (fg == 8 && !(flags & GRID_FLAG_FG256)); - bg_default = (bg == 8 && !(flags & GRID_FLAG_BG256)); + fg_default = tty_is_fg(gc, 8); + bg_default = tty_is_bg(gc, 8); if (fg_default || bg_default) { /* * If don't have AX but do have op, send sgr0 (op can't @@ -1451,48 +1524,52 @@ tty_colours(struct tty *tty, const struct grid_cell *gc) if (!have_ax && tty_term_has(tty->term, TTYC_OP)) tty_reset(tty); else { - if (fg_default && - (tc->fg != 8 || tc->flags & GRID_FLAG_FG256)) { + if (fg_default && !tty_is_fg(tc, 8)) { if (have_ax) tty_puts(tty, "\033[39m"); - else if (tc->fg != 7 || - tc->flags & GRID_FLAG_FG256) + else if (!tty_is_fg(tc, 7)) tty_putcode1(tty, TTYC_SETAF, 7); tc->fg = 8; - tc->flags &= ~GRID_FLAG_FG256; + tc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB); } - if (bg_default && - (tc->bg != 8 || tc->flags & GRID_FLAG_BG256)) { + if (bg_default && !tty_is_bg(tc, 8)) { if (have_ax) tty_puts(tty, "\033[49m"); - else if (tc->bg != 0 || - tc->flags & GRID_FLAG_BG256) + else if (!tty_is_bg(tc, 0)) tty_putcode1(tty, TTYC_SETAB, 0); tc->bg = 8; - tc->flags &= ~GRID_FLAG_BG256; + tc->flags &= ~(GRID_FLAG_BG256|GRID_FLAG_BGRGB); } } } /* Set the foreground colour. */ - if (!fg_default && (fg != tc->fg || - ((flags & GRID_FLAG_FG256) != (tc->flags & GRID_FLAG_FG256)))) + if (!fg_default && !tty_same_fg(gc, tc)) tty_colours_fg(tty, gc); /* * Set the background colour. This must come after the foreground as * tty_colour_fg() can call tty_reset(). */ - if (!bg_default && (bg != tc->bg || - ((flags & GRID_FLAG_BG256) != (tc->flags & GRID_FLAG_BG256)))) + if (!bg_default && !tty_same_bg(gc, tc)) tty_colours_bg(tty, gc); } void tty_check_fg(struct tty *tty, struct grid_cell *gc) { - u_int colours; + struct grid_cell_rgb *rgb = &gc->fg_rgb; + u_int colours; + /* Is this a 24-bit colour? */ + if (gc->flags & GRID_FLAG_FGRGB) { + /* Not a 24-bit terminal? Translate to 256-colour palette. */ + if (!tty_term_flag(tty->term, TTYC_TC)) { + gc->flags &= ~GRID_FLAG_FGRGB; + gc->flags |= GRID_FLAG_FG256; + gc->fg = colour_find_rgb(rgb->r, rgb->g, rgb->b); + } + } colours = tty_term_number(tty->term, TTYC_COLORS); /* Is this a 256-colour colour? */ @@ -1524,8 +1601,18 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc) void tty_check_bg(struct tty *tty, struct grid_cell *gc) { - u_int colours; + struct grid_cell_rgb *rgb = &gc->bg_rgb; + u_int colours; + /* Is this a 24-bit colour? */ + if (gc->flags & GRID_FLAG_BGRGB) { + /* Not a 24-bit terminal? Translate to 256-colour palette. */ + if (!tty_term_flag(tty->term, TTYC_TC)) { + gc->flags &= ~GRID_FLAG_BGRGB; + gc->flags |= GRID_FLAG_BG256; + gc->bg = colour_find_rgb(rgb->r, rgb->g, rgb->b); + } + } colours = tty_term_number(tty->term, TTYC_COLORS); /* Is this a 256-colour colour? */ @@ -1560,12 +1647,21 @@ tty_colours_fg(struct tty *tty, const struct grid_cell *gc) u_char fg = gc->fg; char s[32]; + tc->flags &= ~(GRID_FLAG_FG256|GRID_FLAG_FGRGB); + + /* Is this a 24-bit colour? */ + if (gc->flags & GRID_FLAG_FGRGB) { + if (tty_try_rgb(tty, &gc->fg_rgb, "38") == 0) + goto save_fg; + /* Should not get here, already converted in tty_check_fg. */ + return; + } + /* Is this a 256-colour colour? */ if (gc->flags & GRID_FLAG_FG256) { - /* Try as 256 colours. */ if (tty_try_256(tty, fg, "38") == 0) goto save_fg; - /* Else already handled by tty_check_fg. */ + /* Should not get here, already converted in tty_check_fg. */ return; } @@ -1581,9 +1677,12 @@ tty_colours_fg(struct tty *tty, const struct grid_cell *gc) save_fg: /* Save the new values in the terminal current cell. */ - tc->fg = fg; - tc->flags &= ~GRID_FLAG_FG256; - tc->flags |= gc->flags & GRID_FLAG_FG256; + if (gc->flags & GRID_FLAG_FGRGB) + memcpy(&tc->fg_rgb, &gc->fg_rgb, sizeof tc->fg_rgb); + else + tc->fg = fg; + tc->flags &= ~(GRID_FLAG_FGRGB|GRID_FLAG_FG256); + tc->flags |= (gc->flags & (GRID_FLAG_FG256|GRID_FLAG_FGRGB)); } void @@ -1593,12 +1692,19 @@ tty_colours_bg(struct tty *tty, const struct grid_cell *gc) u_char bg = gc->bg; char s[32]; + /* Is this a 24-bit colour? */ + if (gc->flags & GRID_FLAG_BGRGB) { + if (tty_try_rgb(tty, &gc->bg_rgb, "48") == 0) + goto save_bg; + /* Should not get here, already converted in tty_check_bg. */ + return; + } + /* Is this a 256-colour colour? */ if (gc->flags & GRID_FLAG_BG256) { - /* Try as 256 colours. */ if (tty_try_256(tty, bg, "48") == 0) goto save_bg; - /* Else already handled by tty_check_bg. */ + /* Should not get here, already converted in tty_check_bg. */ return; } @@ -1614,9 +1720,12 @@ tty_colours_bg(struct tty *tty, const struct grid_cell *gc) save_bg: /* Save the new values in the terminal current cell. */ - tc->bg = bg; - tc->flags &= ~GRID_FLAG_BG256; - tc->flags |= gc->flags & GRID_FLAG_BG256; + if (gc->flags & GRID_FLAG_BGRGB) + memcpy(&tc->bg_rgb, &gc->bg_rgb, sizeof tc->bg_rgb); + else + tc->bg = bg; + tc->flags &= ~(GRID_FLAG_BGRGB|GRID_FLAG_BG256); + tc->flags |= (gc->flags & (GRID_FLAG_BG256|GRID_FLAG_BGRGB)); } int @@ -1656,6 +1765,20 @@ tty_try_256(struct tty *tty, u_char colour, const char *type) return (0); } +int +tty_try_rgb(struct tty *tty, const struct grid_cell_rgb *rgb, const char *type) +{ + char s[32]; + + if (!tty_term_flag(tty->term, TTYC_TC)) + return (-1); + + xsnprintf(s, sizeof s, "\033[%s;2;%hhu;%hhu;%hhum", type, rgb->r, + rgb->g, rgb->b); + tty_puts(tty, s); + return (0); +} + void tty_default_colours(struct grid_cell *gc, const struct window_pane *wp) { From a33bb3e876895ef40ee90e5f89c76184e65c7f10 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 29 Jan 2016 14:40:30 +0000 Subject: [PATCH 10/47] Link to the bash(1) completion file from README rather than including it in examples. --- README | 4 ++ examples/bash_completion_tmux.sh | 105 ------------------------------- 2 files changed, 4 insertions(+), 105 deletions(-) delete mode 100644 examples/bash_completion_tmux.sh diff --git a/README b/README index 88d77b5f4..c0102e68a 100644 --- a/README +++ b/README @@ -40,6 +40,10 @@ A vim(1) syntax file is available at: https://github.com/keith/tmux.vim https://raw.githubusercontent.com/keith/tmux.vim/master/syntax/tmux.vim +And a bash(1) completion file at: + + https://github.com/przepompownia/tmux-bash-completion + For debugging, running tmux with -v or -vv will generate server and client log files in the current directory. diff --git a/examples/bash_completion_tmux.sh b/examples/bash_completion_tmux.sh deleted file mode 100644 index 74728b91e..000000000 --- a/examples/bash_completion_tmux.sh +++ /dev/null @@ -1,105 +0,0 @@ -# START tmux completion -# This file is in the public domain -# See: http://www.debian-administration.org/articles/317 for how to write more. -# Usage: Put "source bash_completion_tmux.sh" into your .bashrc -_tmux() -{ - local cur prev opts - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - - opts=" \ - attach-session \ - bind-key \ - break-pane \ - capture-pane \ - choose-client \ - choose-session \ - choose-window \ - clear-history \ - clock-mode \ - command-prompt \ - confirm-before \ - copy-buffer \ - copy-mode \ - delete-buffer \ - detach-client \ - display-message \ - display-panes \ - down-pane \ - find-window \ - has-session \ - if-shell \ - join-pane \ - kill-pane \ - kill-server \ - kill-session \ - kill-window \ - last-window \ - link-window \ - list-buffers \ - list-clients \ - list-commands \ - list-keys \ - list-panes \ - list-sessions \ - list-windows \ - load-buffer \ - lock-client \ - lock-server \ - lock-session \ - move-window \ - new-session \ - new-window \ - next-layout \ - next-window \ - paste-buffer \ - pipe-pane \ - previous-layout \ - previous-window \ - refresh-client \ - rename-session \ - rename-window \ - resize-pane \ - respawn-window \ - rotate-window \ - run-shell \ - save-buffer \ - select-layout \ - select-pane \ - select-prompt \ - select-window \ - send-keys \ - send-prefix \ - server-info \ - set-buffer \ - set-environment \ - set-option \ - set-window-option \ - show-buffer \ - show-environment \ - show-messages \ - show-options \ - show-window-options \ - source-file \ - split-window \ - start-server \ - suspend-client \ - swap-pane \ - swap-window \ - switch-client \ - unbind-key \ - unlink-window \ - up-pane" - - COMPREPLY=($(compgen -W "${opts}" -- ${cur})) - return 0 - -} -complete -F _tmux tmux - -# END tmux completion - - - From 2a1bb91bf73366b89d27f2ecfacdc770ceecb72e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 29 Jan 2016 14:53:28 +0000 Subject: [PATCH 11/47] Remove old examples in favour of one example configuration file. --- README | 2 +- example_tmux.conf | 66 +++++++++++++++++++++++ examples/h-boetes.conf | 42 --------------- examples/n-marriott.conf | 110 -------------------------------------- examples/screen-keys.conf | 102 ----------------------------------- examples/t-williams.conf | 104 ----------------------------------- examples/vim-keys.conf | 36 ------------- examples/xterm-keys.vim | 49 ----------------- 8 files changed, 67 insertions(+), 444 deletions(-) create mode 100644 example_tmux.conf delete mode 100644 examples/h-boetes.conf delete mode 100644 examples/n-marriott.conf delete mode 100644 examples/screen-keys.conf delete mode 100644 examples/t-williams.conf delete mode 100644 examples/vim-keys.conf delete mode 100644 examples/xterm-keys.vim diff --git a/README b/README index c0102e68a..dbc9b173f 100644 --- a/README +++ b/README @@ -33,7 +33,7 @@ the source tree with: Some common questions are answered in the FAQ file and a more extensive (but slightly out of date) guide is available in the OpenBSD FAQ at http://www.openbsd.org/faq/faq7.html#tmux. A rough todo list is in the TODO -file and some example configurations are in the examples directory. +file and an example configuration in example_tmux.conf. A vim(1) syntax file is available at: diff --git a/example_tmux.conf b/example_tmux.conf new file mode 100644 index 000000000..f659a3c25 --- /dev/null +++ b/example_tmux.conf @@ -0,0 +1,66 @@ +# +# Example .tmux.conf +# +# By Nicholas Marriott. Public domain. +# + +# Some tweaks to the status line +set -g status-bg green +set -g status-right "%H:%M" +set -g window-status-current-attr "underscore" + +# No bells at all +set -g bell-action none + +# Lock after 15 minutes +set -g lock-after-time 1800 + +# Keep windows around after they exit +set -g remain-on-exit on + +# Turn on xterm-keys so that additional function keys get escape sequences +set -g xterm-keys on + +# Change the prefix key to C-a +set -g prefix C-a +unbind C-b +bind C-a send-prefix + +# Turn the mouse on, but without copy mode dragging +set -g mouse on +unbind -n MouseDrag1Pane +unbind -temacs-copy MouseDrag1Pane + +# Some extra key bindings to select higher numbered windows +bind F1 selectw -t:10 +bind F2 selectw -t:11 +bind F3 selectw -t:12 +bind F4 selectw -t:13 +bind F5 selectw -t:14 +bind F6 selectw -t:15 +bind F7 selectw -t:16 +bind F8 selectw -t:17 +bind F9 selectw -t:18 +bind F10 selectw -t:19 +bind F11 selectw -t:20 +bind F12 selectw -t:21 + +# Keys to toggle monitoring activity in a window, and synchronize-panes +bind m set monitor-activity +bind y set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}' + +# Keys to hide and show a window name from the status line +bind '-' set window-status-format '#I'\; set window-status-current-format '#I' +bind '+' set window-status-format '#I:#W#F'\; set window-status-current-format '#I:#W#F' + +# Create a single default session +new -d -s0 -nirssi 'exec irssi' +set -t0:0 monitor-activity on +set -t0:0 aggressive-resize on +neww -d -ntodo 'exec emacs ~/TODO' +setw -t0:1 aggressive-resize on +neww -d -nmutt 'exec mutt' +setw -t0:2 aggressive-resize on +neww -d +neww -d +neww -d diff --git a/examples/h-boetes.conf b/examples/h-boetes.conf deleted file mode 100644 index 2aa86dc56..000000000 --- a/examples/h-boetes.conf +++ /dev/null @@ -1,42 +0,0 @@ -# $Id: h-boetes.conf,v 1.2 2009-10-25 21:45:26 nicm Exp $ -# -# From Han Boetes. - -set -g default-command zsh -set -g status-right "#(uptime|awk '{print $11}') #(date)" - -# Statusbar properties. -set -g display-time 3000 -set -g status-bg black -set -g status-fg cyan -set-window-option -g window-status-current-attr bright,reverse -set-window-option -g window-status-current-bg cyan -set-window-option -g window-status-current-fg black - -# Use c-t instead of c-b as the prefix -unbind C-b -set -g prefix C-t -bind C-t send-prefix -bind t send-prefix - -# Bind function keys. -bind -n F1 select-window -t 1 -bind -n F2 select-window -t 2 -bind -n F3 select-window -t 3 -bind -n F4 select-window -t 4 -bind -n F5 select-window -t 5 -bind -n F6 select-window -t 6 -bind -n F7 select-window -t 7 -bind -n F8 select-window -t 8 - -# All new windows started at startup. -new emacs -neww irssi -neww mutt -neww -neww -neww -neww -neww - -select-window -t 1 diff --git a/examples/n-marriott.conf b/examples/n-marriott.conf deleted file mode 100644 index 6a047ec92..000000000 --- a/examples/n-marriott.conf +++ /dev/null @@ -1,110 +0,0 @@ -# $Id: n-marriott.conf,v 1.11 2009-11-24 19:03:59 nicm Exp $ -# -# By Nicholas Marriott. Public domain. - -# Default global options. -set -g status-bg green -set -g status-right "%H:%M" # %d-%b-%y -set -g bell-action none -set -g lock-after-time 1800 - -# Default global window options. -setw -g remain-on-exit on -setw -g window-status-current-attr "underscore" -#setw -g xterm-keys on - -# Prefix key. -set -g prefix C-a -unbind C-b -bind C-a send-prefix - -# Keys to switch session. -bind Q switchc -t0 -bind W switchc -t1 -bind E switchc -t2 - -# Other key bindings. -bind F1 selectw -t:10 -bind F2 selectw -t:11 -bind F3 selectw -t:12 -bind F4 selectw -t:13 -bind F5 selectw -t:14 -bind F6 selectw -t:15 -bind F7 selectw -t:16 -bind F8 selectw -t:17 -bind F9 selectw -t:18 -bind F10 selectw -t:19 -bind F11 selectw -t:20 -bind F12 selectw -t:21 - -bind m setw monitor-activity - -bind y setw force-width 81 -bind u setw force-width 0 - -bind -n F1 run-shell 'mpc toggle >/dev/null 2>&1' -bind -n F2 run-shell 'mpc' -bind -n F3 run-shell 'mpc prev >/dev/null 2>&1' -bind -n F4 run-shell 'mpc next >/dev/null 2>&1' -bind -n F5 run-shell 'mpc volume -5 >/dev/null 2>&1' -bind -n F6 run-shell 'mpc volume +5 >/dev/null 2>&1' - -# Hide and show window name from status line -bind '-' setw window-status-format '#I'\; setw window-status-current-format '#I' -bind '+' setw window-status-format '#I:#W#F'\; setw window-status-current-format '#I:#W#F' - -# First session. -new -d -s0 -nirssi 'exec ssh -t natalya exec sh ~/bin/tmux-start' -setw -t0:0 monitor-activity on -setw -t0:0 aggressive-resize on -set -t0 status-bg green -neww -d -ntodo 'exec emacs ~/TODO' -setw -t0:1 aggressive-resize on -neww -d -ntodo2 'exec emacs ~/TODO2' -setw -t0:2 aggressive-resize on -neww -d -nncmpc 'exec ncmpc -f ~/.ncmpc.conf' -setw -t0:3 aggressive-resize on -neww -d -nmutt 'exec mutt' -setw -t0:4 aggressive-resize on -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d - -# Second session. -new -d -s1 -set -t1 status-bg cyan -linkw -dk -t0 -s0:0 -linkw -dk -t1 -s0:1 -linkw -dk -t2 -s0:2 -linkw -dk -t3 -s0:3 -linkw -dk -t4 -s0:4 -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d - -# Third session. -new -d -s2 -set -t2 status-bg yellow -linkw -dk -t0 -s0:0 -linkw -dk -t1 -s0:1 -linkw -dk -t2 -s0:2 -linkw -dk -t3 -s0:3 -linkw -dk -t4 -s0:4 -neww -d -neww -d -neww -d -neww -d -neww -d -neww -d diff --git a/examples/screen-keys.conf b/examples/screen-keys.conf deleted file mode 100644 index ce149290e..000000000 --- a/examples/screen-keys.conf +++ /dev/null @@ -1,102 +0,0 @@ -# $Id: screen-keys.conf,v 1.7 2010-07-31 11:39:13 nicm Exp $ -# -# By Nicholas Marriott. Public domain. -# -# This configuration file binds many of the common GNU screen key bindings to -# appropriate tmux key bindings. Note that for some key bindings there is no -# tmux analogue and also that this set omits binding some commands available in -# tmux but not in screen. -# -# Note this is only a selection of key bindings and they are in addition to the -# normal tmux key bindings. This is intended as an example not as to be used -# as-is. - -# Set the prefix to ^A. -unbind C-b -set -g prefix ^A -bind a send-prefix - -# Bind appropriate commands similar to screen. -# lockscreen ^X x -unbind ^X -bind ^X lock-server -unbind x -bind x lock-server - -# screen ^C c -unbind ^C -bind ^C new-window -unbind c -bind c new-window - -# detach ^D d -unbind ^D -bind ^D detach - -# displays * -unbind * -bind * list-clients - -# next ^@ ^N sp n -unbind ^@ -bind ^@ next-window -unbind ^N -bind ^N next-window -unbind " " -bind " " next-window -unbind n -bind n next-window - -# title A -unbind A -bind A command-prompt "rename-window %%" - -# other ^A -unbind ^A -bind ^A last-window - -# prev ^H ^P p ^? -unbind ^H -bind ^H previous-window -unbind ^P -bind ^P previous-window -unbind p -bind p previous-window -unbind BSpace -bind BSpace previous-window - -# windows ^W w -unbind ^W -bind ^W list-windows -unbind w -bind w list-windows - -# quit \ -unbind '\' -bind '\' confirm-before "kill-server" - -# kill K k -unbind K -bind K confirm-before "kill-window" -unbind k -bind k confirm-before "kill-window" - -# redisplay ^L l -unbind ^L -bind ^L refresh-client -unbind l -bind l refresh-client - -# split -v | -unbind | -bind | split-window - -# :kB: focus up -unbind Tab -bind Tab select-pane -t:.+ -unbind BTab -bind BTab select-pane -t:.- - -# " windowlist -b -unbind '"' -bind '"' choose-window diff --git a/examples/t-williams.conf b/examples/t-williams.conf deleted file mode 100644 index 0a2cc3f5a..000000000 --- a/examples/t-williams.conf +++ /dev/null @@ -1,104 +0,0 @@ -# $Id: t-williams.conf,v 1.1 2009-11-02 18:59:28 nicm Exp $ -# -# ~/.tmux.conf - tmux terminal multiplexer config -# Thayer Williams (http://cinderwick.ca) -# "Feel free to do whatever you like with it." - -# I typically start tmux from ~/.xinitrc with the following: -# -# urxvt -e bash -c "tmux attach -d -t mysession" & -# -# and recall it any time thereafter with xbindkeys (Mod4+s): -# -# "urxvt -e bash -c 'tmux attach -d -t mysession'" -# m:0x50 + c:39 - - -# set prefix key to ctrl+a until I have time to adapt -unbind C-b -set -g prefix C-a - -# send the prefix to client inside window (ala nested sessions) -bind-key a send-prefix - -# toggle last window like screen -bind-key C-a last-window - -# confirm before killing a window or the server -bind-key k confirm kill-window -bind-key K confirm kill-server - -# toggle statusbar -bind-key b set-option status - -# ctrl+left/right cycles thru windows -bind-key -n C-right next -bind-key -n C-left prev - -# open a man page in new window -bind / command-prompt "split-window 'exec man %%'" - -# quick view of processes -bind '~' split-window "exec htop" - -# scrollback buffer n lines -set -g history-limit 5000 - -# listen for activity on all windows -set -g bell-action any - -# on-screen time for display-panes in ms -set -g display-panes-time 2000 - -# start window indexing at one instead of zero -set -g base-index 1 - -# enable wm window titles -set -g set-titles on - -# wm window title string (uses statusbar variables) -set -g set-titles-string "tmux.#I.#W" - -# session initialization -new -s mysession mutt -neww -t 2 -neww -d -t 3 -neww -d -t 5 mocp -neww -d -t 6 rtorrent -selectw -t 1 - -# statusbar -------------------------------------------------------------- - -set -g display-time 2000 - -# default statusbar colors -set -g status-fg white -set -g status-bg default -set -g status-attr default - -# default window title colors -set-window-option -g window-status-fg cyan -set-window-option -g window-status-bg default -set-window-option -g window-status-attr dim - -# active window title colors -set-window-option -g window-status-current-fg white -set-window-option -g window-status-current-bg default -set-window-option -g window-status-current-attr bright - -# command/message line colors -set -g message-fg white -set -g message-bg black -set -g message-attr bright - -# center align the window list -set -g status-justify centre - -# show some useful stats but only when tmux is started -# outside of Xorg, otherwise dwm statusbar shows these already -set -g status-right "" -set -g status-left "" -if '[ -z "$DISPLAY" ]' 'set -g status-left "[#[fg=green] #H #[default]]"' -if '[ -z "$DISPLAY" ]' 'set -g status-right "[ #[fg=magenta]#(cat /proc/loadavg | cut -d \" \" -f 1,2,3)#[default] ][ #[fg=cyan,bright]%a %Y-%m-%d %H:%M #[default]]"' -if '[ -z "$DISPLAY" ]' 'set -g status-right-length 50' - diff --git a/examples/vim-keys.conf b/examples/vim-keys.conf deleted file mode 100644 index d587d0bf0..000000000 --- a/examples/vim-keys.conf +++ /dev/null @@ -1,36 +0,0 @@ -# $Id: vim-keys.conf,v 1.2 2010-09-18 09:36:15 nicm Exp $ -# -# vim-keys.conf, v1.2 2010/09/12 -# -# By Daniel Thau. Public domain. -# -# This configuration file binds many vi- and vim-like bindings to the -# appropriate tmux key bindings. Note that for many key bindings there is no -# tmux analogue. This is intended for tmux 1.3, which handles pane selection -# differently from the previous versions - -# split windows like vim -# vim's definition of a horizontal/vertical split is reversed from tmux's -bind s split-window -v -bind v split-window -h - -# move around panes with hjkl, as one would in vim after pressing ctrl-w -bind h select-pane -L -bind j select-pane -D -bind k select-pane -U -bind l select-pane -R - -# resize panes like vim -# feel free to change the "1" to however many lines you want to resize by, only -# one at a time can be slow -bind < resize-pane -L 1 -bind > resize-pane -R 1 -bind - resize-pane -D 1 -bind + resize-pane -U 1 - -# bind : to command-prompt like vim -# this is the default in tmux already -bind : command-prompt - -# vi-style controls for copy mode -setw -g mode-keys vi diff --git a/examples/xterm-keys.vim b/examples/xterm-keys.vim deleted file mode 100644 index 5672c26a3..000000000 --- a/examples/xterm-keys.vim +++ /dev/null @@ -1,49 +0,0 @@ -" tmux.vim - Set xterm input codes passed by tmux -" Author: Mark Oteiza -" License: Public domain -" Description: Simple plugin that assigns some xterm(1)-style keys to escape -" sequences passed by tmux when "xterm-keys" is set to "on". Inspired by an -" example given by Chris Johnsen at: -" https://stackoverflow.com/a/15471820 -" -" Documentation: help:xterm-modifier-keys man:tmux(1) - -if exists("g:loaded_tmux") || &cp - finish -endif -let g:loaded_tmux = 1 - -function! s:SetXtermCapabilities() - set ttymouse=sgr - - execute "set =\e[1;*A" - execute "set =\e[1;*B" - execute "set =\e[1;*C" - execute "set =\e[1;*D" - - execute "set =\e[1;*H" - execute "set =\e[1;*F" - - execute "set =\e[2;*~" - execute "set =\e[3;*~" - execute "set =\e[5;*~" - execute "set =\e[6;*~" - - execute "set =\e[1;*P" - execute "set =\e[1;*Q" - execute "set =\e[1;*R" - execute "set =\e[1;*S" - - execute "set =\e[15;*~" - execute "set =\e[17;*~" - execute "set =\e[18;*~" - execute "set =\e[19;*~" - execute "set =\e[20;*~" - execute "set =\e[21;*~" - execute "set =\e[23;*~" - execute "set =\e[24;*~" -endfunction - -if exists('$TMUX') - call s:SetXtermCapabilities() -endif From 404379049a4cb5480c2b1c19634c869e46feb220 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 29 Jan 2016 15:45:32 +0000 Subject: [PATCH 12/47] examples/ has gone, so delete some text about it. --- README | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README b/README index dbc9b173f..9141f240b 100644 --- a/README +++ b/README @@ -60,10 +60,7 @@ welcome. Please send by email to: tmux-users@googlegroups.com -This file and the CHANGES, FAQ, SYNCING and TODO files are licensed under -the ISC license. Files under examples/ remain copyright their authors unless -otherwise stated in the file but permission has been received to distribute -them with tmux. All other files have a license and copyright notice at their -start. +This file and the CHANGES, FAQ, SYNCING and TODO files are licensed under the +ISC license. All other files have a license and copyright notice at their start. -- Nicholas Marriott From 225a384dbb5ffe5fc91c59ebcaeda1946b80ca69 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 31 Jan 2016 09:52:01 +0000 Subject: [PATCH 13/47] Fix new-session with -t after command flags changes, reported by Michael Graczyk. --- cmd-new-session.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd-new-session.c b/cmd-new-session.c index b4bb37d59..ecbc59836 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -74,7 +74,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) struct environ *env; struct termios tio, *tiop; const char *newname, *target, *update, *errstr, *template; - const char *path, *cwd, *to_free; + const char *path, *cwd, *to_free = NULL; char **argv, *cmd, *cause, *cp; int detached, already_attached, idx, argc; u_int sx, sy; @@ -118,7 +118,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) } } - if ((target = args_get(args, 't')) == NULL) + if ((target = args_get(args, 't')) != NULL) { + if (groupwith == NULL) { + cmdq_error(cmdq, "no such session: %s", target); + goto error; + } + } else groupwith = NULL; /* Set -d if no client. */ @@ -132,7 +137,6 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) already_attached = 1; /* Get the new session working directory. */ - to_free = NULL; if (args_has(args, 'c')) { ft = format_create(cmdq, 0); format_defaults(ft, c, NULL, NULL, NULL); @@ -208,7 +212,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) if (!args_has(args, 't') && args->argc != 0) { argc = args->argc; argv = args->argv; - } else if (target == NULL) { + } else if (groupwith == NULL) { cmd = options_get_string(global_s_options, "default-command"); if (cmd != NULL && *cmd != '\0') { argc = 1; @@ -257,7 +261,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) * If a target session is given, this is to be part of a session group, * so add it to the group and synchronize. */ - if (args_has(args, 't')) { + if (groupwith != NULL) { session_group_add(groupwith, s); session_group_synchronize_to(s); session_select(s, RB_MIN(winlinks, &s->windows)->idx); From 8028560f8260aeea6fee1206cf8704a0a5fc25f9 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 31 Jan 2016 09:54:46 +0000 Subject: [PATCH 14/47] Support negative trim values (#{=-10:pane_title}) to trim from the end, suggested by Kevin Brubeck Unhammer. --- format.c | 12 ++++++++---- tmux.1 | 10 +++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/format.c b/format.c index efa9d1e11..78c177cd8 100644 --- a/format.c +++ b/format.c @@ -684,7 +684,7 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, char *copy, *copy0, *endptr, *ptr, *found, *new, *value; char *from = NULL, *to = NULL; size_t valuelen, newlen, fromlen, tolen, used; - u_long limit = 0; + long limit = 0; int modifiers = 0, brackets; /* Make a copy of the key. */ @@ -696,8 +696,8 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, switch (copy[0]) { case '=': errno = 0; - limit = strtoul(copy + 1, &endptr, 10); - if (errno == ERANGE && limit == ULONG_MAX) + limit = strtol(copy + 1, &endptr, 10); + if (errno == ERANGE && (limit == LONG_MIN || limit == LONG_MAX)) break; if (*endptr != ':') break; @@ -813,10 +813,14 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, } /* Truncate the value if needed. */ - if (limit != 0) { + if (limit > 0) { new = utf8_trimcstr(value, limit); free(value); value = new; + } else if (limit < 0) { + new = utf8_rtrimcstr(value, -limit); + free(value); + value = new; } /* Expand the buffer and copy in the value. */ diff --git a/tmux.1 b/tmux.1 index e70b07c34..5dbf6b845 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3377,9 +3377,13 @@ if not. A limit may be placed on the length of the resultant string by prefixing it by an .Ql = , -a number and a colon, so -.Ql #{=10:pane_title} -will include at most the first 10 characters of the pane title. +a number and a colon. +Positive numbers count from the start of the string and negative from the end, +so +.Ql #{=5:pane_title} +will include at most the first 5 characters of the pane title, or +.Ql #{=-5:pane_title} +the last 5 characters. Prefixing a time variable with .Ql t: will convert it to a string, so if From 49e9f937387356a3970fdb2af6bb56818127b433 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 31 Jan 2016 09:57:09 +0000 Subject: [PATCH 15/47] Add RGB escape sequences for capture-pane -e. --- grid.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/grid.c b/grid.c index 782032f40..0be0254ff 100644 --- a/grid.c +++ b/grid.c @@ -452,6 +452,12 @@ grid_string_cells_fg(const struct grid_cell *gc, int *values) values[n++] = 38; values[n++] = 5; values[n++] = gc->fg; + } else if (gc->flags & GRID_FLAG_FGRGB) { + values[n++] = 38; + values[n++] = 2; + values[n++] = gc->fg_rgb.r; + values[n++] = gc->fg_rgb.g; + values[n++] = gc->fg_rgb.b; } else { switch (gc->fg) { case 0: @@ -493,6 +499,12 @@ grid_string_cells_bg(const struct grid_cell *gc, int *values) values[n++] = 48; values[n++] = 5; values[n++] = gc->bg; + } else if (gc->flags & GRID_FLAG_BGRGB) { + values[n++] = 48; + values[n++] = 2; + values[n++] = gc->bg_rgb.r; + values[n++] = gc->bg_rgb.g; + values[n++] = gc->bg_rgb.b; } else { switch (gc->bg) { case 0: @@ -532,7 +544,7 @@ void grid_string_cells_code(const struct grid_cell *lastgc, const struct grid_cell *gc, char *buf, size_t len, int escape_c0) { - int oldc[16], newc[16], s[32]; + int oldc[64], newc[64], s[128]; size_t noldc, nnewc, n, i; u_int attr = gc->attr; u_int lastattr = lastgc->attr; From fa64b89ad7af8daf04c50b54fe8b45411750149e Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 31 Jan 2016 09:57:41 +0000 Subject: [PATCH 16/47] Whoops, need this for the previous reverse trim commit too. --- tmux.h | 1 + utf8.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/tmux.h b/tmux.h index 8edb92090..997690fc3 100644 --- a/tmux.h +++ b/tmux.h @@ -2324,6 +2324,7 @@ char *utf8_sanitize(const char *); struct utf8_data *utf8_fromcstr(const char *); char *utf8_tocstr(struct utf8_data *); u_int utf8_cstrwidth(const char *); +char *utf8_rtrimcstr(const char *, u_int); char *utf8_trimcstr(const char *, u_int); char *utf8_padcstr(const char *, u_int); diff --git a/utf8.c b/utf8.c index b03c425df..3f6107a76 100644 --- a/utf8.c +++ b/utf8.c @@ -724,6 +724,43 @@ utf8_trimcstr(const char *s, u_int width) return (out); } +/* Trim UTF-8 string to width. Caller frees. */ +char * +utf8_rtrimcstr(const char *s, u_int width) +{ + struct utf8_data *tmp, *next, *end; + char *out; + u_int at; + + tmp = utf8_fromcstr(s); + + for (end = tmp; end->size != 0; end++) + /* nothing */; + if (end == tmp) { + free(tmp); + return (xstrdup("")); + } + next = end - 1; + + at = 0; + for (;;) + { + if (at + next->width > width) { + next++; + break; + } + at += next->width; + + if (next == tmp) + break; + next--; + } + + out = utf8_tocstr(next); + free(tmp); + return (out); +} + /* Pad UTF-8 string to width. Caller frees. */ char * utf8_padcstr(const char *s, u_int width) From 97882f9ce27d615769d3140ef77ddfb47b17a89b Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 31 Jan 2016 14:11:49 +0000 Subject: [PATCH 17/47] Clear RGB flags during selection. --- screen-write.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/screen-write.c b/screen-write.c index 05315b3f8..e58d744cf 100644 --- a/screen-write.c +++ b/screen-write.c @@ -994,7 +994,9 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) utf8_copy(&tmp_gc.data, &gc->data); tmp_gc.attr = tmp_gc.attr & ~GRID_ATTR_CHARSET; tmp_gc.attr |= gc->attr & GRID_ATTR_CHARSET; - tmp_gc.flags = gc->flags & ~(GRID_FLAG_FG256|GRID_FLAG_BG256); + tmp_gc.flags = gc->flags; + tmp_gc.flags &= ~(GRID_FLAG_FGRGB|GRID_FLAG_BGRGB); + tmp_gc.flags &= ~(GRID_FLAG_FG256|GRID_FLAG_BG256); tmp_gc.flags |= s->sel.cell.flags & (GRID_FLAG_FG256|GRID_FLAG_BG256); ttyctx.cell = &tmp_gc; From bdb8bb790ed53c0ea134c690c8f55b449eefbd3f Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 4 Feb 2016 14:11:20 +0000 Subject: [PATCH 18/47] Set up -t flag properly when passing new-session -A off to attach-session, GitHub issue 295. --- cmd-new-session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd-new-session.c b/cmd-new-session.c index ecbc59836..291107bc0 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -68,7 +68,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct client *c = cmdq->client; - struct session *s, *attach_sess; + struct session *s, *as; struct session *groupwith = cmdq->state.tflag.s; struct window *w; struct environ *env; @@ -100,7 +100,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) cmdq_error(cmdq, "bad session name: %s", newname); return (CMD_RETURN_ERROR); } - if ((attach_sess = session_find(newname)) != NULL) { + if ((as = session_find(newname)) != NULL) { if (args_has(args, 'A')) { /* * This cmdq is now destined for @@ -108,7 +108,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) * will have already been prepared, copy this * session into its tflag so it can be used. */ - cmdq->state.tflag.s = attach_sess; + cmd_find_from_session(&cmdq->state.tflag, as); return (cmd_attach_session(cmdq, args_has(args, 'D'), 0, NULL, args_has(args, 'E'))); From 2130a07b70db7df8d57b9cad96a6866203daacad Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 5 Feb 2016 10:08:39 +0000 Subject: [PATCH 19/47] Add to TODO. --- TODO | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index b4b8231be..18d3ae61c 100644 --- a/TODO +++ b/TODO @@ -62,6 +62,19 @@ * command to toggle selection not to move it in copy-mode * regex searching * copy-pipe should have -x as well + * copy mode key bindings should just be a standard key table, using + something like "copy-mode start-selection"; it could use + command-prompt for search, goto, etc: + + bind -Temacs command-prompt -p'Search Up: ' 'copy-mode search-up %%' + + it'd need a separate lookup, because modes are per-pane, perhaps a + table() cb to give the table name ("vi" or "emacs"). anything in the + table fires the command, anything not in the table is injected as a + key + * searching in copy mode should unwrap lines, so if you seach for "foobar" + then it should be found even if it is now "foo\nbar" (if the WRAP flag + is set on the line) - layout stuff * way to tag a layout as a number/name @@ -123,13 +136,3 @@ * automatic pane logging * BCE? We are halfway there (output side is done for pane backgrounds), just need to change how screen/grid handles erase - * copy mode key bindings should just be a standard key table, using - something like "copy-mode start-selection"; it could use - command-prompt for search, goto, etc: - - bind -Temacs command-prompt -p'Search Up: ' 'copy-mode search-up %%' - - it'd need a separate lookup, because modes are per-pane, perhaps a - table() cb to give the table name ("vi" or "emacs"). anything in the - table fires the command, anything not in the table is injected as a - key From bc0c9c7920349328ed426a735b999d9dc85fe1f1 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 5 Feb 2016 10:20:06 +0000 Subject: [PATCH 20/47] Do not wrap cursor at start or end of history, from Michal Mazurek. --- window-copy.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/window-copy.c b/window-copy.c index c8e38fd18..009ed2460 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1775,11 +1775,13 @@ void window_copy_cursor_left(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; + u_int py; - if (data->cx == 0) { + py = screen_hsize(data->backing) + data->cy - data->oy; + if (data->cx == 0 && py > 0) { window_copy_cursor_up(wp, 0); window_copy_cursor_end_of_line(wp); - } else { + } else if (data->cx > 0) { window_copy_update_cursor(wp, data->cx - 1, data->cy); if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); @@ -1790,19 +1792,20 @@ void window_copy_cursor_right(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; - u_int px, py; + u_int px, py, yy; + py = screen_hsize(data->backing) + data->cy - data->oy; + yy = screen_hsize(data->backing) + screen_size_y(data->backing) - 1; if (data->screen.sel.flag && data->rectflag) px = screen_size_x(&data->screen); else { - py = screen_hsize(data->backing) + data->cy - data->oy; px = window_copy_find_length(wp, py); } - if (data->cx >= px) { + if (data->cx >= px && py < yy) { window_copy_cursor_start_of_line(wp); window_copy_cursor_down(wp, 0); - } else { + } else if (data->cx < px) { window_copy_update_cursor(wp, data->cx + 1, data->cy); if (window_copy_update_selection(wp, 1)) window_copy_redraw_lines(wp, data->cy, 1); From ba97ae1737fbbdc7d6cd4ce4f8f0b4a3d77f027e Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sat, 6 Feb 2016 19:04:21 +0000 Subject: [PATCH 21/47] EXTRA_DIST: add example_tmux.conf / xmalloc.h --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index d8c92aa91..8678a38e1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,8 +6,8 @@ CLEANFILES = tmux.1.mdoc tmux.1.man # Distribution tarball options. EXTRA_DIST = \ - CHANGES FAQ README TODO COPYING examples compat/*.[ch] \ - array.h compat.h tmux.h osdep-*.c mdoc2man.awk tmux.1 + CHANGES FAQ README TODO COPYING example_tmux.conf compat/*.[ch] \ + array.h compat.h tmux.h osdep-*.c xmalloc.h mdoc2man.awk tmux.1 dist-hook: make clean grep "^#found_debug=" configure From f7c8f1ae291b0211734fe2c902a786033a9e0f3f Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sun, 7 Feb 2016 00:04:46 +0000 Subject: [PATCH 22/47] xmalloc: define __bounded__ where necessary --- xmalloc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xmalloc.h b/xmalloc.h index d331ce99d..0360b0d9d 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -19,6 +19,10 @@ #ifndef XMALLOC_H #define XMALLOC_H +#if !defined(__bounded__) +# define __bounded__(x, y, z) +#endif + void *xmalloc(size_t); void *xcalloc(size_t, size_t); void *xrealloc(void *, size_t); From 4f6bc0a0a90a652172bdf251d5177476f7e6bdb1 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 12 Feb 2016 12:24:52 +0000 Subject: [PATCH 23/47] Expand client formats in run-shell. --- cmd-run-shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-run-shell.c b/cmd-run-shell.c index e857e9c9e..0bd8fc59b 100644 --- a/cmd-run-shell.c +++ b/cmd-run-shell.c @@ -93,7 +93,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq) else cwd = NULL; ft = format_create(cmdq, 0); - format_defaults(ft, NULL, s, wl, wp); + format_defaults(ft, cmdq->state.c, s, wl, wp); shellcmd = format_expand(ft, args->argv[0]); format_free(ft); From 782dd941da97802108628fb068f5462f4c78f431 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 17 Feb 2016 23:21:58 +0000 Subject: [PATCH 24/47] Fire SIGCHLD after utempter_add_record since it probably eats it. --- window.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window.c b/window.c index a89b10811..a364948ff 100644 --- a/window.c +++ b/window.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -915,6 +916,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv, #ifdef HAVE_UTEMPTER xsnprintf(s, sizeof s, "tmux(%lu).%%%u", (long) getpid(), wp->id); utempter_add_record(wp->fd, s); + kill(getpid(), SIGCHLD); #endif setblocking(wp->fd, 0); From fc864529f587fc4c913d1ad40da41eab2e512521 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Feb 2016 13:11:10 +0000 Subject: [PATCH 25/47] Remove malloc_options debug bit (already gone from OpenBSD). --- tmux.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tmux.c b/tmux.c index 700687a58..ff0871244 100644 --- a/tmux.c +++ b/tmux.c @@ -32,10 +32,6 @@ #include "tmux.h" -#if defined(DEBUG) && defined(__OpenBSD__) -extern char *malloc_options; -#endif - struct options *global_options; /* server options */ struct options *global_s_options; /* session options */ struct options *global_w_options; /* window options */ @@ -194,10 +190,6 @@ main(int argc, char **argv) const char *s; int opt, flags, keys; -#if defined(DEBUG) && defined(__OpenBSD__) - malloc_options = (char *) "AFGJPX"; -#endif - setlocale(LC_TIME, ""); tzset(); From acc1090e778090b8c5d2488220897873266dc368 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Feb 2016 13:14:17 +0000 Subject: [PATCH 26/47] Use system wcwidth() instead of carrying around UTF-8 width tables. --- input-keys.c | 19 ++- tmux.c | 3 + tmux.h | 8 +- utf8.c | 450 ++++----------------------------------------------- 4 files changed, 50 insertions(+), 430 deletions(-) diff --git a/input-keys.c b/input-keys.c index 9a39ba7c5..2a22b0898 100644 --- a/input-keys.c +++ b/input-keys.c @@ -134,6 +134,19 @@ const struct input_key_ent input_keys[] = { { KEYC_KP_PERIOD, ".", 0 }, }; +/* Split a character into two UTF-8 bytes. */ +static size_t +input_split2(u_int c, u_char *dst) +{ + if (c > 0x7f) { + dst[0] = (c >> 6) | 0xc0; + dst[1] = (c & 0x3f) | 0x80; + return (2); + } + dst[0] = c; + return (1); +} + /* Translate a key code into an output key sequence. */ void input_key(struct window_pane *wp, key_code key, struct mouse_event *m) @@ -250,9 +263,9 @@ input_key_mouse(struct window_pane *wp, struct mouse_event *m) m->sgr_b, x + 1, y + 1, m->sgr_type); } else if (wp->screen->mode & MODE_MOUSE_UTF8) { len = xsnprintf(buf, sizeof buf, "\033[M"); - len += utf8_split2(m->b + 32, &buf[len]); - len += utf8_split2(x + 33, &buf[len]); - len += utf8_split2(y + 33, &buf[len]); + len += input_split2(m->b + 32, &buf[len]); + len += input_split2(x + 33, &buf[len]); + len += input_split2(y + 33, &buf[len]); } else { if (m->b > 223) return; diff --git a/tmux.c b/tmux.c index ff0871244..b1285c3e0 100644 --- a/tmux.c +++ b/tmux.c @@ -190,7 +190,10 @@ main(int argc, char **argv) const char *s; int opt, flags, keys; + + setlocale(LC_CTYPE, "en_US.UTF-8"); setlocale(LC_TIME, ""); + tzset(); if (**argv == '-') diff --git a/tmux.h b/tmux.h index be00098d3..7c0acc75b 100644 --- a/tmux.h +++ b/tmux.h @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef HAVE_UTEMPTER #include @@ -2313,14 +2314,13 @@ void session_group_synchronize1(struct session *, struct session *); void session_renumber_windows(struct session *); /* utf8.c */ -u_int utf8_width(u_int); void utf8_set(struct utf8_data *, u_char); void utf8_copy(struct utf8_data *, const struct utf8_data *); enum utf8_state utf8_open(struct utf8_data *, u_char); enum utf8_state utf8_append(struct utf8_data *, u_char); -u_int utf8_combine(const struct utf8_data *); -enum utf8_state utf8_split(u_int, struct utf8_data *); -u_int utf8_split2(u_int, u_char *); +u_int utf8_width(wchar_t); +wchar_t utf8_combine(const struct utf8_data *); +enum utf8_state utf8_split(wchar_t, struct utf8_data *); int utf8_strvis(char *, const char *, size_t, int); char *utf8_sanitize(const char *); struct utf8_data *utf8_fromcstr(const char *); diff --git a/utf8.c b/utf8.c index 524ba8724..503546af2 100644 --- a/utf8.c +++ b/utf8.c @@ -20,333 +20,10 @@ #include #include +#include #include "tmux.h" -struct utf8_width_entry { - u_int first; - u_int last; - - int width; - - struct utf8_width_entry *left; - struct utf8_width_entry *right; -}; - -/* Sorted, then repeatedly split in the middle to balance the tree. */ -static struct utf8_width_entry utf8_width_table[] = { - { 0x00b41, 0x00b44, 0, NULL, NULL }, - { 0x008e4, 0x00902, 0, NULL, NULL }, - { 0x006d6, 0x006dd, 0, NULL, NULL }, - { 0x005c4, 0x005c5, 0, NULL, NULL }, - { 0x00591, 0x005bd, 0, NULL, NULL }, - { 0x00300, 0x0036f, 0, NULL, NULL }, - { 0x00483, 0x00489, 0, NULL, NULL }, - { 0x005bf, 0x005bf, 0, NULL, NULL }, - { 0x005c1, 0x005c2, 0, NULL, NULL }, - { 0x00610, 0x0061a, 0, NULL, NULL }, - { 0x00600, 0x00605, 0, NULL, NULL }, - { 0x005c7, 0x005c7, 0, NULL, NULL }, - { 0x0064b, 0x0065f, 0, NULL, NULL }, - { 0x0061c, 0x0061c, 0, NULL, NULL }, - { 0x00670, 0x00670, 0, NULL, NULL }, - { 0x007a6, 0x007b0, 0, NULL, NULL }, - { 0x006ea, 0x006ed, 0, NULL, NULL }, - { 0x006df, 0x006e4, 0, NULL, NULL }, - { 0x006e7, 0x006e8, 0, NULL, NULL }, - { 0x00711, 0x00711, 0, NULL, NULL }, - { 0x0070f, 0x0070f, 0, NULL, NULL }, - { 0x00730, 0x0074a, 0, NULL, NULL }, - { 0x0081b, 0x00823, 0, NULL, NULL }, - { 0x007eb, 0x007f3, 0, NULL, NULL }, - { 0x00816, 0x00819, 0, NULL, NULL }, - { 0x00829, 0x0082d, 0, NULL, NULL }, - { 0x00825, 0x00827, 0, NULL, NULL }, - { 0x00859, 0x0085b, 0, NULL, NULL }, - { 0x00a41, 0x00a42, 0, NULL, NULL }, - { 0x00981, 0x00981, 0, NULL, NULL }, - { 0x00941, 0x00948, 0, NULL, NULL }, - { 0x0093a, 0x0093a, 0, NULL, NULL }, - { 0x0093c, 0x0093c, 0, NULL, NULL }, - { 0x00951, 0x00957, 0, NULL, NULL }, - { 0x0094d, 0x0094d, 0, NULL, NULL }, - { 0x00962, 0x00963, 0, NULL, NULL }, - { 0x009e2, 0x009e3, 0, NULL, NULL }, - { 0x009c1, 0x009c4, 0, NULL, NULL }, - { 0x009bc, 0x009bc, 0, NULL, NULL }, - { 0x009cd, 0x009cd, 0, NULL, NULL }, - { 0x00a01, 0x00a02, 0, NULL, NULL }, - { 0x00a3c, 0x00a3c, 0, NULL, NULL }, - { 0x00ac1, 0x00ac5, 0, NULL, NULL }, - { 0x00a70, 0x00a71, 0, NULL, NULL }, - { 0x00a4b, 0x00a4d, 0, NULL, NULL }, - { 0x00a47, 0x00a48, 0, NULL, NULL }, - { 0x00a51, 0x00a51, 0, NULL, NULL }, - { 0x00a81, 0x00a82, 0, NULL, NULL }, - { 0x00a75, 0x00a75, 0, NULL, NULL }, - { 0x00abc, 0x00abc, 0, NULL, NULL }, - { 0x00ae2, 0x00ae3, 0, NULL, NULL }, - { 0x00ac7, 0x00ac8, 0, NULL, NULL }, - { 0x00acd, 0x00acd, 0, NULL, NULL }, - { 0x00b3c, 0x00b3c, 0, NULL, NULL }, - { 0x00b01, 0x00b01, 0, NULL, NULL }, - { 0x00b3f, 0x00b3f, 0, NULL, NULL }, - { 0x03190, 0x031ba, 2, NULL, NULL }, - { 0x017c9, 0x017d3, 0, NULL, NULL }, - { 0x00ec8, 0x00ecd, 0, NULL, NULL }, - { 0x00cc6, 0x00cc6, 0, NULL, NULL }, - { 0x00c3e, 0x00c40, 0, NULL, NULL }, - { 0x00b82, 0x00b82, 0, NULL, NULL }, - { 0x00b56, 0x00b56, 0, NULL, NULL }, - { 0x00b4d, 0x00b4d, 0, NULL, NULL }, - { 0x00b62, 0x00b63, 0, NULL, NULL }, - { 0x00bcd, 0x00bcd, 0, NULL, NULL }, - { 0x00bc0, 0x00bc0, 0, NULL, NULL }, - { 0x00c00, 0x00c00, 0, NULL, NULL }, - { 0x00c62, 0x00c63, 0, NULL, NULL }, - { 0x00c4a, 0x00c4d, 0, NULL, NULL }, - { 0x00c46, 0x00c48, 0, NULL, NULL }, - { 0x00c55, 0x00c56, 0, NULL, NULL }, - { 0x00cbc, 0x00cbc, 0, NULL, NULL }, - { 0x00c81, 0x00c81, 0, NULL, NULL }, - { 0x00cbf, 0x00cbf, 0, NULL, NULL }, - { 0x00dd2, 0x00dd4, 0, NULL, NULL }, - { 0x00d41, 0x00d44, 0, NULL, NULL }, - { 0x00ce2, 0x00ce3, 0, NULL, NULL }, - { 0x00ccc, 0x00ccd, 0, NULL, NULL }, - { 0x00d01, 0x00d01, 0, NULL, NULL }, - { 0x00d62, 0x00d63, 0, NULL, NULL }, - { 0x00d4d, 0x00d4d, 0, NULL, NULL }, - { 0x00dca, 0x00dca, 0, NULL, NULL }, - { 0x00e47, 0x00e4e, 0, NULL, NULL }, - { 0x00e31, 0x00e31, 0, NULL, NULL }, - { 0x00dd6, 0x00dd6, 0, NULL, NULL }, - { 0x00e34, 0x00e3a, 0, NULL, NULL }, - { 0x00eb4, 0x00eb9, 0, NULL, NULL }, - { 0x00eb1, 0x00eb1, 0, NULL, NULL }, - { 0x00ebb, 0x00ebc, 0, NULL, NULL }, - { 0x0105e, 0x01060, 0, NULL, NULL }, - { 0x00f8d, 0x00f97, 0, NULL, NULL }, - { 0x00f39, 0x00f39, 0, NULL, NULL }, - { 0x00f35, 0x00f35, 0, NULL, NULL }, - { 0x00f18, 0x00f19, 0, NULL, NULL }, - { 0x00f37, 0x00f37, 0, NULL, NULL }, - { 0x00f80, 0x00f84, 0, NULL, NULL }, - { 0x00f71, 0x00f7e, 0, NULL, NULL }, - { 0x00f86, 0x00f87, 0, NULL, NULL }, - { 0x01032, 0x01037, 0, NULL, NULL }, - { 0x00fc6, 0x00fc6, 0, NULL, NULL }, - { 0x00f99, 0x00fbc, 0, NULL, NULL }, - { 0x0102d, 0x01030, 0, NULL, NULL }, - { 0x0103d, 0x0103e, 0, NULL, NULL }, - { 0x01039, 0x0103a, 0, NULL, NULL }, - { 0x01058, 0x01059, 0, NULL, NULL }, - { 0x0135d, 0x0135f, 0, NULL, NULL }, - { 0x01085, 0x01086, 0, NULL, NULL }, - { 0x01071, 0x01074, 0, NULL, NULL }, - { 0x01082, 0x01082, 0, NULL, NULL }, - { 0x0109d, 0x0109d, 0, NULL, NULL }, - { 0x0108d, 0x0108d, 0, NULL, NULL }, - { 0x01100, 0x011ff, 2, NULL, NULL }, - { 0x01772, 0x01773, 0, NULL, NULL }, - { 0x01732, 0x01734, 0, NULL, NULL }, - { 0x01712, 0x01714, 0, NULL, NULL }, - { 0x01752, 0x01753, 0, NULL, NULL }, - { 0x017b7, 0x017bd, 0, NULL, NULL }, - { 0x017b4, 0x017b5, 0, NULL, NULL }, - { 0x017c6, 0x017c6, 0, NULL, NULL }, - { 0x01c2c, 0x01c33, 0, NULL, NULL }, - { 0x01a7f, 0x01a7f, 0, NULL, NULL }, - { 0x01a17, 0x01a18, 0, NULL, NULL }, - { 0x01920, 0x01922, 0, NULL, NULL }, - { 0x0180b, 0x0180e, 0, NULL, NULL }, - { 0x017dd, 0x017dd, 0, NULL, NULL }, - { 0x018a9, 0x018a9, 0, NULL, NULL }, - { 0x01932, 0x01932, 0, NULL, NULL }, - { 0x01927, 0x01928, 0, NULL, NULL }, - { 0x01939, 0x0193b, 0, NULL, NULL }, - { 0x01a60, 0x01a60, 0, NULL, NULL }, - { 0x01a56, 0x01a56, 0, NULL, NULL }, - { 0x01a1b, 0x01a1b, 0, NULL, NULL }, - { 0x01a58, 0x01a5e, 0, NULL, NULL }, - { 0x01a65, 0x01a6c, 0, NULL, NULL }, - { 0x01a62, 0x01a62, 0, NULL, NULL }, - { 0x01a73, 0x01a7c, 0, NULL, NULL }, - { 0x01b80, 0x01b81, 0, NULL, NULL }, - { 0x01b36, 0x01b3a, 0, NULL, NULL }, - { 0x01b00, 0x01b03, 0, NULL, NULL }, - { 0x01ab0, 0x01abe, 0, NULL, NULL }, - { 0x01b34, 0x01b34, 0, NULL, NULL }, - { 0x01b42, 0x01b42, 0, NULL, NULL }, - { 0x01b3c, 0x01b3c, 0, NULL, NULL }, - { 0x01b6b, 0x01b73, 0, NULL, NULL }, - { 0x01be6, 0x01be6, 0, NULL, NULL }, - { 0x01ba8, 0x01ba9, 0, NULL, NULL }, - { 0x01ba2, 0x01ba5, 0, NULL, NULL }, - { 0x01bab, 0x01bad, 0, NULL, NULL }, - { 0x01bed, 0x01bed, 0, NULL, NULL }, - { 0x01be8, 0x01be9, 0, NULL, NULL }, - { 0x01bef, 0x01bf1, 0, NULL, NULL }, - { 0x02329, 0x0232a, 2, NULL, NULL }, - { 0x01dc0, 0x01df5, 0, NULL, NULL }, - { 0x01ce2, 0x01ce8, 0, NULL, NULL }, - { 0x01cd0, 0x01cd2, 0, NULL, NULL }, - { 0x01c36, 0x01c37, 0, NULL, NULL }, - { 0x01cd4, 0x01ce0, 0, NULL, NULL }, - { 0x01cf4, 0x01cf4, 0, NULL, NULL }, - { 0x01ced, 0x01ced, 0, NULL, NULL }, - { 0x01cf8, 0x01cf9, 0, NULL, NULL }, - { 0x02060, 0x02064, 0, NULL, NULL }, - { 0x0200b, 0x0200f, 0, NULL, NULL }, - { 0x01dfc, 0x01dff, 0, NULL, NULL }, - { 0x0202a, 0x0202e, 0, NULL, NULL }, - { 0x02066, 0x0206f, 0, NULL, NULL }, - { 0x020d0, 0x020f0, 0, NULL, NULL }, - { 0x03001, 0x03029, 2, NULL, NULL }, - { 0x02e80, 0x02e99, 2, NULL, NULL }, - { 0x02d7f, 0x02d7f, 0, NULL, NULL }, - { 0x02cef, 0x02cf1, 0, NULL, NULL }, - { 0x02de0, 0x02dff, 0, NULL, NULL }, - { 0x02f00, 0x02fd5, 2, NULL, NULL }, - { 0x02e9b, 0x02ef3, 2, NULL, NULL }, - { 0x02ff0, 0x02ffb, 2, NULL, NULL }, - { 0x03099, 0x0309a, 0, NULL, NULL }, - { 0x0302e, 0x0303e, 2, NULL, NULL }, - { 0x0302a, 0x0302d, 0, NULL, NULL }, - { 0x03041, 0x03096, 2, NULL, NULL }, - { 0x03105, 0x0312d, 2, NULL, NULL }, - { 0x0309b, 0x030ff, 2, NULL, NULL }, - { 0x03131, 0x0318e, 2, NULL, NULL }, - { 0x10a3f, 0x10a3f, 0, NULL, NULL }, - { 0x0aa4c, 0x0aa4c, 0, NULL, NULL }, - { 0x0a825, 0x0a826, 0, NULL, NULL }, - { 0x0a490, 0x0a4c6, 2, NULL, NULL }, - { 0x03250, 0x032fe, 2, NULL, NULL }, - { 0x031f0, 0x0321e, 2, NULL, NULL }, - { 0x031c0, 0x031e3, 2, NULL, NULL }, - { 0x03220, 0x03247, 2, NULL, NULL }, - { 0x04e00, 0x09fcc, 2, NULL, NULL }, - { 0x03300, 0x04db5, 2, NULL, NULL }, - { 0x0a000, 0x0a48c, 2, NULL, NULL }, - { 0x0a6f0, 0x0a6f1, 0, NULL, NULL }, - { 0x0a674, 0x0a67d, 0, NULL, NULL }, - { 0x0a66f, 0x0a672, 0, NULL, NULL }, - { 0x0a69f, 0x0a69f, 0, NULL, NULL }, - { 0x0a806, 0x0a806, 0, NULL, NULL }, - { 0x0a802, 0x0a802, 0, NULL, NULL }, - { 0x0a80b, 0x0a80b, 0, NULL, NULL }, - { 0x0a9b6, 0x0a9b9, 0, NULL, NULL }, - { 0x0a947, 0x0a951, 0, NULL, NULL }, - { 0x0a8e0, 0x0a8f1, 0, NULL, NULL }, - { 0x0a8c4, 0x0a8c4, 0, NULL, NULL }, - { 0x0a926, 0x0a92d, 0, NULL, NULL }, - { 0x0a980, 0x0a982, 0, NULL, NULL }, - { 0x0a960, 0x0a97c, 2, NULL, NULL }, - { 0x0a9b3, 0x0a9b3, 0, NULL, NULL }, - { 0x0aa29, 0x0aa2e, 0, NULL, NULL }, - { 0x0a9bc, 0x0a9bc, 0, NULL, NULL }, - { 0x0a9e5, 0x0a9e5, 0, NULL, NULL }, - { 0x0aa35, 0x0aa36, 0, NULL, NULL }, - { 0x0aa31, 0x0aa32, 0, NULL, NULL }, - { 0x0aa43, 0x0aa43, 0, NULL, NULL }, - { 0x0fb1e, 0x0fb1e, 0, NULL, NULL }, - { 0x0aaf6, 0x0aaf6, 0, NULL, NULL }, - { 0x0aab7, 0x0aab8, 0, NULL, NULL }, - { 0x0aab0, 0x0aab0, 0, NULL, NULL }, - { 0x0aa7c, 0x0aa7c, 0, NULL, NULL }, - { 0x0aab2, 0x0aab4, 0, NULL, NULL }, - { 0x0aac1, 0x0aac1, 0, NULL, NULL }, - { 0x0aabe, 0x0aabf, 0, NULL, NULL }, - { 0x0aaec, 0x0aaed, 0, NULL, NULL }, - { 0x0ac00, 0x0d7a3, 2, NULL, NULL }, - { 0x0abe8, 0x0abe8, 0, NULL, NULL }, - { 0x0abe5, 0x0abe5, 0, NULL, NULL }, - { 0x0abed, 0x0abed, 0, NULL, NULL }, - { 0x0f900, 0x0fa6d, 2, NULL, NULL }, - { 0x0d800, 0x0dfff, 0, NULL, NULL }, - { 0x0fa70, 0x0fad9, 2, NULL, NULL }, - { 0x0fff9, 0x0fffb, 0, NULL, NULL }, - { 0x0fe30, 0x0fe52, 2, NULL, NULL }, - { 0x0fe10, 0x0fe19, 2, NULL, NULL }, - { 0x0fe00, 0x0fe0f, 0, NULL, NULL }, - { 0x0fe20, 0x0fe2d, 0, NULL, NULL }, - { 0x0fe68, 0x0fe6b, 2, NULL, NULL }, - { 0x0fe54, 0x0fe66, 2, NULL, NULL }, - { 0x0feff, 0x0feff, 0, NULL, NULL }, - { 0x10a01, 0x10a03, 0, NULL, NULL }, - { 0x102e0, 0x102e0, 0, NULL, NULL }, - { 0x101fd, 0x101fd, 0, NULL, NULL }, - { 0x10376, 0x1037a, 0, NULL, NULL }, - { 0x10a0c, 0x10a0f, 0, NULL, NULL }, - { 0x10a05, 0x10a06, 0, NULL, NULL }, - { 0x10a38, 0x10a3a, 0, NULL, NULL }, - { 0x11633, 0x1163a, 0, NULL, NULL }, - { 0x11236, 0x11237, 0, NULL, NULL }, - { 0x11100, 0x11102, 0, NULL, NULL }, - { 0x1107f, 0x11081, 0, NULL, NULL }, - { 0x11001, 0x11001, 0, NULL, NULL }, - { 0x10ae5, 0x10ae6, 0, NULL, NULL }, - { 0x11038, 0x11046, 0, NULL, NULL }, - { 0x110b9, 0x110ba, 0, NULL, NULL }, - { 0x110b3, 0x110b6, 0, NULL, NULL }, - { 0x110bd, 0x110bd, 0, NULL, NULL }, - { 0x11180, 0x11181, 0, NULL, NULL }, - { 0x1112d, 0x11134, 0, NULL, NULL }, - { 0x11127, 0x1112b, 0, NULL, NULL }, - { 0x11173, 0x11173, 0, NULL, NULL }, - { 0x1122f, 0x11231, 0, NULL, NULL }, - { 0x111b6, 0x111be, 0, NULL, NULL }, - { 0x11234, 0x11234, 0, NULL, NULL }, - { 0x11370, 0x11374, 0, NULL, NULL }, - { 0x11301, 0x11301, 0, NULL, NULL }, - { 0x112df, 0x112df, 0, NULL, NULL }, - { 0x112e3, 0x112ea, 0, NULL, NULL }, - { 0x11340, 0x11340, 0, NULL, NULL }, - { 0x1133c, 0x1133c, 0, NULL, NULL }, - { 0x11366, 0x1136c, 0, NULL, NULL }, - { 0x114c2, 0x114c3, 0, NULL, NULL }, - { 0x114ba, 0x114ba, 0, NULL, NULL }, - { 0x114b3, 0x114b8, 0, NULL, NULL }, - { 0x114bf, 0x114c0, 0, NULL, NULL }, - { 0x115bc, 0x115bd, 0, NULL, NULL }, - { 0x115b2, 0x115b5, 0, NULL, NULL }, - { 0x115bf, 0x115c0, 0, NULL, NULL }, - { 0x1d1aa, 0x1d1ad, 0, NULL, NULL }, - { 0x16b30, 0x16b36, 0, NULL, NULL }, - { 0x116ad, 0x116ad, 0, NULL, NULL }, - { 0x1163f, 0x11640, 0, NULL, NULL }, - { 0x1163d, 0x1163d, 0, NULL, NULL }, - { 0x116ab, 0x116ab, 0, NULL, NULL }, - { 0x116b7, 0x116b7, 0, NULL, NULL }, - { 0x116b0, 0x116b5, 0, NULL, NULL }, - { 0x16af0, 0x16af4, 0, NULL, NULL }, - { 0x1bca0, 0x1bca3, 0, NULL, NULL }, - { 0x1b000, 0x1b001, 2, NULL, NULL }, - { 0x16f8f, 0x16f92, 0, NULL, NULL }, - { 0x1bc9d, 0x1bc9e, 0, NULL, NULL }, - { 0x1d173, 0x1d182, 0, NULL, NULL }, - { 0x1d167, 0x1d169, 0, NULL, NULL }, - { 0x1d185, 0x1d18b, 0, NULL, NULL }, - { 0x2a700, 0x2b734, 2, NULL, NULL }, - { 0x1f210, 0x1f23a, 2, NULL, NULL }, - { 0x1e8d0, 0x1e8d6, 0, NULL, NULL }, - { 0x1d242, 0x1d244, 0, NULL, NULL }, - { 0x1f200, 0x1f202, 2, NULL, NULL }, - { 0x1f250, 0x1f251, 2, NULL, NULL }, - { 0x1f240, 0x1f248, 2, NULL, NULL }, - { 0x20000, 0x2a6d6, 2, NULL, NULL }, - { 0xe0020, 0xe007f, 0, NULL, NULL }, - { 0x2f800, 0x2fa1d, 2, NULL, NULL }, - { 0x2b740, 0x2b81d, 2, NULL, NULL }, - { 0xe0001, 0xe0001, 0, NULL, NULL }, - { 0xf0000, 0xffffd, 0, NULL, NULL }, - { 0xe0100, 0xe01ef, 0, NULL, NULL }, - { 0x100000, 0x10fffd, 0, NULL, NULL }, -}; -static struct utf8_width_entry *utf8_width_root = NULL; - -static void utf8_build(void); - /* Set a single character. */ void utf8_set(struct utf8_data *ud, u_char ch) @@ -420,118 +97,45 @@ utf8_append(struct utf8_data *ud, u_char ch) return (UTF8_DONE); } -/* Build UTF-8 width tree. */ -static void -utf8_build(void) -{ - struct utf8_width_entry **ptr, *item, *node; - u_int i; - - for (i = 0; i < nitems(utf8_width_table); i++) { - item = &utf8_width_table[i]; - - ptr = &utf8_width_root; - while (*ptr != NULL) { - node = *ptr; - if (item->last < node->first) - ptr = &node->left; - else if (item->first > node->last) - ptr = &node->right; - } - *ptr = item; - } -} - -/* Lookup width of UTF-8 data in tree. */ +/* Get width of Unicode character. */ u_int -utf8_width(u_int uc) +utf8_width(wchar_t wc) { - struct utf8_width_entry *item; + int width; - if (utf8_width_root == NULL) - utf8_build(); - - item = utf8_width_root; - while (item != NULL) { - if (uc < item->first) - item = item->left; - else if (uc > item->last) - item = item->right; - else - return (item->width); - } - return (1); + width = wcwidth(wc); + if (width < 0) + return (0); + return (width); } -/* Combine UTF-8 into 32-bit Unicode. */ -u_int +/* Combine UTF-8 into Unicode. */ +wchar_t utf8_combine(const struct utf8_data *ud) { - u_int uc; - - uc = 0xfffd; - switch (ud->size) { - case 1: - uc = ud->data[0]; - break; - case 2: - uc = ud->data[1] & 0x3f; - uc |= (ud->data[0] & 0x1f) << 6; - break; - case 3: - uc = ud->data[2] & 0x3f; - uc |= (ud->data[1] & 0x3f) << 6; - uc |= (ud->data[0] & 0xf) << 12; - break; - case 4: - uc = ud->data[3] & 0x3f; - uc |= (ud->data[2] & 0x3f) << 6; - uc |= (ud->data[1] & 0x3f) << 12; - uc |= (ud->data[0] & 0x7) << 18; - break; - } - return (uc); + wchar_t wc; + + if (mbtowc(&wc, ud->data, ud->size) <= 0) + return (0xfffd); + return (wc); } -/* Split 32-bit Unicode into UTF-8. */ +/* Split Unicode into UTF-8. */ enum utf8_state -utf8_split(u_int uc, struct utf8_data *ud) +utf8_split(wchar_t wc, struct utf8_data *ud) { - if (uc < 0x7f) { - ud->size = 1; - ud->data[0] = uc; - } else if (uc < 0x7ff) { - ud->size = 2; - ud->data[0] = 0xc0 | ((uc >> 6) & 0x1f); - ud->data[1] = 0x80 | (uc & 0x3f); - } else if (uc < 0xffff) { - ud->size = 3; - ud->data[0] = 0xe0 | ((uc >> 12) & 0xf); - ud->data[1] = 0x80 | ((uc >> 6) & 0x3f); - ud->data[2] = 0x80 | (uc & 0x3f); - } else if (uc < 0x1fffff) { - ud->size = 4; - ud->data[0] = 0xf0 | ((uc >> 18) & 0x7); - ud->data[1] = 0x80 | ((uc >> 12) & 0x3f); - ud->data[2] = 0x80 | ((uc >> 6) & 0x3f); - ud->data[3] = 0x80 | (uc & 0x3f); - } else + char s[MB_CUR_MAX]; + int slen; + + slen = wctomb(s, wc); + if (slen <= 0 || slen > (int)sizeof ud->data) return (UTF8_ERROR); - ud->width = utf8_width(uc); - return (UTF8_DONE); -} -/* Split a two-byte UTF-8 character. */ -u_int -utf8_split2(u_int uc, u_char *ptr) -{ - if (uc > 0x7f) { - ptr[0] = (uc >> 6) | 0xc0; - ptr[1] = (uc & 0x3f) | 0x80; - return (2); - } - ptr[0] = uc; - return (1); + memcpy(ud->data, s, slen); + ud->size = slen; + + ud->width = utf8_width(wc); + return (UTF8_DONE); } /* From 02753ba9ea89bbeed1a5bba4d5b3a3c6a41e775e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Feb 2016 13:15:22 +0000 Subject: [PATCH 27/47] Remove unused variables, from Michal Mazurek. --- cmd-swap-pane.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c index aec7753de..13575e0af 100644 --- a/cmd-swap-pane.c +++ b/cmd-swap-pane.c @@ -45,28 +45,23 @@ const struct cmd_entry cmd_swap_pane_entry = { enum cmd_retval cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq) { - struct winlink *src_wl, *dst_wl; struct window *src_w, *dst_w; struct window_pane *tmp_wp, *src_wp, *dst_wp; struct layout_cell *src_lc, *dst_lc; u_int sx, sy, xoff, yoff; - dst_wl = cmdq->state.tflag.wl; - dst_w = dst_wl->window; + dst_w = cmdq->state.tflag.wl->window; dst_wp = cmdq->state.tflag.wp; - src_wl = cmdq->state.sflag.wl; - src_w = src_wl->window; + src_w = cmdq->state.sflag.wl->window; src_wp = cmdq->state.sflag.wp; server_unzoom_window(dst_w); if (args_has(self->args, 'D')) { - src_wl = dst_wl; src_w = dst_w; src_wp = TAILQ_NEXT(dst_wp, entry); if (src_wp == NULL) src_wp = TAILQ_FIRST(&dst_w->panes); } else if (args_has(self->args, 'U')) { - src_wl = dst_wl; src_w = dst_w; src_wp = TAILQ_PREV(dst_wp, window_panes, entry); if (src_wp == NULL) From 95adc0e6bacb32108fd6557e2e5ddeaaaa4fd58e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Feb 2016 13:28:03 +0000 Subject: [PATCH 28/47] When a mouse drag is finished, fire a MouseUp key press, instead of doing the drag end in code. From Stephen Coakley. --- mode-key.c | 2 ++ server-client.c | 40 ++++++++++++++++++++++++++++++++++++++-- window-copy.c | 15 +-------------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/mode-key.c b/mode-key.c index f38ebf661..a9b15bb94 100644 --- a/mode-key.c +++ b/mode-key.c @@ -347,6 +347,7 @@ const struct mode_key_entry mode_key_vi_copy[] = { { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP }, { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN }, { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION }, + { KEYC_MOUSEUP1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, { 0, -1, 0 } }; @@ -495,6 +496,7 @@ const struct mode_key_entry mode_key_emacs_copy[] = { { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP }, { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN }, { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION }, + { KEYC_MOUSEUP1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, { 0, -1, 0 } }; diff --git a/server-client.c b/server-client.c index 6e98f062f..680350df8 100644 --- a/server-client.c +++ b/server-client.c @@ -382,8 +382,42 @@ server_client_check_mouse(struct client *c) c->tty.mouse_drag_update = NULL; c->tty.mouse_drag_release = NULL; + /* + * End a mouse drag by passing a MouseUp key corresponding to + * the button that started the drag. + */ + switch (c->tty.mouse_drag_flag) { + case 1: + if (where == PANE) + key = KEYC_MOUSEUP1_PANE; + if (where == STATUS) + key = KEYC_MOUSEUP1_STATUS; + if (where == BORDER) + key = KEYC_MOUSEUP1_BORDER; + break; + case 2: + if (where == PANE) + key = KEYC_MOUSEUP2_PANE; + if (where == STATUS) + key = KEYC_MOUSEUP2_STATUS; + if (where == BORDER) + key = KEYC_MOUSEUP2_BORDER; + break; + case 3: + if (where == PANE) + key = KEYC_MOUSEUP3_PANE; + if (where == STATUS) + key = KEYC_MOUSEUP3_STATUS; + if (where == BORDER) + key = KEYC_MOUSEUP3_BORDER; + break; + default: + key = KEYC_MOUSE; + break; + } c->tty.mouse_drag_flag = 0; - return (KEYC_MOUSE); /* not a key, but still may want to pass */ + + return (key); } /* Convert to a key binding. */ @@ -423,7 +457,9 @@ server_client_check_mouse(struct client *c) } } - c->tty.mouse_drag_flag = 1; + /* Begin a drag by setting the flag to nonzero, where the value + corresponds to the mouse button doing the dragging. */ + c->tty.mouse_drag_flag = MOUSE_BUTTONS(b) + 1; break; case WHEEL: if (MOUSE_BUTTONS(b) == MOUSE_WHEEL_UP) { diff --git a/window-copy.c b/window-copy.c index 009ed2460..d345f2464 100644 --- a/window-copy.c +++ b/window-copy.c @@ -2248,7 +2248,7 @@ window_copy_start_drag(struct client *c, struct mouse_event *m) return; c->tty.mouse_drag_update = window_copy_drag_update; - c->tty.mouse_drag_release = window_copy_drag_release; + c->tty.mouse_drag_release = NULL; /* will fire MouseUp key */ window_copy_update_cursor(wp, x, y); window_copy_start_selection(wp); @@ -2275,16 +2275,3 @@ window_copy_drag_update(__unused struct client *c, struct mouse_event *m) if (window_copy_update_selection(wp, 1)) window_copy_redraw_selection(wp, old_cy); } - -void -window_copy_drag_release(__unused struct client *c, struct mouse_event *m) -{ - struct window_pane *wp; - - wp = cmd_mouse_pane(m, NULL, NULL); - if (wp == NULL || wp->mode != &window_copy_mode) - return; - - window_copy_copy_selection(wp, NULL); - window_pane_reset_mode(wp); -} From 6adf5615075944e87b2a988d5507cca5d9151826 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Feb 2016 13:29:59 +0000 Subject: [PATCH 29/47] Redraw status on mode entry and exit. --- window.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/window.c b/window.c index a364948ff..236d2436b 100644 --- a/window.c +++ b/window.c @@ -1100,6 +1100,8 @@ window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode) if ((s = wp->mode->init(wp)) != NULL) wp->screen = s; wp->flags |= (PANE_REDRAW|PANE_CHANGED); + + server_status_window(wp->window); return (0); } @@ -1114,6 +1116,8 @@ window_pane_reset_mode(struct window_pane *wp) wp->screen = &wp->base; wp->flags |= (PANE_REDRAW|PANE_CHANGED); + + server_status_window(wp->window); } void From e9d369a09e48ea8f940958025c8444988d31e840 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Feb 2016 13:35:46 +0000 Subject: [PATCH 30/47] Fixed fgetln(3) implementation (from Joerg Jung) which does not depend on *BSD fgets(3) semantics. --- compat/fgetln.c | 108 +++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 66 deletions(-) diff --git a/compat/fgetln.c b/compat/fgetln.c index a5c2489d3..0ad6378a2 100644 --- a/compat/fgetln.c +++ b/compat/fgetln.c @@ -1,43 +1,26 @@ -/* $NetBSD: fgetln.c,v 1.3 2007/08/07 02:06:58 lukem Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. +/* + * Copyright (c) 2015 Joerg Jung * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * 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. * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * 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. */ -#include +/* + * portable fgetln() version, NOT reentrant + */ -#include #include #include -#include +#include #include "tmux.h" @@ -45,41 +28,34 @@ char * fgetln(FILE *fp, size_t *len) { static char *buf = NULL; - static size_t bufsiz = 0; - char *ptr; - - - if (buf == NULL) { - bufsiz = BUFSIZ; - if ((buf = malloc(bufsiz)) == NULL) - return NULL; - } + static size_t bufsz = 0; + size_t r = 0; + char *p; + int c, e; - if (fgets(buf, bufsiz, fp) == NULL) + if (!fp || !len) { + errno = EINVAL; return NULL; - - *len = 0; - while ((ptr = strchr(&buf[*len], '\n')) == NULL) { - size_t nbufsiz = bufsiz + BUFSIZ; - char *nbuf = realloc(buf, nbufsiz); - - if (nbuf == NULL) { - int oerrno = errno; - free(buf); - errno = oerrno; - buf = NULL; + } + if (!buf) { + if (!(buf = calloc(1, BUFSIZ))) return NULL; - } else - buf = nbuf; - - *len = bufsiz; - if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) - return buf; - - bufsiz = nbufsiz; + bufsz = BUFSIZ; } - - *len = (ptr - buf) + 1; - return buf; + while ((c = getc(fp)) != EOF) { + buf[r++] = c; + if (r == bufsz) { + if (!(p = reallocarray(buf, 2, bufsz))) { + e = errno; + free(buf); + errno = e; + buf = NULL, bufsz = 0; + return NULL; + } + buf = p, bufsz = 2 * bufsz; + } + if (c == '\n') + break; + } + return (*len = r) ? buf : NULL; } - From c3f93e71785290d717ecf60623b99b30d4941850 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Feb 2016 16:45:15 +0000 Subject: [PATCH 31/47] Add to TODO. --- TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO b/TODO index 18d3ae61c..4a284220e 100644 --- a/TODO +++ b/TODO @@ -131,7 +131,7 @@ comes from config for new sessions and windows. likewise, panes and jobs and run-shell and lock command all start with slightly different environments - * multiline status line? + * multiline status line? separate command prompt and status line? * customizable command aliases * automatic pane logging * BCE? We are halfway there (output side is done for pane backgrounds), From a011b67f56448b38e251418f0af67ff12411a0a0 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Feb 2016 16:45:35 +0000 Subject: [PATCH 32/47] Remove unused variables. --- cmd-if-shell.c | 3 +-- cmd-resize-pane.c | 1 - cmd.c | 1 - key-bindings.c | 4 ++-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 229289cd4..3e2a52519 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -73,14 +73,13 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq) struct format_tree *ft; const char *cwd; - cwd = wp->cwd; - if (cmdq->client != NULL && cmdq->client->session == NULL) cwd = cmdq->client->cwd; else if (s != NULL) cwd = s->cwd; else cwd = NULL; + ft = format_create(cmdq, 0); format_defaults(ft, NULL, s, wl, wp); shellcmd = format_expand(ft, args->argv[0]); diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index 2b4f1c177..7ec65f10c 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -68,7 +68,6 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_NORMAL); } - w = wl->window; if (args_has(args, 'Z')) { if (w->flags & WINDOW_ZOOMED) window_unzoom(w); diff --git a/cmd.c b/cmd.c index b0517e62b..28efa0c54 100644 --- a/cmd.c +++ b/cmd.c @@ -481,7 +481,6 @@ cmd_prepare_state_flag(char c, const char *target, enum cmd_entry_flag flag, CMD_FIND_SESSION, CMD_FIND_QUIET); if (error == 0) break; - flag = CMD_WINDOW_INDEX; /* FALLTHROUGH */ case CMD_WINDOW: case CMD_WINDOW_CANFAIL: diff --git a/key-bindings.c b/key-bindings.c index a922eb183..0d13385de 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -68,12 +68,12 @@ void key_bindings_unref_table(struct key_table *table) { struct key_binding *bd; + struct key_binding *bd1; if (--table->references != 0) return; - while (!RB_EMPTY(&table->key_bindings)) { - bd = RB_ROOT(&table->key_bindings); + RB_FOREACH_SAFE(bd, key_bindings, &table->key_bindings, bd1) { RB_REMOVE(key_bindings, &table->key_bindings, bd); cmd_list_free(bd->cmdlist); free(bd); From c7851e0ee71e26ee9af67f2523679132369b152f Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 1 Mar 2016 11:58:45 +0000 Subject: [PATCH 33/47] Fix break-pane synopsis and some other tmux.1 bits. --- cmd-break-pane.c | 2 +- tmux.1 | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cmd-break-pane.c b/cmd-break-pane.c index b5a2743f7..85873227f 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -35,7 +35,7 @@ const struct cmd_entry cmd_break_pane_entry = { .alias = "breakp", .args = { "dPF:s:t:", 0, 0 }, - .usage = "[-dP] [-F format] " CMD_SRCDST_PANE_USAGE, + .usage = "[-dP] [-F format] [-s src-pane] [-t dst-window]", .sflag = CMD_PANE, .tflag = CMD_WINDOW_INDEX, diff --git a/tmux.1 b/tmux.1 index 5dbf6b845..448673f15 100644 --- a/tmux.1 +++ b/tmux.1 @@ -717,7 +717,7 @@ will set the session working directory (used for new windows) to .Pp If .Fl E -is used, +is used, the .Ic update-environment option will not be applied. .It Xo Ic detach-client @@ -853,13 +853,12 @@ with .Ar target-session . This means they share the same set of windows - all windows from .Ar target-session -are linked to the new session and any subsequent new windows or windows being -closed are applied to both sessions. +are linked to the new session, any new windows are linked to both sessions and +any windows closed removed from both sessions. The current and previous window and any session options remain independent and either session may be killed without affecting the other. -Giving .Fl n -or +and .Ar shell-command are invalid if .Fl t @@ -875,7 +874,7 @@ but a different format may be specified with .Pp If .Fl E -is used, +is used, the .Ic update-environment option will not be applied. .It Xo Ic refresh-client @@ -1250,7 +1249,7 @@ Commands related to windows and panes are as follows: .Op Fl dP .Op Fl F Ar format .Op Fl s Ar src-pane -.Op Fl t Ar dst-pane +.Op Fl t Ar dst-window .Xc .D1 (alias: Ic breakp ) Break From 26945d7956bf1f160fba72677082e1a9c6968e0c Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 1 Mar 2016 12:02:08 +0000 Subject: [PATCH 34/47] Use system wcwidth() instead of carrying around UTF-8 width tables. --- input-keys.c | 19 ++- tmux.c | 3 + tmux.h | 8 +- utf8.c | 450 ++++----------------------------------------------- 4 files changed, 50 insertions(+), 430 deletions(-) diff --git a/input-keys.c b/input-keys.c index 254845cba..47786d273 100644 --- a/input-keys.c +++ b/input-keys.c @@ -135,6 +135,19 @@ const struct input_key_ent input_keys[] = { { KEYC_KP_PERIOD, ".", 0 }, }; +/* Split a character into two UTF-8 bytes. */ +static size_t +input_split2(u_int c, u_char *dst) +{ + if (c > 0x7f) { + dst[0] = (c >> 6) | 0xc0; + dst[1] = (c & 0x3f) | 0x80; + return (2); + } + dst[0] = c; + return (1); +} + /* Translate a key code into an output key sequence. */ void input_key(struct window_pane *wp, key_code key, struct mouse_event *m) @@ -251,9 +264,9 @@ input_key_mouse(struct window_pane *wp, struct mouse_event *m) m->sgr_b, x + 1, y + 1, m->sgr_type); } else if (wp->screen->mode & MODE_MOUSE_UTF8) { len = xsnprintf(buf, sizeof buf, "\033[M"); - len += utf8_split2(m->b + 32, &buf[len]); - len += utf8_split2(x + 33, &buf[len]); - len += utf8_split2(y + 33, &buf[len]); + len += input_split2(m->b + 32, &buf[len]); + len += input_split2(x + 33, &buf[len]); + len += input_split2(y + 33, &buf[len]); } else { if (m->b > 223) return; diff --git a/tmux.c b/tmux.c index 1ee2a269a..68cd4bb7d 100644 --- a/tmux.c +++ b/tmux.c @@ -188,7 +188,10 @@ main(int argc, char **argv) const char *s; int opt, flags, keys; + + setlocale(LC_CTYPE, "en_US.UTF-8"); setlocale(LC_TIME, ""); + tzset(); if (**argv == '-') diff --git a/tmux.h b/tmux.h index 997690fc3..b00c7469a 100644 --- a/tmux.h +++ b/tmux.h @@ -32,6 +32,7 @@ #include #include #include +#include #include "xmalloc.h" @@ -2311,14 +2312,13 @@ void session_group_synchronize1(struct session *, struct session *); void session_renumber_windows(struct session *); /* utf8.c */ -u_int utf8_width(u_int); void utf8_set(struct utf8_data *, u_char); void utf8_copy(struct utf8_data *, const struct utf8_data *); enum utf8_state utf8_open(struct utf8_data *, u_char); enum utf8_state utf8_append(struct utf8_data *, u_char); -u_int utf8_combine(const struct utf8_data *); -enum utf8_state utf8_split(u_int, struct utf8_data *); -u_int utf8_split2(u_int, u_char *); +u_int utf8_width(wchar_t); +wchar_t utf8_combine(const struct utf8_data *); +enum utf8_state utf8_split(wchar_t, struct utf8_data *); int utf8_strvis(char *, const char *, size_t, int); char *utf8_sanitize(const char *); struct utf8_data *utf8_fromcstr(const char *); diff --git a/utf8.c b/utf8.c index 3f6107a76..be0915bab 100644 --- a/utf8.c +++ b/utf8.c @@ -21,333 +21,10 @@ #include #include #include +#include #include "tmux.h" -struct utf8_width_entry { - u_int first; - u_int last; - - int width; - - struct utf8_width_entry *left; - struct utf8_width_entry *right; -}; - -/* Sorted, then repeatedly split in the middle to balance the tree. */ -static struct utf8_width_entry utf8_width_table[] = { - { 0x00b41, 0x00b44, 0, NULL, NULL }, - { 0x008e4, 0x00902, 0, NULL, NULL }, - { 0x006d6, 0x006dd, 0, NULL, NULL }, - { 0x005c4, 0x005c5, 0, NULL, NULL }, - { 0x00591, 0x005bd, 0, NULL, NULL }, - { 0x00300, 0x0036f, 0, NULL, NULL }, - { 0x00483, 0x00489, 0, NULL, NULL }, - { 0x005bf, 0x005bf, 0, NULL, NULL }, - { 0x005c1, 0x005c2, 0, NULL, NULL }, - { 0x00610, 0x0061a, 0, NULL, NULL }, - { 0x00600, 0x00605, 0, NULL, NULL }, - { 0x005c7, 0x005c7, 0, NULL, NULL }, - { 0x0064b, 0x0065f, 0, NULL, NULL }, - { 0x0061c, 0x0061c, 0, NULL, NULL }, - { 0x00670, 0x00670, 0, NULL, NULL }, - { 0x007a6, 0x007b0, 0, NULL, NULL }, - { 0x006ea, 0x006ed, 0, NULL, NULL }, - { 0x006df, 0x006e4, 0, NULL, NULL }, - { 0x006e7, 0x006e8, 0, NULL, NULL }, - { 0x00711, 0x00711, 0, NULL, NULL }, - { 0x0070f, 0x0070f, 0, NULL, NULL }, - { 0x00730, 0x0074a, 0, NULL, NULL }, - { 0x0081b, 0x00823, 0, NULL, NULL }, - { 0x007eb, 0x007f3, 0, NULL, NULL }, - { 0x00816, 0x00819, 0, NULL, NULL }, - { 0x00829, 0x0082d, 0, NULL, NULL }, - { 0x00825, 0x00827, 0, NULL, NULL }, - { 0x00859, 0x0085b, 0, NULL, NULL }, - { 0x00a41, 0x00a42, 0, NULL, NULL }, - { 0x00981, 0x00981, 0, NULL, NULL }, - { 0x00941, 0x00948, 0, NULL, NULL }, - { 0x0093a, 0x0093a, 0, NULL, NULL }, - { 0x0093c, 0x0093c, 0, NULL, NULL }, - { 0x00951, 0x00957, 0, NULL, NULL }, - { 0x0094d, 0x0094d, 0, NULL, NULL }, - { 0x00962, 0x00963, 0, NULL, NULL }, - { 0x009e2, 0x009e3, 0, NULL, NULL }, - { 0x009c1, 0x009c4, 0, NULL, NULL }, - { 0x009bc, 0x009bc, 0, NULL, NULL }, - { 0x009cd, 0x009cd, 0, NULL, NULL }, - { 0x00a01, 0x00a02, 0, NULL, NULL }, - { 0x00a3c, 0x00a3c, 0, NULL, NULL }, - { 0x00ac1, 0x00ac5, 0, NULL, NULL }, - { 0x00a70, 0x00a71, 0, NULL, NULL }, - { 0x00a4b, 0x00a4d, 0, NULL, NULL }, - { 0x00a47, 0x00a48, 0, NULL, NULL }, - { 0x00a51, 0x00a51, 0, NULL, NULL }, - { 0x00a81, 0x00a82, 0, NULL, NULL }, - { 0x00a75, 0x00a75, 0, NULL, NULL }, - { 0x00abc, 0x00abc, 0, NULL, NULL }, - { 0x00ae2, 0x00ae3, 0, NULL, NULL }, - { 0x00ac7, 0x00ac8, 0, NULL, NULL }, - { 0x00acd, 0x00acd, 0, NULL, NULL }, - { 0x00b3c, 0x00b3c, 0, NULL, NULL }, - { 0x00b01, 0x00b01, 0, NULL, NULL }, - { 0x00b3f, 0x00b3f, 0, NULL, NULL }, - { 0x03190, 0x031ba, 2, NULL, NULL }, - { 0x017c9, 0x017d3, 0, NULL, NULL }, - { 0x00ec8, 0x00ecd, 0, NULL, NULL }, - { 0x00cc6, 0x00cc6, 0, NULL, NULL }, - { 0x00c3e, 0x00c40, 0, NULL, NULL }, - { 0x00b82, 0x00b82, 0, NULL, NULL }, - { 0x00b56, 0x00b56, 0, NULL, NULL }, - { 0x00b4d, 0x00b4d, 0, NULL, NULL }, - { 0x00b62, 0x00b63, 0, NULL, NULL }, - { 0x00bcd, 0x00bcd, 0, NULL, NULL }, - { 0x00bc0, 0x00bc0, 0, NULL, NULL }, - { 0x00c00, 0x00c00, 0, NULL, NULL }, - { 0x00c62, 0x00c63, 0, NULL, NULL }, - { 0x00c4a, 0x00c4d, 0, NULL, NULL }, - { 0x00c46, 0x00c48, 0, NULL, NULL }, - { 0x00c55, 0x00c56, 0, NULL, NULL }, - { 0x00cbc, 0x00cbc, 0, NULL, NULL }, - { 0x00c81, 0x00c81, 0, NULL, NULL }, - { 0x00cbf, 0x00cbf, 0, NULL, NULL }, - { 0x00dd2, 0x00dd4, 0, NULL, NULL }, - { 0x00d41, 0x00d44, 0, NULL, NULL }, - { 0x00ce2, 0x00ce3, 0, NULL, NULL }, - { 0x00ccc, 0x00ccd, 0, NULL, NULL }, - { 0x00d01, 0x00d01, 0, NULL, NULL }, - { 0x00d62, 0x00d63, 0, NULL, NULL }, - { 0x00d4d, 0x00d4d, 0, NULL, NULL }, - { 0x00dca, 0x00dca, 0, NULL, NULL }, - { 0x00e47, 0x00e4e, 0, NULL, NULL }, - { 0x00e31, 0x00e31, 0, NULL, NULL }, - { 0x00dd6, 0x00dd6, 0, NULL, NULL }, - { 0x00e34, 0x00e3a, 0, NULL, NULL }, - { 0x00eb4, 0x00eb9, 0, NULL, NULL }, - { 0x00eb1, 0x00eb1, 0, NULL, NULL }, - { 0x00ebb, 0x00ebc, 0, NULL, NULL }, - { 0x0105e, 0x01060, 0, NULL, NULL }, - { 0x00f8d, 0x00f97, 0, NULL, NULL }, - { 0x00f39, 0x00f39, 0, NULL, NULL }, - { 0x00f35, 0x00f35, 0, NULL, NULL }, - { 0x00f18, 0x00f19, 0, NULL, NULL }, - { 0x00f37, 0x00f37, 0, NULL, NULL }, - { 0x00f80, 0x00f84, 0, NULL, NULL }, - { 0x00f71, 0x00f7e, 0, NULL, NULL }, - { 0x00f86, 0x00f87, 0, NULL, NULL }, - { 0x01032, 0x01037, 0, NULL, NULL }, - { 0x00fc6, 0x00fc6, 0, NULL, NULL }, - { 0x00f99, 0x00fbc, 0, NULL, NULL }, - { 0x0102d, 0x01030, 0, NULL, NULL }, - { 0x0103d, 0x0103e, 0, NULL, NULL }, - { 0x01039, 0x0103a, 0, NULL, NULL }, - { 0x01058, 0x01059, 0, NULL, NULL }, - { 0x0135d, 0x0135f, 0, NULL, NULL }, - { 0x01085, 0x01086, 0, NULL, NULL }, - { 0x01071, 0x01074, 0, NULL, NULL }, - { 0x01082, 0x01082, 0, NULL, NULL }, - { 0x0109d, 0x0109d, 0, NULL, NULL }, - { 0x0108d, 0x0108d, 0, NULL, NULL }, - { 0x01100, 0x011ff, 2, NULL, NULL }, - { 0x01772, 0x01773, 0, NULL, NULL }, - { 0x01732, 0x01734, 0, NULL, NULL }, - { 0x01712, 0x01714, 0, NULL, NULL }, - { 0x01752, 0x01753, 0, NULL, NULL }, - { 0x017b7, 0x017bd, 0, NULL, NULL }, - { 0x017b4, 0x017b5, 0, NULL, NULL }, - { 0x017c6, 0x017c6, 0, NULL, NULL }, - { 0x01c2c, 0x01c33, 0, NULL, NULL }, - { 0x01a7f, 0x01a7f, 0, NULL, NULL }, - { 0x01a17, 0x01a18, 0, NULL, NULL }, - { 0x01920, 0x01922, 0, NULL, NULL }, - { 0x0180b, 0x0180e, 0, NULL, NULL }, - { 0x017dd, 0x017dd, 0, NULL, NULL }, - { 0x018a9, 0x018a9, 0, NULL, NULL }, - { 0x01932, 0x01932, 0, NULL, NULL }, - { 0x01927, 0x01928, 0, NULL, NULL }, - { 0x01939, 0x0193b, 0, NULL, NULL }, - { 0x01a60, 0x01a60, 0, NULL, NULL }, - { 0x01a56, 0x01a56, 0, NULL, NULL }, - { 0x01a1b, 0x01a1b, 0, NULL, NULL }, - { 0x01a58, 0x01a5e, 0, NULL, NULL }, - { 0x01a65, 0x01a6c, 0, NULL, NULL }, - { 0x01a62, 0x01a62, 0, NULL, NULL }, - { 0x01a73, 0x01a7c, 0, NULL, NULL }, - { 0x01b80, 0x01b81, 0, NULL, NULL }, - { 0x01b36, 0x01b3a, 0, NULL, NULL }, - { 0x01b00, 0x01b03, 0, NULL, NULL }, - { 0x01ab0, 0x01abe, 0, NULL, NULL }, - { 0x01b34, 0x01b34, 0, NULL, NULL }, - { 0x01b42, 0x01b42, 0, NULL, NULL }, - { 0x01b3c, 0x01b3c, 0, NULL, NULL }, - { 0x01b6b, 0x01b73, 0, NULL, NULL }, - { 0x01be6, 0x01be6, 0, NULL, NULL }, - { 0x01ba8, 0x01ba9, 0, NULL, NULL }, - { 0x01ba2, 0x01ba5, 0, NULL, NULL }, - { 0x01bab, 0x01bad, 0, NULL, NULL }, - { 0x01bed, 0x01bed, 0, NULL, NULL }, - { 0x01be8, 0x01be9, 0, NULL, NULL }, - { 0x01bef, 0x01bf1, 0, NULL, NULL }, - { 0x02329, 0x0232a, 2, NULL, NULL }, - { 0x01dc0, 0x01df5, 0, NULL, NULL }, - { 0x01ce2, 0x01ce8, 0, NULL, NULL }, - { 0x01cd0, 0x01cd2, 0, NULL, NULL }, - { 0x01c36, 0x01c37, 0, NULL, NULL }, - { 0x01cd4, 0x01ce0, 0, NULL, NULL }, - { 0x01cf4, 0x01cf4, 0, NULL, NULL }, - { 0x01ced, 0x01ced, 0, NULL, NULL }, - { 0x01cf8, 0x01cf9, 0, NULL, NULL }, - { 0x02060, 0x02064, 0, NULL, NULL }, - { 0x0200b, 0x0200f, 0, NULL, NULL }, - { 0x01dfc, 0x01dff, 0, NULL, NULL }, - { 0x0202a, 0x0202e, 0, NULL, NULL }, - { 0x02066, 0x0206f, 0, NULL, NULL }, - { 0x020d0, 0x020f0, 0, NULL, NULL }, - { 0x03001, 0x03029, 2, NULL, NULL }, - { 0x02e80, 0x02e99, 2, NULL, NULL }, - { 0x02d7f, 0x02d7f, 0, NULL, NULL }, - { 0x02cef, 0x02cf1, 0, NULL, NULL }, - { 0x02de0, 0x02dff, 0, NULL, NULL }, - { 0x02f00, 0x02fd5, 2, NULL, NULL }, - { 0x02e9b, 0x02ef3, 2, NULL, NULL }, - { 0x02ff0, 0x02ffb, 2, NULL, NULL }, - { 0x03099, 0x0309a, 0, NULL, NULL }, - { 0x0302e, 0x0303e, 2, NULL, NULL }, - { 0x0302a, 0x0302d, 0, NULL, NULL }, - { 0x03041, 0x03096, 2, NULL, NULL }, - { 0x03105, 0x0312d, 2, NULL, NULL }, - { 0x0309b, 0x030ff, 2, NULL, NULL }, - { 0x03131, 0x0318e, 2, NULL, NULL }, - { 0x10a3f, 0x10a3f, 0, NULL, NULL }, - { 0x0aa4c, 0x0aa4c, 0, NULL, NULL }, - { 0x0a825, 0x0a826, 0, NULL, NULL }, - { 0x0a490, 0x0a4c6, 2, NULL, NULL }, - { 0x03250, 0x032fe, 2, NULL, NULL }, - { 0x031f0, 0x0321e, 2, NULL, NULL }, - { 0x031c0, 0x031e3, 2, NULL, NULL }, - { 0x03220, 0x03247, 2, NULL, NULL }, - { 0x04e00, 0x09fcc, 2, NULL, NULL }, - { 0x03300, 0x04db5, 2, NULL, NULL }, - { 0x0a000, 0x0a48c, 2, NULL, NULL }, - { 0x0a6f0, 0x0a6f1, 0, NULL, NULL }, - { 0x0a674, 0x0a67d, 0, NULL, NULL }, - { 0x0a66f, 0x0a672, 0, NULL, NULL }, - { 0x0a69f, 0x0a69f, 0, NULL, NULL }, - { 0x0a806, 0x0a806, 0, NULL, NULL }, - { 0x0a802, 0x0a802, 0, NULL, NULL }, - { 0x0a80b, 0x0a80b, 0, NULL, NULL }, - { 0x0a9b6, 0x0a9b9, 0, NULL, NULL }, - { 0x0a947, 0x0a951, 0, NULL, NULL }, - { 0x0a8e0, 0x0a8f1, 0, NULL, NULL }, - { 0x0a8c4, 0x0a8c4, 0, NULL, NULL }, - { 0x0a926, 0x0a92d, 0, NULL, NULL }, - { 0x0a980, 0x0a982, 0, NULL, NULL }, - { 0x0a960, 0x0a97c, 2, NULL, NULL }, - { 0x0a9b3, 0x0a9b3, 0, NULL, NULL }, - { 0x0aa29, 0x0aa2e, 0, NULL, NULL }, - { 0x0a9bc, 0x0a9bc, 0, NULL, NULL }, - { 0x0a9e5, 0x0a9e5, 0, NULL, NULL }, - { 0x0aa35, 0x0aa36, 0, NULL, NULL }, - { 0x0aa31, 0x0aa32, 0, NULL, NULL }, - { 0x0aa43, 0x0aa43, 0, NULL, NULL }, - { 0x0fb1e, 0x0fb1e, 0, NULL, NULL }, - { 0x0aaf6, 0x0aaf6, 0, NULL, NULL }, - { 0x0aab7, 0x0aab8, 0, NULL, NULL }, - { 0x0aab0, 0x0aab0, 0, NULL, NULL }, - { 0x0aa7c, 0x0aa7c, 0, NULL, NULL }, - { 0x0aab2, 0x0aab4, 0, NULL, NULL }, - { 0x0aac1, 0x0aac1, 0, NULL, NULL }, - { 0x0aabe, 0x0aabf, 0, NULL, NULL }, - { 0x0aaec, 0x0aaed, 0, NULL, NULL }, - { 0x0ac00, 0x0d7a3, 2, NULL, NULL }, - { 0x0abe8, 0x0abe8, 0, NULL, NULL }, - { 0x0abe5, 0x0abe5, 0, NULL, NULL }, - { 0x0abed, 0x0abed, 0, NULL, NULL }, - { 0x0f900, 0x0fa6d, 2, NULL, NULL }, - { 0x0d800, 0x0dfff, 0, NULL, NULL }, - { 0x0fa70, 0x0fad9, 2, NULL, NULL }, - { 0x0fff9, 0x0fffb, 0, NULL, NULL }, - { 0x0fe30, 0x0fe52, 2, NULL, NULL }, - { 0x0fe10, 0x0fe19, 2, NULL, NULL }, - { 0x0fe00, 0x0fe0f, 0, NULL, NULL }, - { 0x0fe20, 0x0fe2d, 0, NULL, NULL }, - { 0x0fe68, 0x0fe6b, 2, NULL, NULL }, - { 0x0fe54, 0x0fe66, 2, NULL, NULL }, - { 0x0feff, 0x0feff, 0, NULL, NULL }, - { 0x10a01, 0x10a03, 0, NULL, NULL }, - { 0x102e0, 0x102e0, 0, NULL, NULL }, - { 0x101fd, 0x101fd, 0, NULL, NULL }, - { 0x10376, 0x1037a, 0, NULL, NULL }, - { 0x10a0c, 0x10a0f, 0, NULL, NULL }, - { 0x10a05, 0x10a06, 0, NULL, NULL }, - { 0x10a38, 0x10a3a, 0, NULL, NULL }, - { 0x11633, 0x1163a, 0, NULL, NULL }, - { 0x11236, 0x11237, 0, NULL, NULL }, - { 0x11100, 0x11102, 0, NULL, NULL }, - { 0x1107f, 0x11081, 0, NULL, NULL }, - { 0x11001, 0x11001, 0, NULL, NULL }, - { 0x10ae5, 0x10ae6, 0, NULL, NULL }, - { 0x11038, 0x11046, 0, NULL, NULL }, - { 0x110b9, 0x110ba, 0, NULL, NULL }, - { 0x110b3, 0x110b6, 0, NULL, NULL }, - { 0x110bd, 0x110bd, 0, NULL, NULL }, - { 0x11180, 0x11181, 0, NULL, NULL }, - { 0x1112d, 0x11134, 0, NULL, NULL }, - { 0x11127, 0x1112b, 0, NULL, NULL }, - { 0x11173, 0x11173, 0, NULL, NULL }, - { 0x1122f, 0x11231, 0, NULL, NULL }, - { 0x111b6, 0x111be, 0, NULL, NULL }, - { 0x11234, 0x11234, 0, NULL, NULL }, - { 0x11370, 0x11374, 0, NULL, NULL }, - { 0x11301, 0x11301, 0, NULL, NULL }, - { 0x112df, 0x112df, 0, NULL, NULL }, - { 0x112e3, 0x112ea, 0, NULL, NULL }, - { 0x11340, 0x11340, 0, NULL, NULL }, - { 0x1133c, 0x1133c, 0, NULL, NULL }, - { 0x11366, 0x1136c, 0, NULL, NULL }, - { 0x114c2, 0x114c3, 0, NULL, NULL }, - { 0x114ba, 0x114ba, 0, NULL, NULL }, - { 0x114b3, 0x114b8, 0, NULL, NULL }, - { 0x114bf, 0x114c0, 0, NULL, NULL }, - { 0x115bc, 0x115bd, 0, NULL, NULL }, - { 0x115b2, 0x115b5, 0, NULL, NULL }, - { 0x115bf, 0x115c0, 0, NULL, NULL }, - { 0x1d1aa, 0x1d1ad, 0, NULL, NULL }, - { 0x16b30, 0x16b36, 0, NULL, NULL }, - { 0x116ad, 0x116ad, 0, NULL, NULL }, - { 0x1163f, 0x11640, 0, NULL, NULL }, - { 0x1163d, 0x1163d, 0, NULL, NULL }, - { 0x116ab, 0x116ab, 0, NULL, NULL }, - { 0x116b7, 0x116b7, 0, NULL, NULL }, - { 0x116b0, 0x116b5, 0, NULL, NULL }, - { 0x16af0, 0x16af4, 0, NULL, NULL }, - { 0x1bca0, 0x1bca3, 0, NULL, NULL }, - { 0x1b000, 0x1b001, 2, NULL, NULL }, - { 0x16f8f, 0x16f92, 0, NULL, NULL }, - { 0x1bc9d, 0x1bc9e, 0, NULL, NULL }, - { 0x1d173, 0x1d182, 0, NULL, NULL }, - { 0x1d167, 0x1d169, 0, NULL, NULL }, - { 0x1d185, 0x1d18b, 0, NULL, NULL }, - { 0x2a700, 0x2b734, 2, NULL, NULL }, - { 0x1f210, 0x1f23a, 2, NULL, NULL }, - { 0x1e8d0, 0x1e8d6, 0, NULL, NULL }, - { 0x1d242, 0x1d244, 0, NULL, NULL }, - { 0x1f200, 0x1f202, 2, NULL, NULL }, - { 0x1f250, 0x1f251, 2, NULL, NULL }, - { 0x1f240, 0x1f248, 2, NULL, NULL }, - { 0x20000, 0x2a6d6, 2, NULL, NULL }, - { 0xe0020, 0xe007f, 0, NULL, NULL }, - { 0x2f800, 0x2fa1d, 2, NULL, NULL }, - { 0x2b740, 0x2b81d, 2, NULL, NULL }, - { 0xe0001, 0xe0001, 0, NULL, NULL }, - { 0xf0000, 0xffffd, 0, NULL, NULL }, - { 0xe0100, 0xe01ef, 0, NULL, NULL }, - { 0x100000, 0x10fffd, 0, NULL, NULL }, -}; -static struct utf8_width_entry *utf8_width_root = NULL; - -static void utf8_build(void); - /* Set a single character. */ void utf8_set(struct utf8_data *ud, u_char ch) @@ -421,118 +98,45 @@ utf8_append(struct utf8_data *ud, u_char ch) return (UTF8_DONE); } -/* Build UTF-8 width tree. */ -static void -utf8_build(void) -{ - struct utf8_width_entry **ptr, *item, *node; - u_int i; - - for (i = 0; i < nitems(utf8_width_table); i++) { - item = &utf8_width_table[i]; - - ptr = &utf8_width_root; - while (*ptr != NULL) { - node = *ptr; - if (item->last < node->first) - ptr = &node->left; - else if (item->first > node->last) - ptr = &node->right; - } - *ptr = item; - } -} - -/* Lookup width of UTF-8 data in tree. */ +/* Get width of Unicode character. */ u_int -utf8_width(u_int uc) +utf8_width(wchar_t wc) { - struct utf8_width_entry *item; + int width; - if (utf8_width_root == NULL) - utf8_build(); - - item = utf8_width_root; - while (item != NULL) { - if (uc < item->first) - item = item->left; - else if (uc > item->last) - item = item->right; - else - return (item->width); - } - return (1); + width = wcwidth(wc); + if (width < 0) + return (0); + return (width); } -/* Combine UTF-8 into 32-bit Unicode. */ -u_int +/* Combine UTF-8 into Unicode. */ +wchar_t utf8_combine(const struct utf8_data *ud) { - u_int uc; - - uc = 0xfffd; - switch (ud->size) { - case 1: - uc = ud->data[0]; - break; - case 2: - uc = ud->data[1] & 0x3f; - uc |= (ud->data[0] & 0x1f) << 6; - break; - case 3: - uc = ud->data[2] & 0x3f; - uc |= (ud->data[1] & 0x3f) << 6; - uc |= (ud->data[0] & 0xf) << 12; - break; - case 4: - uc = ud->data[3] & 0x3f; - uc |= (ud->data[2] & 0x3f) << 6; - uc |= (ud->data[1] & 0x3f) << 12; - uc |= (ud->data[0] & 0x7) << 18; - break; - } - return (uc); + wchar_t wc; + + if (mbtowc(&wc, ud->data, ud->size) <= 0) + return (0xfffd); + return (wc); } -/* Split 32-bit Unicode into UTF-8. */ +/* Split Unicode into UTF-8. */ enum utf8_state -utf8_split(u_int uc, struct utf8_data *ud) +utf8_split(wchar_t wc, struct utf8_data *ud) { - if (uc < 0x7f) { - ud->size = 1; - ud->data[0] = uc; - } else if (uc < 0x7ff) { - ud->size = 2; - ud->data[0] = 0xc0 | ((uc >> 6) & 0x1f); - ud->data[1] = 0x80 | (uc & 0x3f); - } else if (uc < 0xffff) { - ud->size = 3; - ud->data[0] = 0xe0 | ((uc >> 12) & 0xf); - ud->data[1] = 0x80 | ((uc >> 6) & 0x3f); - ud->data[2] = 0x80 | (uc & 0x3f); - } else if (uc < 0x1fffff) { - ud->size = 4; - ud->data[0] = 0xf0 | ((uc >> 18) & 0x7); - ud->data[1] = 0x80 | ((uc >> 12) & 0x3f); - ud->data[2] = 0x80 | ((uc >> 6) & 0x3f); - ud->data[3] = 0x80 | (uc & 0x3f); - } else + char s[MB_CUR_MAX]; + int slen; + + slen = wctomb(s, wc); + if (slen <= 0 || slen > (int)sizeof ud->data) return (UTF8_ERROR); - ud->width = utf8_width(uc); - return (UTF8_DONE); -} -/* Split a two-byte UTF-8 character. */ -u_int -utf8_split2(u_int uc, u_char *ptr) -{ - if (uc > 0x7f) { - ptr[0] = (uc >> 6) | 0xc0; - ptr[1] = (uc & 0x3f) | 0x80; - return (2); - } - ptr[0] = uc; - return (1); + memcpy(ud->data, s, slen); + ud->size = slen; + + ud->width = utf8_width(wc); + return (UTF8_DONE); } /* From e647eeb0c92cb5cf9134f77c30dce49f27224304 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 1 Mar 2016 12:02:54 +0000 Subject: [PATCH 35/47] Remove unused variables, from Michal Mazurek. --- cmd-swap-pane.c | 9 ++------- tmux.c | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c index aec7753de..13575e0af 100644 --- a/cmd-swap-pane.c +++ b/cmd-swap-pane.c @@ -45,28 +45,23 @@ const struct cmd_entry cmd_swap_pane_entry = { enum cmd_retval cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq) { - struct winlink *src_wl, *dst_wl; struct window *src_w, *dst_w; struct window_pane *tmp_wp, *src_wp, *dst_wp; struct layout_cell *src_lc, *dst_lc; u_int sx, sy, xoff, yoff; - dst_wl = cmdq->state.tflag.wl; - dst_w = dst_wl->window; + dst_w = cmdq->state.tflag.wl->window; dst_wp = cmdq->state.tflag.wp; - src_wl = cmdq->state.sflag.wl; - src_w = src_wl->window; + src_w = cmdq->state.sflag.wl->window; src_wp = cmdq->state.sflag.wp; server_unzoom_window(dst_w); if (args_has(self->args, 'D')) { - src_wl = dst_wl; src_w = dst_w; src_wp = TAILQ_NEXT(dst_wp, entry); if (src_wp == NULL) src_wp = TAILQ_FIRST(&dst_w->panes); } else if (args_has(self->args, 'U')) { - src_wl = dst_wl; src_w = dst_w; src_wp = TAILQ_PREV(dst_wp, window_panes, entry); if (src_wp == NULL) diff --git a/tmux.c b/tmux.c index 68cd4bb7d..93503d2de 100644 --- a/tmux.c +++ b/tmux.c @@ -188,7 +188,6 @@ main(int argc, char **argv) const char *s; int opt, flags, keys; - setlocale(LC_CTYPE, "en_US.UTF-8"); setlocale(LC_TIME, ""); From 54ea8f74ae4ae3bff6df3f09ce8a8cdd148e51e5 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 1 Mar 2016 12:04:43 +0000 Subject: [PATCH 36/47] When a mouse drag is finished, fire a MouseUp key press, instead of doing the drag end in code. From Stephen Coakley. --- mode-key.c | 2 ++ server-client.c | 42 ++++++++++++++++++++++++++++++++++++++++-- window-copy.c | 15 +-------------- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/mode-key.c b/mode-key.c index f38ebf661..a9b15bb94 100644 --- a/mode-key.c +++ b/mode-key.c @@ -347,6 +347,7 @@ const struct mode_key_entry mode_key_vi_copy[] = { { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP }, { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN }, { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION }, + { KEYC_MOUSEUP1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, { 0, -1, 0 } }; @@ -495,6 +496,7 @@ const struct mode_key_entry mode_key_emacs_copy[] = { { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP }, { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN }, { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION }, + { KEYC_MOUSEUP1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, { 0, -1, 0 } }; diff --git a/server-client.c b/server-client.c index bb54643a3..9111eb82d 100644 --- a/server-client.c +++ b/server-client.c @@ -384,8 +384,42 @@ server_client_check_mouse(struct client *c) c->tty.mouse_drag_update = NULL; c->tty.mouse_drag_release = NULL; + /* + * End a mouse drag by passing a MouseUp key corresponding to + * the button that started the drag. + */ + switch (c->tty.mouse_drag_flag) { + case 1: + if (where == PANE) + key = KEYC_MOUSEUP1_PANE; + if (where == STATUS) + key = KEYC_MOUSEUP1_STATUS; + if (where == BORDER) + key = KEYC_MOUSEUP1_BORDER; + break; + case 2: + if (where == PANE) + key = KEYC_MOUSEUP2_PANE; + if (where == STATUS) + key = KEYC_MOUSEUP2_STATUS; + if (where == BORDER) + key = KEYC_MOUSEUP2_BORDER; + break; + case 3: + if (where == PANE) + key = KEYC_MOUSEUP3_PANE; + if (where == STATUS) + key = KEYC_MOUSEUP3_STATUS; + if (where == BORDER) + key = KEYC_MOUSEUP3_BORDER; + break; + default: + key = KEYC_MOUSE; + break; + } c->tty.mouse_drag_flag = 0; - return (KEYC_MOUSE); /* not a key, but still may want to pass */ + + return (key); } /* Convert to a key binding. */ @@ -425,7 +459,11 @@ server_client_check_mouse(struct client *c) } } - c->tty.mouse_drag_flag = 1; + /* + * Begin a drag by setting the flag to a non-zero value that + * corresponds to the mouse button in use. + */ + c->tty.mouse_drag_flag = MOUSE_BUTTONS(b) + 1; break; case WHEEL: if (MOUSE_BUTTONS(b) == MOUSE_WHEEL_UP) { diff --git a/window-copy.c b/window-copy.c index 009ed2460..d345f2464 100644 --- a/window-copy.c +++ b/window-copy.c @@ -2248,7 +2248,7 @@ window_copy_start_drag(struct client *c, struct mouse_event *m) return; c->tty.mouse_drag_update = window_copy_drag_update; - c->tty.mouse_drag_release = window_copy_drag_release; + c->tty.mouse_drag_release = NULL; /* will fire MouseUp key */ window_copy_update_cursor(wp, x, y); window_copy_start_selection(wp); @@ -2275,16 +2275,3 @@ window_copy_drag_update(__unused struct client *c, struct mouse_event *m) if (window_copy_update_selection(wp, 1)) window_copy_redraw_selection(wp, old_cy); } - -void -window_copy_drag_release(__unused struct client *c, struct mouse_event *m) -{ - struct window_pane *wp; - - wp = cmd_mouse_pane(m, NULL, NULL); - if (wp == NULL || wp->mode != &window_copy_mode) - return; - - window_copy_copy_selection(wp, NULL); - window_pane_reset_mode(wp); -} From 2e4503ad4eec5422e6425480681a261258f7e940 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 1 Mar 2016 12:05:15 +0000 Subject: [PATCH 37/47] Redraw status on mode entry and exit. --- window.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/window.c b/window.c index 201942a37..1769552f9 100644 --- a/window.c +++ b/window.c @@ -1085,6 +1085,8 @@ window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode) if ((s = wp->mode->init(wp)) != NULL) wp->screen = s; wp->flags |= (PANE_REDRAW|PANE_CHANGED); + + server_status_window(wp->window); return (0); } @@ -1099,6 +1101,8 @@ window_pane_reset_mode(struct window_pane *wp) wp->screen = &wp->base; wp->flags |= (PANE_REDRAW|PANE_CHANGED); + + server_status_window(wp->window); } void From f0239a8fe97367ce7ab66d18716c411b424a0e63 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 1 Mar 2016 12:06:07 +0000 Subject: [PATCH 38/47] Remove some more unused variables, and use RB_FOREACH_SAFE in key_bindings_unref_table. --- cmd-if-shell.c | 3 +-- cmd-resize-pane.c | 1 - cmd.c | 1 - key-bindings.c | 4 ++-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 229289cd4..3e2a52519 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -73,14 +73,13 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq) struct format_tree *ft; const char *cwd; - cwd = wp->cwd; - if (cmdq->client != NULL && cmdq->client->session == NULL) cwd = cmdq->client->cwd; else if (s != NULL) cwd = s->cwd; else cwd = NULL; + ft = format_create(cmdq, 0); format_defaults(ft, NULL, s, wl, wp); shellcmd = format_expand(ft, args->argv[0]); diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index 2b4f1c177..7ec65f10c 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -68,7 +68,6 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_NORMAL); } - w = wl->window; if (args_has(args, 'Z')) { if (w->flags & WINDOW_ZOOMED) window_unzoom(w); diff --git a/cmd.c b/cmd.c index 005f2a0f3..c643a346b 100644 --- a/cmd.c +++ b/cmd.c @@ -482,7 +482,6 @@ cmd_prepare_state_flag(char c, const char *target, enum cmd_entry_flag flag, CMD_FIND_SESSION, CMD_FIND_QUIET); if (error == 0) break; - flag = CMD_WINDOW_INDEX; /* FALLTHROUGH */ case CMD_WINDOW: case CMD_WINDOW_CANFAIL: diff --git a/key-bindings.c b/key-bindings.c index a922eb183..0d13385de 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -68,12 +68,12 @@ void key_bindings_unref_table(struct key_table *table) { struct key_binding *bd; + struct key_binding *bd1; if (--table->references != 0) return; - while (!RB_EMPTY(&table->key_bindings)) { - bd = RB_ROOT(&table->key_bindings); + RB_FOREACH_SAFE(bd, key_bindings, &table->key_bindings, bd1) { RB_REMOVE(key_bindings, &table->key_bindings, bd); cmd_list_free(bd->cmdlist); free(bd); From d980d965ddb6165bd801351892fed2497204a279 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 2 Mar 2016 15:33:36 +0000 Subject: [PATCH 39/47] Limit x, y and b to 0x7ff for UTF-8 mouse input, suggested by schwarze@. --- input-keys.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/input-keys.c b/input-keys.c index 47786d273..41bd5ab50 100644 --- a/input-keys.c +++ b/input-keys.c @@ -263,6 +263,8 @@ input_key_mouse(struct window_pane *wp, struct mouse_event *m) len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c", m->sgr_b, x + 1, y + 1, m->sgr_type); } else if (wp->screen->mode & MODE_MOUSE_UTF8) { + if (m->b > 0x7ff - 32 || x > 0x7ff - 33 || y > 0x7ff - 33) + return; len = xsnprintf(buf, sizeof buf, "\033[M"); len += input_split2(m->b + 32, &buf[len]); len += input_split2(x + 33, &buf[len]); From b8a102d26f41e57b94359627a4df8f22af10c6fa Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 2 Mar 2016 15:36:02 +0000 Subject: [PATCH 40/47] Handle wcwidth() and mbtowc() failures in better style and drop characters where we can't find the width (wcwidth() fails) on input, the same as we drop invalid UTF-8. Suggested by schwarze@. --- input.c | 10 ++++++++-- key-string.c | 6 ++++-- tmux.h | 3 +-- tty-keys.c | 7 ++++++- utf8.c | 43 +++++++++++++++++++++++++++++-------------- 5 files changed, 48 insertions(+), 21 deletions(-) diff --git a/input.c b/input.c index ae2050241..18c8eb9ad 100644 --- a/input.c +++ b/input.c @@ -1960,8 +1960,14 @@ input_utf8_close(struct input_ctx *ictx) { struct utf8_data *ud = &ictx->utf8data; - if (utf8_append(ud, ictx->ch) != UTF8_DONE) - fatalx("UTF-8 close invalid %#x", ictx->ch); + if (utf8_append(ud, ictx->ch) != UTF8_DONE) { + /* + * An error here could be invalid UTF-8 or it could be a + * nonprintable character for which we can't get the + * width. Drop it. + */ + return (0); + } log_debug("%s %hhu '%*s' (width %hhu)", __func__, ud->size, (int)ud->size, ud->data, ud->width); diff --git a/key-string.c b/key-string.c index dc2116969..c56681f1a 100644 --- a/key-string.c +++ b/key-string.c @@ -149,6 +149,7 @@ key_string_lookup_string(const char *string) struct utf8_data ud; u_int i; enum utf8_state more; + wchar_t wc; /* Is this no key? */ if (strcasecmp(string, "None") == 0) @@ -185,8 +186,9 @@ key_string_lookup_string(const char *string) more = utf8_append(&ud, (u_char)string[i]); if (more != UTF8_DONE) return (KEYC_UNKNOWN); - key = utf8_combine(&ud); - return (key | modifiers); + if (utf8_combine(&ud, &wc) != UTF8_DONE) + return (KEYC_UNKNOWN); + return (wc | modifiers); } /* Otherwise look the key up in the table. */ diff --git a/tmux.h b/tmux.h index b00c7469a..ac94d7804 100644 --- a/tmux.h +++ b/tmux.h @@ -2316,8 +2316,7 @@ void utf8_set(struct utf8_data *, u_char); void utf8_copy(struct utf8_data *, const struct utf8_data *); enum utf8_state utf8_open(struct utf8_data *, u_char); enum utf8_state utf8_append(struct utf8_data *, u_char); -u_int utf8_width(wchar_t); -wchar_t utf8_combine(const struct utf8_data *); +enum utf8_state utf8_combine(const struct utf8_data *, wchar_t *); enum utf8_state utf8_split(wchar_t, struct utf8_data *); int utf8_strvis(char *, const char *, size_t, int); char *utf8_sanitize(const char *); diff --git a/tty-keys.c b/tty-keys.c index 2b9987781..105f99f77 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -477,6 +477,7 @@ tty_keys_next(struct tty *tty) struct utf8_data ud; enum utf8_state more; u_int i; + wchar_t wc; /* Get key buffer. */ buf = EVBUFFER_DATA(tty->event->input); @@ -552,7 +553,11 @@ tty_keys_next(struct tty *tty) more = utf8_append(&ud, (u_char)buf[i]); if (more != UTF8_DONE) goto discard_key; - key = utf8_combine(&ud); + + if (utf8_combine(&ud, &wc) != UTF8_DONE) + goto discard_key; + key = wc; + log_debug("UTF-8 key %.*s %#llx", (int)size, buf, key); goto complete_key; } diff --git a/utf8.c b/utf8.c index be0915bab..114f2b906 100644 --- a/utf8.c +++ b/utf8.c @@ -25,6 +25,8 @@ #include "tmux.h" +static int utf8_width(wchar_t); + /* Set a single character. */ void utf8_set(struct utf8_data *ud, u_char ch) @@ -80,6 +82,9 @@ utf8_open(struct utf8_data *ud, u_char ch) enum utf8_state utf8_append(struct utf8_data *ud, u_char ch) { + wchar_t wc; + int width; + if (ud->have >= ud->size) fatalx("UTF-8 character overflow"); if (ud->size > sizeof ud->data) @@ -94,39 +99,49 @@ utf8_append(struct utf8_data *ud, u_char ch) if (ud->width == 0xff) return (UTF8_ERROR); - ud->width = utf8_width(utf8_combine(ud)); + + if (utf8_combine(ud, &wc) != UTF8_DONE) + return (UTF8_ERROR); + if ((width = utf8_width(wc)) < 0) + return (UTF8_ERROR); + ud->width = width; + return (UTF8_DONE); } /* Get width of Unicode character. */ -u_int +static int utf8_width(wchar_t wc) { - int width; + int width; width = wcwidth(wc); - if (width < 0) - return (0); + if (width < 0 || width > 0xff) + return (-1); return (width); } /* Combine UTF-8 into Unicode. */ -wchar_t -utf8_combine(const struct utf8_data *ud) +enum utf8_state +utf8_combine(const struct utf8_data *ud, wchar_t *wc) { - wchar_t wc; - - if (mbtowc(&wc, ud->data, ud->size) <= 0) - return (0xfffd); - return (wc); + switch (mbtowc(wc, ud->data, ud->size)) { + case -1: + mbtowc(NULL, NULL, MB_CUR_MAX); + return (UTF8_ERROR); + case 0: + return (UTF8_ERROR); + default: + return (UTF8_DONE); + } } /* Split Unicode into UTF-8. */ enum utf8_state utf8_split(wchar_t wc, struct utf8_data *ud) { - char s[MB_CUR_MAX]; - int slen; + char s[MB_LEN_MAX]; + int slen; slen = wctomb(s, wc); if (slen <= 0 || slen > (int)sizeof ud->data) From 9e2fbb31ec34c38d7e3acd42895f11b1a83bcd19 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 2 Mar 2016 18:19:13 +0000 Subject: [PATCH 41/47] +wchar.h --- utf8.c | 1 + 1 file changed, 1 insertion(+) diff --git a/utf8.c b/utf8.c index 6d80266b6..c04075767 100644 --- a/utf8.c +++ b/utf8.c @@ -20,6 +20,7 @@ #include #include +#include #include "tmux.h" From bcb41a09b3d3f0c61d2e98c0b91fcea52f745efb Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Mar 2016 12:58:15 +0000 Subject: [PATCH 42/47] RGB colours shouldn't be mixed up with aixterm colours, return before that happens when working out if they are supported. --- tty.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tty.c b/tty.c index c6fc22134..2dff57005 100644 --- a/tty.c +++ b/tty.c @@ -1569,6 +1569,8 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc) gc->flags |= GRID_FLAG_FG256; gc->fg = colour_find_rgb(rgb->r, rgb->g, rgb->b); } + else + return; } colours = tty_term_number(tty->term, TTYC_COLORS); @@ -1612,6 +1614,8 @@ tty_check_bg(struct tty *tty, struct grid_cell *gc) gc->flags |= GRID_FLAG_BG256; gc->bg = colour_find_rgb(rgb->r, rgb->g, rgb->b); } + else + return; } colours = tty_term_number(tty->term, TTYC_COLORS); From fa81d838dacb2dd05d4556db3cbcb3760b7d2c47 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Mar 2016 14:14:46 +0000 Subject: [PATCH 43/47] Accept clients as sessions in cmd_find_get_session. --- cmd-find.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd-find.c b/cmd-find.c index 7ffc5f15d..225112011 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -401,6 +401,7 @@ int cmd_find_get_session(struct cmd_find_state *fs, const char *session) { struct session *s, *s_loop; + struct client *c; log_debug("%s: %s", __func__, session); @@ -417,6 +418,13 @@ cmd_find_get_session(struct cmd_find_state *fs, const char *session) if (fs->s != NULL) return (0); + /* Look for as a client. */ + c = cmd_find_client(NULL, session, 1); + if (c != NULL && c->session != NULL) { + fs->s = c->session; + return (0); + } + /* Stop now if exact only. */ if (fs->flags & CMD_FIND_EXACT_SESSION) return (-1); @@ -1209,7 +1217,7 @@ cmd_find_client(struct cmd_q *cmdq, const char *target, int quiet) const char *path; /* A NULL argument means the current client. */ - if (target == NULL) { + if (cmdq != NULL && target == NULL) { c = cmd_find_current_client(cmdq); if (c == NULL && !quiet) cmdq_error(cmdq, "no current client"); From df0983af39922f2ee747a244c1c718ba7ca28910 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Mar 2016 14:15:22 +0000 Subject: [PATCH 44/47] show-* and set-* need to handle a missing target. --- cmd-set-environment.c | 15 ++++++++++++--- cmd-set-option.c | 38 +++++++++++++++++++------------------- cmd-show-environment.c | 21 +++++++++++++++++++-- cmd-show-options.c | 31 +++++++++++++++++++++++-------- 4 files changed, 73 insertions(+), 32 deletions(-) diff --git a/cmd-set-environment.c b/cmd-set-environment.c index 55bdaa9ae..ba295ea6f 100644 --- a/cmd-set-environment.c +++ b/cmd-set-environment.c @@ -47,7 +47,7 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; struct environ *env; - const char *name, *value; + const char *name, *value, *target; name = args->argv[0]; if (*name == '\0') { @@ -64,10 +64,19 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq) else value = args->argv[1]; - if (args_has(self->args, 'g') || cmdq->state.tflag.s == NULL) + if (args_has(self->args, 'g')) env = global_environ; - else + else { + if (cmdq->state.tflag.s == NULL) { + target = args_get(args, 't'); + if (target != NULL) + cmdq_error(cmdq, "no such session: %s", target); + else + cmdq_error(cmdq, "no current session"); + return (CMD_RETURN_ERROR); + } env = cmdq->state.tflag.s->environ; + } if (args_has(self->args, 'u')) { if (value != NULL) { diff --git a/cmd-set-option.c b/cmd-set-option.c index 7fc812865..b17714364 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -100,7 +100,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq) struct client *c; const struct options_table_entry *oe; struct options *oo; - const char *optstr, *valstr; + const char *optstr, *valstr, *target; /* Get the option name and value. */ optstr = args->argv[0]; @@ -140,29 +140,29 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq) else if (oe->scope == OPTIONS_TABLE_WINDOW) { if (args_has(self->args, 'g')) oo = global_w_options; - else { - if (wl == NULL) { - cmdq_error(cmdq, - "couldn't set '%s'%s", optstr, - (!args_has(args, 't') && !args_has(args, - 'g')) ? " need target window or -g" : ""); - return (CMD_RETURN_ERROR); - } + else if (wl == NULL) { + target = args_get(args, 't'); + if (target != NULL) { + cmdq_error(cmdq, "no such window: %s", + target); + } else + cmdq_error(cmdq, "no current window"); + return (CMD_RETURN_ERROR); + } else oo = wl->window->options; - } } else if (oe->scope == OPTIONS_TABLE_SESSION) { if (args_has(self->args, 'g')) oo = global_s_options; - else { - if (s == NULL) { - cmdq_error(cmdq, - "couldn't set '%s'%s", optstr, - (!args_has(args, 't') && !args_has(args, - 'g')) ? " need target session or -g" : ""); - return (CMD_RETURN_ERROR); - } + else if (s == NULL) { + target = args_get(args, 't'); + if (target != NULL) { + cmdq_error(cmdq, "no such session: %s", + target); + } else + cmdq_error(cmdq, "no current session"); + return (CMD_RETURN_ERROR); + } else oo = s->options; - } } else { cmdq_error(cmdq, "unknown table"); return (CMD_RETURN_ERROR); diff --git a/cmd-show-environment.c b/cmd-show-environment.c index 83661c440..29e892747 100644 --- a/cmd-show-environment.c +++ b/cmd-show-environment.c @@ -93,11 +93,28 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq) struct args *args = self->args; struct environ *env; struct environ_entry *envent; + const char *target; - if (args_has(self->args, 'g') || cmdq->state.tflag.s == NULL) + if ((target = args_get(args, 't')) != NULL) { + if (cmdq->state.tflag.s == NULL) { + cmdq_error(cmdq, "no such session: %s", target); + return (CMD_RETURN_ERROR); + } + } + + if (args_has(self->args, 'g')) env = global_environ; - else + else { + if (cmdq->state.tflag.s == NULL) { + target = args_get(args, 't'); + if (target != NULL) + cmdq_error(cmdq, "no such session: %s", target); + else + cmdq_error(cmdq, "no current session"); + return (CMD_RETURN_ERROR); + } env = cmdq->state.tflag.s->environ; + } if (args->argc != 0) { envent = environ_find(env, args->argv[0]); diff --git a/cmd-show-options.c b/cmd-show-options.c index fec2f1deb..322f532c9 100644 --- a/cmd-show-options.c +++ b/cmd-show-options.c @@ -63,12 +63,13 @@ const struct cmd_entry cmd_show_window_options_entry = { enum cmd_retval cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq) { - struct args *args = self->args; - struct session *s = cmdq->state.tflag.s; - struct winlink *wl = cmdq->state.tflag.wl; - struct options *oo; - enum options_table_scope scope; - int quiet; + struct args *args = self->args; + struct session *s = cmdq->state.tflag.s; + struct winlink *wl = cmdq->state.tflag.wl; + struct options *oo; + enum options_table_scope scope; + int quiet; + const char *target; if (args_has(self->args, 's')) { oo = global_options; @@ -78,13 +79,27 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq) scope = OPTIONS_TABLE_WINDOW; if (args_has(self->args, 'g')) oo = global_w_options; - else + else if (wl == NULL) { + target = args_get(args, 't'); + if (target != NULL) { + cmdq_error(cmdq, "no such window: %s", target); + } else + cmdq_error(cmdq, "no current window"); + return (CMD_RETURN_ERROR); + } else oo = wl->window->options; } else { scope = OPTIONS_TABLE_SESSION; if (args_has(self->args, 'g')) oo = global_s_options; - else + else if (s == NULL) { + target = args_get(args, 't'); + if (target != NULL) { + cmdq_error(cmdq, "no such session: %s", target); + } else + cmdq_error(cmdq, "no current session"); + return (CMD_RETURN_ERROR); + } else oo = s->options; } From 1f0b317088aaeb230d69f13f43ed63b7406c6fd1 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 5 Mar 2016 07:44:31 +0000 Subject: [PATCH 45/47] Although we always have en_US.UTF-8 on OpenBSD, some platforms do not, so fall back to setlocale(LC_CTYPE, ""). tmux requires a UTF-8 locale, so check with wcwidth() on a UTF-8 character after setlocale(). --- tmux.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tmux.c b/tmux.c index 93503d2de..d221c78ec 100644 --- a/tmux.c +++ b/tmux.c @@ -188,9 +188,12 @@ main(int argc, char **argv) const char *s; int opt, flags, keys; - setlocale(LC_CTYPE, "en_US.UTF-8"); - setlocale(LC_TIME, ""); + if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) + setlocale(LC_CTYPE, ""); + if (wcwidth(0xfffd) != 1) + errx(1, "no UTF-8 locale; please set LC_CTYPE"); + setlocale(LC_TIME, ""); tzset(); if (**argv == '-') From c38e0a4bbc722865f934db1282ca6f086874f530 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 5 Mar 2016 07:47:52 +0000 Subject: [PATCH 46/47] Do not use c->cwd or s->cwd if it is NULL, found by Ben Boeckel. --- cmd-load-buffer.c | 4 ++-- cmd-new-session.c | 2 +- cmd-save-buffer.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c index 6fd2a767f..de76b8556 100644 --- a/cmd-load-buffer.c +++ b/cmd-load-buffer.c @@ -73,9 +73,9 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_WAIT); } - if (c != NULL && c->session == NULL) + if (c != NULL && c->session == NULL && c->cwd != NULL) cwd = c->cwd; - else if ((s = c->session) != NULL) + else if ((s = c->session) != NULL && s->cwd != NULL) cwd = s->cwd; else cwd = "."; diff --git a/cmd-new-session.c b/cmd-new-session.c index 291107bc0..357ffed14 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -142,7 +142,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq) format_defaults(ft, c, NULL, NULL, NULL); to_free = cwd = format_expand(ft, args_get(args, 'c')); format_free(ft); - } else if (c != NULL && c->session == NULL) + } else if (c != NULL && c->session == NULL && c->cwd != NULL) cwd = c->cwd; else cwd = "."; diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c index 591390b59..3aaf81593 100644 --- a/cmd-save-buffer.c +++ b/cmd-save-buffer.c @@ -98,9 +98,9 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq) goto do_print; } - if (c != NULL && c->session == NULL) + if (c != NULL && c->session == NULL && c->cwd != NULL) cwd = c->cwd; - else if ((s = c->session) != NULL) + else if ((s = c->session) != NULL && s->cwd != NULL) cwd = s->cwd; else cwd = "."; From 0d6de44a37755f0e5046c04e19e4506a6d59e750 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 5 Mar 2016 16:08:38 +0000 Subject: [PATCH 47/47] If setlocale("en_US.UTF-8") succeeds, then don't do the check for UTF-8 locale since if it isn't UTF-8 the system is broken anyway. If it fails, try "" and check for UTF-8 with nl_langinfo(CODESET) rather than wcwidth(). Based on a diff from schwarze@, nl_langinfo also suggested by stsp@. --- tmux.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tmux.c b/tmux.c index d221c78ec..f8654e2b2 100644 --- a/tmux.c +++ b/tmux.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -188,10 +189,14 @@ main(int argc, char **argv) const char *s; int opt, flags, keys; - if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) - setlocale(LC_CTYPE, ""); - if (wcwidth(0xfffd) != 1) - errx(1, "no UTF-8 locale; please set LC_CTYPE"); + if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) { + if (setlocale(LC_CTYPE, "") == NULL) + errx(1, "invalid LC_ALL, LC_CTYPE or LANG"); + s = nl_langinfo(CODESET); + if (strcasecmp(s, "UTF-8") != 0 && + strcasecmp(s, "UTF8") != 0) + errx(1, "need UTF-8 locale (LC_CTYPE) but have %s", s); + } setlocale(LC_TIME, ""); tzset();