Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/tmux merge our changes between tmux-3.1c and tm...



details:   https://anonhg.NetBSD.org/src/rev/a1678ff21bf2
branches:  trunk
changeset: 961757:a1678ff21bf2
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 17 20:42:09 2021 +0000

description:
merge our changes between tmux-3.1c and tmux-3.2

diffstat:

 external/bsd/tmux/dist/client.c              |   482 +--
 external/bsd/tmux/dist/cmd-attach-session.c  |    37 +-
 external/bsd/tmux/dist/cmd-capture-pane.c    |    31 +-
 external/bsd/tmux/dist/cmd-display-menu.c    |     2 +-
 external/bsd/tmux/dist/cmd-display-message.c |    56 +-
 external/bsd/tmux/dist/cmd-if-shell.c        |    77 +-
 external/bsd/tmux/dist/cmd-load-buffer.c     |    34 +-
 external/bsd/tmux/dist/cmd-new-session.c     |   102 +-
 external/bsd/tmux/dist/cmd-new-window.c      |    67 +-
 external/bsd/tmux/dist/cmd-parse.y           |   359 +-
 external/bsd/tmux/dist/cmd-paste-buffer.c    |     5 +-
 external/bsd/tmux/dist/cmd-queue.c           |   508 ++-
 external/bsd/tmux/dist/cmd-resize-window.c   |     7 +-
 external/bsd/tmux/dist/cmd-send-keys.c       |    90 +-
 external/bsd/tmux/dist/cmd-show-messages.c   |    45 +-
 external/bsd/tmux/dist/cmd-show-options.c    |    63 +-
 external/bsd/tmux/dist/cmd-split-window.c    |    27 +-
 external/bsd/tmux/dist/cmd-wait-for.c        |     6 +-
 external/bsd/tmux/dist/colour.c              |   617 ++++-
 external/bsd/tmux/dist/compat.h              |    58 +
 external/bsd/tmux/dist/compat/imsg-buffer.c  |     4 +-
 external/bsd/tmux/dist/control.c             |     4 +-
 external/bsd/tmux/dist/environ.c             |    38 +-
 external/bsd/tmux/dist/format.c              |  3908 ++++++++++++++++++++-----
 external/bsd/tmux/dist/grid.c                |   181 +-
 external/bsd/tmux/dist/input-keys.c          |   701 +++-
 external/bsd/tmux/dist/input.c               |   463 +-
 external/bsd/tmux/dist/job.c                 |   151 +-
 external/bsd/tmux/dist/key-bindings.c        |   261 +-
 external/bsd/tmux/dist/log.c                 |    21 +-
 external/bsd/tmux/dist/menu.c                |   162 +-
 external/bsd/tmux/dist/mode-tree.c           |   279 +-
 external/bsd/tmux/dist/notify.c              |    76 +-
 external/bsd/tmux/dist/options.c             |   424 ++-
 external/bsd/tmux/dist/paste.c               |    11 +-
 external/bsd/tmux/dist/proc.c                |    67 +-
 external/bsd/tmux/dist/regsub.c              |     3 +-
 external/bsd/tmux/dist/resize.c              |   420 +-
 external/bsd/tmux/dist/screen-write.c        |   861 ++++-
 external/bsd/tmux/dist/screen.c              |   199 +-
 external/bsd/tmux/dist/server-client.c       |  1082 ++++--
 external/bsd/tmux/dist/server-fn.c           |   100 +-
 external/bsd/tmux/dist/server.c              |     2 +-
 external/bsd/tmux/dist/session.c             |    18 +-
 external/bsd/tmux/dist/spawn.c               |    64 +-
 external/bsd/tmux/dist/status.c              |   725 +++-
 external/bsd/tmux/dist/style.c               |    80 +-
 external/bsd/tmux/dist/tmux.1                |  1166 ++++++-
 external/bsd/tmux/dist/tmux.c                |   224 +-
 external/bsd/tmux/dist/tmux.h                |   890 ++++-
 external/bsd/tmux/dist/tty-acs.c             |    87 +-
 external/bsd/tmux/dist/tty-keys.c            |   668 +++-
 external/bsd/tmux/dist/tty-term.c            |   403 +-
 external/bsd/tmux/dist/tty.c                 |  1098 +++---
 external/bsd/tmux/dist/utf8.c                |   351 +-
 external/bsd/tmux/dist/window-buffer.c       |   163 +-
 external/bsd/tmux/dist/window-client.c       |    60 +-
 external/bsd/tmux/dist/window-copy.c         |  2014 ++++++++----
 external/bsd/tmux/dist/window-customize.c    |     4 +-
 external/bsd/tmux/dist/window-tree.c         |   111 +-
 external/bsd/tmux/dist/window.c              |   315 +-
 external/bsd/tmux/dist/xterm-keys.c          |   252 -
 external/bsd/tmux/usr.bin/tmux/Makefile      |    27 +-
 63 files changed, 14406 insertions(+), 6405 deletions(-)

