diff --git a/cfg.c b/cfg.c index d12af67d..5a6d67ef 100644 --- a/cfg.c +++ b/cfg.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "tmux.h" @@ -36,9 +37,10 @@ int load_cfg(const char *path, struct cmd_q *cmdq, char **cause) { FILE *f; - u_int n, found; - char *buf, *copy, *line, *cause1, *msg; - size_t len, oldlen; + char delim[3] = { '\\', '\\', '\0' }; + u_int found; + size_t line = 0; + char *buf, *cause1, *msg, *p; struct cmd_list *cmdlist; log_debug("loading %s", path); @@ -47,60 +49,30 @@ load_cfg(const char *path, struct cmd_q *cmdq, char **cause) return (-1); } - n = found = 0; - line = NULL; - while ((buf = fgetln(f, &len))) { - /* Trim \n. */ - if (buf[len - 1] == '\n') - len--; - log_debug("%s: %.*s", path, (int)len, buf); - - /* Current line is the continuation of the previous one. */ - if (line != NULL) { - oldlen = strlen(line); - line = xrealloc(line, 1, oldlen + len + 1); - } else { - oldlen = 0; - line = xmalloc(len + 1); - } - - /* Append current line to the previous. */ - memcpy(line + oldlen, buf, len); - line[oldlen + len] = '\0'; - n++; - - /* Continuation: get next line? */ - len = strlen(line); - if (len > 0 && line[len - 1] == '\\') { - line[len - 1] = '\0'; - - /* Ignore escaped backslash at EOL. */ - if (len > 1 && line[len - 2] != '\\') - continue; - } - copy = line; - line = NULL; + found = 0; + while ((buf = fparseln(f, NULL, &line, delim, 0))) { + log_debug("%s: %s", path, buf); /* Skip empty lines. */ - buf = copy; - while (isspace((u_char)*buf)) - buf++; - if (*buf == '\0') { - free(copy); + p = buf; + while (isspace((u_char) *p)) + p++; + if (*p == '\0') { + free(buf); continue; } /* Parse and run the command. */ - if (cmd_string_parse(buf, &cmdlist, path, n, &cause1) != 0) { - free(copy); + if (cmd_string_parse(p, &cmdlist, path, line, &cause1) != 0) { + free(buf); if (cause1 == NULL) continue; - xasprintf(&msg, "%s:%u: %s", path, n, cause1); + xasprintf(&msg, "%s:%zu: %s", path, line, cause1); ARRAY_ADD(&cfg_causes, msg); free(cause1); continue; } - free(copy); + free(buf); if (cmdlist == NULL) continue; @@ -108,8 +80,6 @@ load_cfg(const char *path, struct cmd_q *cmdq, char **cause) cmd_list_free(cmdlist); found++; } - if (line != NULL) - free(line); fclose(f); return (found); diff --git a/client.c b/client.c index 0c9f9cba..8e55640f 100644 --- a/client.c +++ b/client.c @@ -77,13 +77,18 @@ client_get_lock(char *lockfile) if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1) fatal("open failed"); + log_debug("lock file is %s", lockfile); - if (lockf(lockfd, F_TLOCK, 0) == -1 && errno == EAGAIN) { - while (lockf(lockfd, F_LOCK, 0) == -1 && errno == EINTR) + if (flock(lockfd, LOCK_EX|LOCK_NB) == -1) { + log_debug("flock failed: %s", strerror(errno)); + if (errno != EAGAIN) + return (lockfd); + while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR) /* nothing */; close(lockfd); return (-1); } + log_debug("flock succeeded"); return (lockfd); } @@ -94,8 +99,8 @@ client_connect(char *path, int start_server) { struct sockaddr_un sa; size_t size; - int fd, lockfd; - char *lockfile; + int fd, lockfd = -1, locked = 0; + char *lockfile = NULL; memset(&sa, 0, sizeof sa); sa.sun_family = AF_UNIX; @@ -104,29 +109,48 @@ client_connect(char *path, int start_server) errno = ENAMETOOLONG; return (-1); } + log_debug("socket is %s", path); retry: if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) fatal("socket failed"); + log_debug("trying connect"); if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) { + log_debug("connect failed: %s", strerror(errno)); if (errno != ECONNREFUSED && errno != ENOENT) goto failed; if (!start_server) goto failed; close(fd); - xasprintf(&lockfile, "%s.lock", path); - if ((lockfd = client_get_lock(lockfile)) == -1) { - free(lockfile); + if (!locked) { + xasprintf(&lockfile, "%s.lock", path); + if ((lockfd = client_get_lock(lockfile)) == -1) { + log_debug("didn't get lock"); + free(lockfile); + goto retry; + } + log_debug("got lock"); + + /* + * Always retry at least once, even if we got the lock, + * because another client could have taken the lock, + * started the server and released the lock between our + * connect() and flock(). + */ + locked = 1; goto retry; } + if (unlink(path) != 0 && errno != ENOENT) { free(lockfile); close(lockfd); return (-1); } fd = server_start(lockfd, lockfile); + } + if (locked) { free(lockfile); close(lockfd); } @@ -233,7 +257,7 @@ client_main(int argc, char **argv, int flags) return (1); } - /* Initialise the client socket and start the server. */ + /* Initialize the client socket and start the server. */ fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER); if (fd == -1) { fprintf(stderr, "failed to connect to server: %s\n", @@ -473,7 +497,7 @@ client_callback(unused int fd, short events, void *data) } if (events & EV_WRITE) { - if (msgbuf_write(&client_ibuf.w) < 0 && errno != EAGAIN) + if (msgbuf_write(&client_ibuf.w) <= 0 && errno != EAGAIN) goto lost_server; } diff --git a/cmd.c b/cmd.c index 3a948c80..f5165a5f 100644 --- a/cmd.c +++ b/cmd.c @@ -794,8 +794,11 @@ cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached) int ambiguous; /* A NULL argument means the current session. */ - if (arg == NULL) - return (cmd_current_session(cmdq, prefer_unattached)); + if (arg == NULL) { + if ((s = cmd_current_session(cmdq, prefer_unattached)) == NULL) + cmdq_error(cmdq, "can't establish current session"); + return (s); + } /* Lookup as pane id or window id. */ if ((wp = cmd_lookup_paneid(arg)) != NULL) @@ -812,7 +815,9 @@ cmd_find_session(struct cmd_q *cmdq, const char *arg, int prefer_unattached) /* An empty session name is the current session. */ if (*tmparg == '\0') { free(tmparg); - return (cmd_current_session(cmdq, prefer_unattached)); + if ((s = cmd_current_session(cmdq, prefer_unattached)) == NULL) + cmdq_error(cmdq, "can't establish current session"); + return (s); } /* Find the session, if any. */ diff --git a/format.c b/format.c index 5d5982ee..66795d50 100644 --- a/format.c +++ b/format.c @@ -603,8 +603,6 @@ format_window_pane(struct format_tree *ft, struct window_pane *wp) !!(wp->base.mode & MODE_MOUSE_STANDARD)); format_add(ft, "mouse_button_flag", "%d", !!(wp->base.mode & MODE_MOUSE_BUTTON)); - format_add(ft, "mouse_any_flag", "%d", - !!(wp->base.mode & MODE_MOUSE_ANY)); format_add(ft, "mouse_utf8_flag", "%d", !!(wp->base.mode & MODE_MOUSE_UTF8)); diff --git a/input-keys.c b/input-keys.c index 7531f22d..3b72c07e 100644 --- a/input-keys.c +++ b/input-keys.c @@ -56,14 +56,14 @@ const struct input_key_ent input_keys[] = { { KEYC_F10, "\033[21~", 0 }, { KEYC_F11, "\033[23~", 0 }, { KEYC_F12, "\033[24~", 0 }, - { KEYC_F13, "\033[25~", 0 }, - { KEYC_F14, "\033[26~", 0 }, - { KEYC_F15, "\033[28~", 0 }, - { KEYC_F16, "\033[29~", 0 }, - { KEYC_F17, "\033[31~", 0 }, - { KEYC_F18, "\033[32~", 0 }, - { KEYC_F19, "\033[33~", 0 }, - { KEYC_F20, "\033[34~", 0 }, + { KEYC_F1|KEYC_SHIFT, "\033[25~", 0 }, + { KEYC_F2|KEYC_SHIFT, "\033[26~", 0 }, + { KEYC_F3|KEYC_SHIFT, "\033[28~", 0 }, + { KEYC_F4|KEYC_SHIFT, "\033[29~", 0 }, + { KEYC_F5|KEYC_SHIFT, "\033[31~", 0 }, + { KEYC_F6|KEYC_SHIFT, "\033[32~", 0 }, + { KEYC_F7|KEYC_SHIFT, "\033[33~", 0 }, + { KEYC_F8|KEYC_SHIFT, "\033[34~", 0 }, { KEYC_IC, "\033[2~", 0 }, { KEYC_DC, "\033[3~", 0 }, { KEYC_HOME, "\033[1~", 0 }, @@ -204,21 +204,6 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m) char buf[40]; size_t len; struct paste_buffer *pb; - u_int i; - - /* - * If the alternate screen is active and hasn't enabled the mouse, send - * up and down key presses for the mouse wheel. - */ - if (wp->saved_grid != NULL && !(wp->screen->mode & ALL_MOUSE_MODES)) { - for (i = 0; i < m->scroll; i++) { - if (m->wheel == MOUSE_WHEEL_UP) - input_key(wp, KEYC_UP); - else - input_key(wp, KEYC_DOWN); - } - return; - } if (wp->screen->mode & ALL_MOUSE_MODES) { /* diff --git a/input.c b/input.c index dc061695..06e940aa 100644 --- a/input.c +++ b/input.c @@ -1374,7 +1374,6 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx) case 1000: case 1001: case 1002: - case 1003: screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES); break; case 1004: @@ -1451,10 +1450,6 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx) screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES); screen_write_mode_set(&ictx->ctx, MODE_MOUSE_BUTTON); break; - case 1003: - screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES); - screen_write_mode_set(&ictx->ctx, MODE_MOUSE_ANY); - break; case 1004: if (ictx->ctx.s->mode & MODE_FOCUSON) break; diff --git a/key-string.c b/key-string.c index 797eedd5..daf0783e 100644 --- a/key-string.c +++ b/key-string.c @@ -42,14 +42,6 @@ const struct { { "F10", KEYC_F10 }, { "F11", KEYC_F11 }, { "F12", KEYC_F12 }, - { "F13", KEYC_F13 }, - { "F14", KEYC_F14 }, - { "F15", KEYC_F15 }, - { "F16", KEYC_F16 }, - { "F17", KEYC_F17 }, - { "F18", KEYC_F18 }, - { "F19", KEYC_F19 }, - { "F20", KEYC_F20 }, { "IC", KEYC_IC }, { "DC", KEYC_DC }, { "Home", KEYC_HOME }, diff --git a/osdep-openbsd.c b/osdep-openbsd.c index 9d88fb04..9e4df91d 100644 --- a/osdep-openbsd.c +++ b/osdep-openbsd.c @@ -34,7 +34,7 @@ #define is_runnable(p) \ ((p)->p_stat == SRUN || (p)->p_stat == SIDL || (p)->p_stat == SONPROC) #define is_stopped(p) \ - ((p)->p_stat == SSTOP || (p)->p_stat == SZOMB || (p)->p_stat == SDEAD) + ((p)->p_stat == SSTOP || (p)->p_stat == SDEAD) struct kinfo_proc *cmp_procs(struct kinfo_proc *, struct kinfo_proc *); char *osdep_get_name(int, char *); diff --git a/paste.c b/paste.c index 0ff5958c..b05cf025 100644 --- a/paste.c +++ b/paste.c @@ -68,7 +68,7 @@ paste_walk(struct paste_buffer *pb) return (RB_NEXT(paste_time_tree, &paste_by_time, pb)); } -/* Get the most recent automatic buffer */ +/* Get the most recent automatic buffer. */ struct paste_buffer * paste_get_top(void) { @@ -80,7 +80,7 @@ paste_get_top(void) return (pb); } -/* Free the most recent buffer */ +/* Free the most recent buffer. */ int paste_free_top(void) { diff --git a/server-client.c b/server-client.c index e225de30..6d5d0833 100644 --- a/server-client.c +++ b/server-client.c @@ -223,7 +223,7 @@ server_client_callback(int fd, short events, void *data) return; if (fd == c->ibuf.fd) { - if (events & EV_WRITE && msgbuf_write(&c->ibuf.w) < 0 && + if (events & EV_WRITE && msgbuf_write(&c->ibuf.w) <= 0 && errno != EAGAIN) goto client_lost; @@ -656,7 +656,7 @@ server_client_reset_state(struct client *c) */ mode = s->mode; if ((c->tty.mouse.flags & MOUSE_RESIZE_PANE) && - !(mode & (MODE_MOUSE_BUTTON|MODE_MOUSE_ANY))) + !(mode & MODE_MOUSE_BUTTON)) mode |= MODE_MOUSE_BUTTON; /* @@ -884,6 +884,9 @@ server_client_msg_dispatch(struct client *c) break; c->flags &= ~CLIENT_SUSPENDED; + if (c->tty.fd == -1) /* exited in the meantime */ + break; + if (gettimeofday(&c->activity_time, NULL) != 0) fatal("gettimeofday"); if (c->session != NULL) diff --git a/server.c b/server.c index 5ae44df2..6cded12a 100644 --- a/server.c +++ b/server.c @@ -110,6 +110,7 @@ server_start(int lockfd, char *lockfile) /* The first client is special and gets a socketpair; create it. */ if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pair) != 0) fatal("socketpair failed"); + log_debug("starting server"); switch (fork()) { case -1: diff --git a/tmux.h b/tmux.h index c4c52360..ef1943a1 100644 --- a/tmux.h +++ b/tmux.h @@ -192,14 +192,6 @@ enum key_code { KEYC_F10, KEYC_F11, KEYC_F12, - KEYC_F13, - KEYC_F14, - KEYC_F15, - KEYC_F16, - KEYC_F17, - KEYC_F18, - KEYC_F19, - KEYC_F20, KEYC_IC, KEYC_DC, KEYC_HOME, @@ -305,26 +297,69 @@ enum tty_code_code { TTYC_KEND5, TTYC_KEND6, TTYC_KEND7, - TTYC_KF1, /* key_f1, k1 */ - TTYC_KF10, /* key_f10, k; */ - TTYC_KF11, /* key_f11, F1 */ - TTYC_KF12, /* key_f12, F2 */ - TTYC_KF13, /* key_f13, F3 */ - TTYC_KF14, /* key_f14, F4 */ - TTYC_KF15, /* key_f15, F5 */ - TTYC_KF16, /* key_f16, F6 */ - TTYC_KF17, /* key_f17, F7 */ - TTYC_KF18, /* key_f18, F8 */ - TTYC_KF19, /* key_f19, F9 */ - TTYC_KF2, /* key_f2, k2 */ - TTYC_KF20, /* key_f20, F10 */ - TTYC_KF3, /* key_f3, k3 */ - TTYC_KF4, /* key_f4, k4 */ - TTYC_KF5, /* key_f5, k5 */ - TTYC_KF6, /* key_f6, k6 */ - TTYC_KF7, /* key_f7, k7 */ - TTYC_KF8, /* key_f8, k8 */ - TTYC_KF9, /* key_f9, k9 */ + TTYC_KF1, + TTYC_KF10, + TTYC_KF11, + TTYC_KF12, + TTYC_KF13, + TTYC_KF14, + TTYC_KF15, + TTYC_KF16, + TTYC_KF17, + TTYC_KF18, + TTYC_KF19, + TTYC_KF2, + TTYC_KF20, + TTYC_KF21, + TTYC_KF22, + TTYC_KF23, + TTYC_KF24, + TTYC_KF25, + TTYC_KF26, + TTYC_KF27, + TTYC_KF28, + TTYC_KF29, + TTYC_KF3, + TTYC_KF30, + TTYC_KF31, + TTYC_KF32, + TTYC_KF33, + TTYC_KF34, + TTYC_KF35, + TTYC_KF36, + TTYC_KF37, + TTYC_KF38, + TTYC_KF39, + TTYC_KF4, + TTYC_KF40, + TTYC_KF41, + TTYC_KF42, + TTYC_KF43, + TTYC_KF44, + TTYC_KF45, + TTYC_KF46, + TTYC_KF47, + TTYC_KF48, + TTYC_KF49, + TTYC_KF5, + TTYC_KF50, + TTYC_KF51, + TTYC_KF52, + TTYC_KF53, + TTYC_KF54, + TTYC_KF55, + TTYC_KF56, + TTYC_KF57, + TTYC_KF58, + TTYC_KF59, + TTYC_KF6, + TTYC_KF60, + TTYC_KF61, + TTYC_KF62, + TTYC_KF63, + TTYC_KF7, + TTYC_KF8, + TTYC_KF9, TTYC_KHOM2, TTYC_KHOM3, TTYC_KHOM4, @@ -644,13 +679,13 @@ struct mode_key_table { #define MODE_WRAP 0x10 /* whether lines wrap */ #define MODE_MOUSE_STANDARD 0x20 #define MODE_MOUSE_BUTTON 0x40 -#define MODE_MOUSE_ANY 0x80 +/* 0x80 unused */ #define MODE_MOUSE_UTF8 0x100 #define MODE_MOUSE_SGR 0x200 #define MODE_BRACKETPASTE 0x400 #define MODE_FOCUSON 0x800 -#define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ANY) +#define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON) /* A single UTF-8 character. */ struct utf8_data { diff --git a/tty-keys.c b/tty-keys.c index 97b49a20..557ecd55 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -113,14 +113,6 @@ const struct tty_default_key_raw tty_default_raw_keys[] = { { "\033[21^", KEYC_F10|KEYC_CTRL }, { "\033[23^", KEYC_F11|KEYC_CTRL }, { "\033[24^", KEYC_F12|KEYC_CTRL }, - { "\033[25^", KEYC_F13|KEYC_CTRL }, - { "\033[26^", KEYC_F14|KEYC_CTRL }, - { "\033[28^", KEYC_F15|KEYC_CTRL }, - { "\033[29^", KEYC_F16|KEYC_CTRL }, - { "\033[31^", KEYC_F17|KEYC_CTRL }, - { "\033[32^", KEYC_F18|KEYC_CTRL }, - { "\033[33^", KEYC_F19|KEYC_CTRL }, - { "\033[34^", KEYC_F20|KEYC_CTRL }, { "\033[2^", KEYC_IC|KEYC_CTRL }, { "\033[3^", KEYC_DC|KEYC_CTRL }, { "\033[7^", KEYC_HOME|KEYC_CTRL }, @@ -140,14 +132,6 @@ const struct tty_default_key_raw tty_default_raw_keys[] = { { "\033[21$", KEYC_F10|KEYC_SHIFT }, { "\033[23$", KEYC_F11|KEYC_SHIFT }, { "\033[24$", KEYC_F12|KEYC_SHIFT }, - { "\033[25$", KEYC_F13|KEYC_SHIFT }, - { "\033[26$", KEYC_F14|KEYC_SHIFT }, - { "\033[28$", KEYC_F15|KEYC_SHIFT }, - { "\033[29$", KEYC_F16|KEYC_SHIFT }, - { "\033[31$", KEYC_F17|KEYC_SHIFT }, - { "\033[32$", KEYC_F18|KEYC_SHIFT }, - { "\033[33$", KEYC_F19|KEYC_SHIFT }, - { "\033[34$", KEYC_F20|KEYC_SHIFT }, { "\033[2$", KEYC_IC|KEYC_SHIFT }, { "\033[3$", KEYC_DC|KEYC_SHIFT }, { "\033[7$", KEYC_HOME|KEYC_SHIFT }, @@ -167,14 +151,6 @@ const struct tty_default_key_raw tty_default_raw_keys[] = { { "\033[21@", KEYC_F10|KEYC_CTRL|KEYC_SHIFT }, { "\033[23@", KEYC_F11|KEYC_CTRL|KEYC_SHIFT }, { "\033[24@", KEYC_F12|KEYC_CTRL|KEYC_SHIFT }, - { "\033[25@", KEYC_F13|KEYC_CTRL|KEYC_SHIFT }, - { "\033[26@", KEYC_F14|KEYC_CTRL|KEYC_SHIFT }, - { "\033[28@", KEYC_F15|KEYC_CTRL|KEYC_SHIFT }, - { "\033[29@", KEYC_F16|KEYC_CTRL|KEYC_SHIFT }, - { "\033[31@", KEYC_F17|KEYC_CTRL|KEYC_SHIFT }, - { "\033[32@", KEYC_F18|KEYC_CTRL|KEYC_SHIFT }, - { "\033[33@", KEYC_F19|KEYC_CTRL|KEYC_SHIFT }, - { "\033[34@", KEYC_F20|KEYC_CTRL|KEYC_SHIFT }, { "\033[2@", KEYC_IC|KEYC_CTRL|KEYC_SHIFT }, { "\033[3@", KEYC_DC|KEYC_CTRL|KEYC_SHIFT }, { "\033[7@", KEYC_HOME|KEYC_CTRL|KEYC_SHIFT }, @@ -206,14 +182,63 @@ const struct tty_default_key_code tty_default_code_keys[] = { { TTYC_KF10, KEYC_F10 }, { TTYC_KF11, KEYC_F11 }, { TTYC_KF12, KEYC_F12 }, - { TTYC_KF13, KEYC_F13 }, - { TTYC_KF14, KEYC_F14 }, - { TTYC_KF15, KEYC_F15 }, - { TTYC_KF16, KEYC_F16 }, - { TTYC_KF17, KEYC_F17 }, - { TTYC_KF18, KEYC_F18 }, - { TTYC_KF19, KEYC_F19 }, - { TTYC_KF20, KEYC_F20 }, + + { TTYC_KF13, KEYC_F1|KEYC_SHIFT }, + { TTYC_KF14, KEYC_F2|KEYC_SHIFT }, + { TTYC_KF15, KEYC_F3|KEYC_SHIFT }, + { TTYC_KF16, KEYC_F4|KEYC_SHIFT }, + { TTYC_KF17, KEYC_F5|KEYC_SHIFT }, + { TTYC_KF18, KEYC_F6|KEYC_SHIFT }, + { TTYC_KF19, KEYC_F7|KEYC_SHIFT }, + { TTYC_KF20, KEYC_F8|KEYC_SHIFT }, + { TTYC_KF21, KEYC_F9|KEYC_SHIFT }, + { TTYC_KF22, KEYC_F10|KEYC_SHIFT }, + { TTYC_KF23, KEYC_F11|KEYC_SHIFT }, + { TTYC_KF24, KEYC_F12|KEYC_SHIFT }, + + { TTYC_KF25, KEYC_F1|KEYC_CTRL }, + { TTYC_KF26, KEYC_F2|KEYC_CTRL }, + { TTYC_KF27, KEYC_F3|KEYC_CTRL }, + { TTYC_KF28, KEYC_F4|KEYC_CTRL }, + { TTYC_KF29, KEYC_F5|KEYC_CTRL }, + { TTYC_KF30, KEYC_F6|KEYC_CTRL }, + { TTYC_KF31, KEYC_F7|KEYC_CTRL }, + { TTYC_KF32, KEYC_F8|KEYC_CTRL }, + { TTYC_KF33, KEYC_F9|KEYC_CTRL }, + { TTYC_KF34, KEYC_F10|KEYC_CTRL }, + { TTYC_KF35, KEYC_F11|KEYC_CTRL }, + { TTYC_KF36, KEYC_F12|KEYC_CTRL }, + + { TTYC_KF37, KEYC_F1|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF38, KEYC_F2|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF39, KEYC_F3|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF40, KEYC_F4|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF41, KEYC_F5|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF42, KEYC_F6|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF43, KEYC_F7|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF44, KEYC_F8|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF45, KEYC_F9|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF46, KEYC_F10|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF47, KEYC_F11|KEYC_SHIFT|KEYC_CTRL }, + { TTYC_KF48, KEYC_F12|KEYC_SHIFT|KEYC_CTRL }, + + { TTYC_KF49, KEYC_F1|KEYC_ESCAPE }, + { TTYC_KF50, KEYC_F2|KEYC_ESCAPE }, + { TTYC_KF51, KEYC_F3|KEYC_ESCAPE }, + { TTYC_KF52, KEYC_F4|KEYC_ESCAPE }, + { TTYC_KF53, KEYC_F5|KEYC_ESCAPE }, + { TTYC_KF54, KEYC_F6|KEYC_ESCAPE }, + { TTYC_KF55, KEYC_F7|KEYC_ESCAPE }, + { TTYC_KF56, KEYC_F8|KEYC_ESCAPE }, + { TTYC_KF57, KEYC_F9|KEYC_ESCAPE }, + { TTYC_KF58, KEYC_F10|KEYC_ESCAPE }, + { TTYC_KF59, KEYC_F11|KEYC_ESCAPE }, + { TTYC_KF60, KEYC_F12|KEYC_ESCAPE }, + + { TTYC_KF61, KEYC_F1|KEYC_ESCAPE|KEYC_SHIFT }, + { TTYC_KF62, KEYC_F2|KEYC_ESCAPE|KEYC_SHIFT }, + { TTYC_KF63, KEYC_F3|KEYC_ESCAPE|KEYC_SHIFT }, + { TTYC_KICH1, KEYC_IC }, { TTYC_KDCH1, KEYC_DC }, { TTYC_KHOME, KEYC_HOME }, @@ -786,25 +811,24 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) m->button = 3; } else if ((b & MOUSE_MASK_BUTTONS) == 3) { - if (~m->event & MOUSE_EVENT_DRAG && x == m->x && y == m->y) + if (~m->event & MOUSE_EVENT_DRAG && x == m->sx && y == m->sy) { m->event = MOUSE_EVENT_CLICK; - else + m->clicks = (m->clicks + 1) % 3; + } else m->event = MOUSE_EVENT_DRAG; m->event |= MOUSE_EVENT_UP; } else { if (b & MOUSE_MASK_DRAG) m->event = MOUSE_EVENT_DRAG; else { - if (m->event & MOUSE_EVENT_UP && x == m->x && y == m->y) - m->clicks = (m->clicks + 1) % 3; - else - m->clicks = 0; - m->sx = x; - m->sy = y; m->event = MOUSE_EVENT_DOWN; + if (x != m->sx || y != m->sy) + m->clicks = 0; } m->button = (b & MOUSE_MASK_BUTTONS); } + m->sx = x; + m->sy = y; return (0); } diff --git a/tty-term.c b/tty-term.c index 8e500f2f..013cac1b 100644 --- a/tty-term.c +++ b/tty-term.c @@ -116,10 +116,53 @@ const struct tty_term_code_entry tty_term_codes[NTTYCODE] = { { TTYC_KF19, TTYCODE_STRING, "kf19" }, { TTYC_KF2, TTYCODE_STRING, "kf2" }, { TTYC_KF20, TTYCODE_STRING, "kf20" }, + { TTYC_KF21, TTYCODE_STRING, "kf21" }, + { TTYC_KF22, TTYCODE_STRING, "kf22" }, + { TTYC_KF23, TTYCODE_STRING, "kf23" }, + { TTYC_KF24, TTYCODE_STRING, "kf24" }, + { TTYC_KF25, TTYCODE_STRING, "kf25" }, + { TTYC_KF26, TTYCODE_STRING, "kf26" }, + { TTYC_KF27, TTYCODE_STRING, "kf27" }, + { TTYC_KF28, TTYCODE_STRING, "kf28" }, + { TTYC_KF29, TTYCODE_STRING, "kf29" }, { TTYC_KF3, TTYCODE_STRING, "kf3" }, + { TTYC_KF30, TTYCODE_STRING, "kf30" }, + { TTYC_KF31, TTYCODE_STRING, "kf31" }, + { TTYC_KF32, TTYCODE_STRING, "kf32" }, + { TTYC_KF33, TTYCODE_STRING, "kf33" }, + { TTYC_KF34, TTYCODE_STRING, "kf34" }, + { TTYC_KF35, TTYCODE_STRING, "kf35" }, + { TTYC_KF36, TTYCODE_STRING, "kf36" }, + { TTYC_KF37, TTYCODE_STRING, "kf37" }, + { TTYC_KF38, TTYCODE_STRING, "kf38" }, + { TTYC_KF39, TTYCODE_STRING, "kf39" }, { TTYC_KF4, TTYCODE_STRING, "kf4" }, + { TTYC_KF40, TTYCODE_STRING, "kf40" }, + { TTYC_KF41, TTYCODE_STRING, "kf41" }, + { TTYC_KF42, TTYCODE_STRING, "kf42" }, + { TTYC_KF43, TTYCODE_STRING, "kf43" }, + { TTYC_KF44, TTYCODE_STRING, "kf44" }, + { TTYC_KF45, TTYCODE_STRING, "kf45" }, + { TTYC_KF46, TTYCODE_STRING, "kf46" }, + { TTYC_KF47, TTYCODE_STRING, "kf47" }, + { TTYC_KF48, TTYCODE_STRING, "kf48" }, + { TTYC_KF49, TTYCODE_STRING, "kf49" }, { TTYC_KF5, TTYCODE_STRING, "kf5" }, + { TTYC_KF50, TTYCODE_STRING, "kf50" }, + { TTYC_KF51, TTYCODE_STRING, "kf51" }, + { TTYC_KF52, TTYCODE_STRING, "kf52" }, + { TTYC_KF53, TTYCODE_STRING, "kf53" }, + { TTYC_KF54, TTYCODE_STRING, "kf54" }, + { TTYC_KF55, TTYCODE_STRING, "kf55" }, + { TTYC_KF56, TTYCODE_STRING, "kf56" }, + { TTYC_KF57, TTYCODE_STRING, "kf57" }, + { TTYC_KF58, TTYCODE_STRING, "kf58" }, + { TTYC_KF59, TTYCODE_STRING, "kf59" }, { TTYC_KF6, TTYCODE_STRING, "kf6" }, + { TTYC_KF60, TTYCODE_STRING, "kf60" }, + { TTYC_KF61, TTYCODE_STRING, "kf61" }, + { TTYC_KF62, TTYCODE_STRING, "kf62" }, + { TTYC_KF63, TTYCODE_STRING, "kf63" }, { TTYC_KF7, TTYCODE_STRING, "kf7" }, { TTYC_KF8, TTYCODE_STRING, "kf8" }, { TTYC_KF9, TTYCODE_STRING, "kf9" }, diff --git a/tty.c b/tty.c index 7688e90b..e4bd2576 100644 --- a/tty.c +++ b/tty.c @@ -513,16 +513,12 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s) tty_puts(tty, "\033[?1005l"); tty_puts(tty, "\033[?1006h"); - if (mode & MODE_MOUSE_ANY) - tty_puts(tty, "\033[?1003h"); - else if (mode & MODE_MOUSE_BUTTON) + if (mode & MODE_MOUSE_BUTTON) tty_puts(tty, "\033[?1002h"); else if (mode & MODE_MOUSE_STANDARD) tty_puts(tty, "\033[?1000h"); } else { - if (tty->mode & MODE_MOUSE_ANY) - tty_puts(tty, "\033[?1003l"); - else if (tty->mode & MODE_MOUSE_BUTTON) + if (tty->mode & MODE_MOUSE_BUTTON) tty_puts(tty, "\033[?1002l"); else if (tty->mode & MODE_MOUSE_STANDARD) tty_puts(tty, "\033[?1000l"); diff --git a/window.c b/window.c index 5b93f935..e9ec7eaf 100644 --- a/window.c +++ b/window.c @@ -1065,9 +1065,6 @@ window_pane_key(struct window_pane *wp, struct session *sess, int key) { struct window_pane *wp2; - if (!window_pane_visible(wp)) - return; - if (wp->mode != NULL) { if (wp->mode->key != NULL) wp->mode->key(wp, sess, key); diff --git a/xterm-keys.c b/xterm-keys.c index 4032ba1d..b0b8a37d 100644 --- a/xterm-keys.c +++ b/xterm-keys.c @@ -69,14 +69,6 @@ const struct xterm_keys_entry xterm_keys_table[] = { { KEYC_F10, "\033[21;_~" }, { KEYC_F11, "\033[23;_~" }, { KEYC_F12, "\033[24;_~" }, - { KEYC_F13, "\033[25;_~" }, - { KEYC_F14, "\033[26;_~" }, - { KEYC_F15, "\033[28;_~" }, - { KEYC_F16, "\033[29;_~" }, - { KEYC_F17, "\033[31;_~" }, - { KEYC_F18, "\033[32;_~" }, - { KEYC_F19, "\033[33;_~" }, - { KEYC_F20, "\033[34;_~" }, { KEYC_UP, "\033[1;_A" }, { KEYC_DOWN, "\033[1;_B" }, { KEYC_RIGHT, "\033[1;_C" },