diffs (truncated from 33313 to 300 lines):

diff -r 85508799e51f -r a1678ff21bf2 external/bsd/tmux/dist/client.c
--- a/external/bsd/tmux/dist/client.c   Sat Apr 17 20:36:17 2021 +0000
+++ b/external/bsd/tmux/dist/client.c   Sat Apr 17 20:42:09 2021 +0000
@@ -18,12 +18,12 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/uio.h>
 #include <sys/un.h>
 #include <sys/wait.h>
 #include <sys/file.h>
 
 #include <errno.h>
-#include <event.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -34,7 +34,8 @@
 
 static struct tmuxproc *client_proc;
 static struct tmuxpeer *client_peer;
-static int              client_flags;
+static uint64_t                 client_flags;
+static int              client_suspended;
 static enum {
        CLIENT_EXIT_NONE,
        CLIENT_EXIT_DETACHED,
@@ -44,11 +45,13 @@
        CLIENT_EXIT_LOST_SERVER,
        CLIENT_EXIT_EXITED,
        CLIENT_EXIT_SERVER_EXITED,
+       CLIENT_EXIT_MESSAGE_PROVIDED
 } client_exitreason = CLIENT_EXIT_NONE;
 static int              client_exitflag;
 static int              client_exitval;
 static enum msgtype     client_exittype;
 static const char      *client_exitsession;
+static char            *client_exitmessage;
 static const char      *client_execshell;
 static const char      *client_execcmd;
 static int              client_attached;
@@ -56,8 +59,10 @@
 
 static __dead void      client_exec(const char *,const char *);
 static int              client_get_lock(char *);
-static int              client_connect(struct event_base *, const char *, int);
-static void             client_send_identify(const char *, const char *);
+static int              client_connect(struct event_base *, const char *,
+                            uint64_t);
+static void             client_send_identify(const char *, const char *,
+                            char **, u_int, const char *, int);
 static void             client_signal(int);
 static void             client_dispatch(struct imsg *, void *);
 static void             client_dispatch_attached(struct imsg *);
@@ -97,7 +102,7 @@
 
 /* Connect client to server. */
 static int
-client_connect(struct event_base *base, const char *path, int start_server)
+client_connect(struct event_base *base, const char *path, uint64_t flags)
 {
        struct sockaddr_un      sa;
        size_t                  size;
@@ -122,7 +127,9 @@
                log_debug("connect failed: %s", strerror(errno));
                if (errno != ECONNREFUSED && errno != ENOENT)
                        goto failed;
-               if (!start_server)
+               if (flags & CLIENT_NOSTARTSERVER)
+                       goto failed;
+               if (~flags & CLIENT_STARTSERVER)
                        goto failed;
                close(fd);
 
@@ -154,7 +161,7 @@
                        close(lockfd);
                        return (-1);
                }
-               fd = server_start(client_proc, base, lockfd, lockfile);
+               fd = server_start(client_proc, flags, base, lockfd, lockfile);
        }
 
        if (locked && lockfd >= 0) {
@@ -206,6 +213,8 @@
                return ("exited");
        case CLIENT_EXIT_SERVER_EXITED:
                return ("server exited");
+       case CLIENT_EXIT_MESSAGE_PROVIDED:
+               return (client_exitmessage);
        }
        return ("unknown reason");
 }
@@ -214,51 +223,37 @@
 static void
 client_exit(void)
 {
-       struct client_file      *cf;
-       size_t                   left;
-       int                      waiting = 0;
-
-       RB_FOREACH (cf, client_files, &client_files) {
-               if (cf->event == NULL)
-                       continue;
-               left = EVBUFFER_LENGTH(cf->event->output);
-               if (left != 0) {
-                       waiting++;
-                       log_debug("file %u %zu bytes left", cf->stream, left);
-               }
-       }
-       if (waiting == 0)
+       if (!file_write_left(&client_files))
                proc_exit(client_proc);
 }
 
 /* Client main loop. */
 int
-client_main(struct event_base *base, int argc, char **argv, int flags)
+client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
+    int feat)
 {
        struct cmd_parse_result *pr;
-       struct cmd              *cmd;
        struct msg_command      *data;
-       int                      cmdflags, fd, i;
-       const char              *ttynam, *cwd;
+       int                      fd, i;
+       const char              *ttynam, *termname, *cwd;
        pid_t                    ppid;
        enum msgtype             msg;
        struct termios           tio, saved_tio;
-       size_t                   size;
+       size_t                   size, linesize = 0;
+       ssize_t                  linelen;
+       char                    *line = NULL, **caps = NULL, *cause;
+       u_int                    ncaps = 0;
 
        /* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */
        signal(SIGCHLD, SIG_IGN);
 
-       /* Save the flags. */
-       client_flags = flags;
-
        /* Set up the initial command. */
-       cmdflags = 0;
        if (shell_command != NULL) {
                msg = MSG_SHELL;
-               cmdflags = CMD_STARTSERVER;
+               flags |= CLIENT_STARTSERVER;
        } else if (argc == 0) {
                msg = MSG_COMMAND;
-               cmdflags = CMD_STARTSERVER;
+               flags |= CLIENT_STARTSERVER;
        } else {
                msg = MSG_COMMAND;
 
@@ -269,10 +264,8 @@
                 */
                pr = cmd_parse_from_arguments(argc, argv, NULL);
                if (pr->status == CMD_PARSE_SUCCESS) {
-                       TAILQ_FOREACH(cmd, &pr->cmdlist->list, qentry) {
-                               if (cmd->entry->flags & CMD_STARTSERVER)
-                                       cmdflags |= CMD_STARTSERVER;
-                       }
+                       if (cmd_list_any_have(pr->cmdlist, CMD_STARTSERVER))
+                               flags |= CLIENT_STARTSERVER;
                        cmd_list_free(pr->cmdlist);
                } else
                        free(pr->error);
@@ -282,8 +275,12 @@
        client_proc = proc_start("client");
        proc_set_signals(client_proc, client_signal);
 
+       /* Save the flags. */
+       client_flags = flags;
+       log_debug("flags are %#llx", (unsigned long long)client_flags);
+
        /* Initialize the client socket and start the server. */
-       fd = client_connect(base, socket_path, cmdflags & CMD_STARTSERVER);
+       fd = client_connect(base, socket_path, client_flags);
        if (fd == -1) {
                if (errno == ECONNREFUSED) {
                        fprintf(stderr, "no server running on %s\n",
@@ -301,6 +298,8 @@
                cwd = "/";
        if ((ttynam = ttyname(STDIN_FILENO)) == NULL)
                ttynam = "";
+       if ((termname = getenv("TERM")) == NULL)
+               termname = "";
 
        /*
         * Drop privileges for client. "proc exec" is needed for -c and for
@@ -316,6 +315,16 @@
            NULL) != 0)
                fatal("pledge failed");
 
+       /* Load terminfo entry if any. */
+       if (isatty(STDIN_FILENO) &&
+           *termname != '\0' &&
+           tty_term_read_list(termname, STDIN_FILENO, &caps, &ncaps,
+           &cause) != 0) {
+               fprintf(stderr, "%s\n", cause);
+               free(cause);
+               return (1);
+       }
+
        /* Free stuff that is not used in the client. */
        if (ptm_fd != -1)
                close(ptm_fd);
@@ -346,7 +355,8 @@
        }
 
        /* Send identify messages. */
-       client_send_identify(ttynam, cwd);
+       client_send_identify(ttynam, termname, caps, ncaps, cwd, feat);
+       tty_term_free_list(caps, ncaps);
 
        /* Send first command. */
        if (msg == MSG_COMMAND) {
@@ -389,6 +399,11 @@
                client_exec(client_execshell, client_execcmd);
        }
 
+       /* Restore streams to blocking. */
+       setblocking(STDIN_FILENO, 1);
+       setblocking(STDOUT_FILENO, 1);
+       setblocking(STDERR_FILENO, 1);
+
        /* Print the exit message, if any, and exit. */
        if (client_attached) {
                if (client_exitreason != CLIENT_EXIT_NONE)
@@ -397,42 +412,65 @@
                ppid = getppid();
                if (client_exittype == MSG_DETACHKILL && ppid > 1)
                        kill(ppid, SIGHUP);
-       } else if (client_flags & CLIENT_CONTROLCONTROL) {
+       } else if (client_flags & CLIENT_CONTROL) {
                if (client_exitreason != CLIENT_EXIT_NONE)
                        printf("%%exit %s\n", client_exit_message());
                else
                        printf("%%exit\n");
-               printf("\033\\");
-               tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
+               fflush(stdout);
+               if (client_flags & CLIENT_CONTROL_WAITEXIT) {
+                       setvbuf(stdin, NULL, _IOLBF, 0);
+                       for (;;) {
+                               linelen = getline(&line, &linesize, stdin);
+                               if (linelen <= 1)
+                                       break;
+                       }
+                       free(line);
+               }
+               if (client_flags & CLIENT_CONTROLCONTROL) {
+                       printf("\033\\");
+                       fflush(stdout);
+                       tcsetattr(STDOUT_FILENO, TCSAFLUSH, &saved_tio);
+               }
        } else if (client_exitreason != CLIENT_EXIT_NONE)
                fprintf(stderr, "%s\n", client_exit_message());
-       setblocking(STDIN_FILENO, 1);
        return (client_exitval);
 }
 
 /* Send identify messages to server. */
 static void
-client_send_identify(const char *ttynam, const char *cwd)
+client_send_identify(const char *ttynam, const char *termname, char **caps,
+    u_int ncaps, const char *cwd, int feat)
 {
-       const char       *s;
-       char            **ss;
-       size_t            sslen;
-       int               fd, flags = client_flags;
-       pid_t             pid;
+       char    **ss;
+       size_t    sslen;
+       int       fd, flags = client_flags;
+       pid_t     pid;
+       u_int     i;
 
        proc_send(client_peer, MSG_IDENTIFY_FLAGS, -1, &flags, sizeof flags);
+       proc_send(client_peer, MSG_IDENTIFY_LONGFLAGS, -1, &client_flags,
+           sizeof client_flags);
 
-       if ((s = getenv("TERM")) == NULL)
-               s = "";
-       proc_send(client_peer, MSG_IDENTIFY_TERM, -1, s, strlen(s) + 1);
+       proc_send(client_peer, MSG_IDENTIFY_TERM, -1, termname,
+           strlen(termname) + 1);
+       proc_send(client_peer, MSG_IDENTIFY_FEATURES, -1, &feat, sizeof feat);
 
        proc_send(client_peer, MSG_IDENTIFY_TTYNAME, -1, ttynam,
            strlen(ttynam) + 1);
        proc_send(client_peer, MSG_IDENTIFY_CWD, -1, cwd, strlen(cwd) + 1);
 
+       for (i = 0; i < ncaps; i++) {
+               proc_send(client_peer, MSG_IDENTIFY_TERMINFO, -1,
+                   caps[i], strlen(caps[i]) + 1);
+       }
+



Home | Main Index | Thread Index | Old Index