Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/tmux/dist merge tmux 3.3a



details:   https://anonhg.NetBSD.org/src/rev/31231da60ee3
branches:  trunk
changeset: 376689:31231da60ee3
user:      wiz <wiz%NetBSD.org@localhost>
date:      Wed Jun 28 22:21:26 2023 +0000

description:
merge tmux 3.3a

diffstat:

 external/bsd/tmux/dist/client.c              |    15 +-
 external/bsd/tmux/dist/cmd-attach-session.c  |    28 +-
 external/bsd/tmux/dist/cmd-capture-pane.c    |     4 +-
 external/bsd/tmux/dist/cmd-display-menu.c    |   156 ++-
 external/bsd/tmux/dist/cmd-display-message.c |    23 +-
 external/bsd/tmux/dist/cmd-if-shell.c        |   170 +--
 external/bsd/tmux/dist/cmd-load-buffer.c     |     4 +-
 external/bsd/tmux/dist/cmd-new-session.c     |    59 +-
 external/bsd/tmux/dist/cmd-new-window.c      |    31 +-
 external/bsd/tmux/dist/cmd-parse.y           |   561 +++++++-----
 external/bsd/tmux/dist/cmd-paste-buffer.c    |     2 +-
 external/bsd/tmux/dist/cmd-queue.c           |    72 +-
 external/bsd/tmux/dist/cmd-resize-window.c   |    10 +-
 external/bsd/tmux/dist/cmd-send-keys.c       |    25 +-
 external/bsd/tmux/dist/cmd-show-messages.c   |     2 +-
 external/bsd/tmux/dist/cmd-show-options.c    |    21 +-
 external/bsd/tmux/dist/cmd-split-window.c    |    88 +-
 external/bsd/tmux/dist/cmd-wait-for.c        |    10 +-
 external/bsd/tmux/dist/colour.c              |   129 ++-
 external/bsd/tmux/dist/compat.h              |    10 +
 external/bsd/tmux/dist/control.c             |     6 +-
 external/bsd/tmux/dist/format.c              |   234 ++++-
 external/bsd/tmux/dist/grid.c                |    98 +-
 external/bsd/tmux/dist/input-keys.c          |    48 +-
 external/bsd/tmux/dist/input.c               |   321 ++++--
 external/bsd/tmux/dist/job.c                 |    38 +-
 external/bsd/tmux/dist/key-bindings.c        |   519 +++++-----
 external/bsd/tmux/dist/log.c                 |    40 +-
 external/bsd/tmux/dist/menu.c                |   104 +-
 external/bsd/tmux/dist/mode-tree.c           |    36 +-
 external/bsd/tmux/dist/notify.c              |   108 +-
 external/bsd/tmux/dist/options.c             |    83 +-
 external/bsd/tmux/dist/proc.c                |    19 +-
 external/bsd/tmux/dist/resize.c              |   132 ++-
 external/bsd/tmux/dist/screen-write.c        |   206 +++-
 external/bsd/tmux/dist/screen.c              |   101 ++-
 external/bsd/tmux/dist/server-client.c       |   913 ++++++++++++++++++--
 external/bsd/tmux/dist/server-fn.c           |    56 +-
 external/bsd/tmux/dist/server.c              |    28 +-
 external/bsd/tmux/dist/session.c             |    14 +-
 external/bsd/tmux/dist/spawn.c               |    26 +-
 external/bsd/tmux/dist/status.c              |   473 +++++++---
 external/bsd/tmux/dist/style.c               |     2 +-
 external/bsd/tmux/dist/tmux.1                |   581 ++++++++++--
 external/bsd/tmux/dist/tmux.c                |    18 +-
 external/bsd/tmux/dist/tmux.h                |   834 +++++++++++-------
 external/bsd/tmux/dist/tty-acs.c             |    76 +-
 external/bsd/tmux/dist/tty-keys.c            |    80 +-
 external/bsd/tmux/dist/tty-term.c            |     3 +-
 external/bsd/tmux/dist/tty.c                 |   575 +++++++++---
 external/bsd/tmux/dist/utf8.c                |    17 +-
 external/bsd/tmux/dist/window-buffer.c       |     8 +-
 external/bsd/tmux/dist/window-client.c       |     6 +-
 external/bsd/tmux/dist/window-copy.c         |  1141 ++++++++++++++++++-------
 external/bsd/tmux/dist/window-customize.c    |    25 +-
 external/bsd/tmux/dist/window-tree.c         |    15 +-
 external/bsd/tmux/dist/window.c              |   153 ++-
 external/bsd/tmux/dist/xmalloc.h             |     4 +-
 58 files changed, 6010 insertions(+), 2551 deletions(-)

diffs (truncated from 15265 to 300 lines):

diff -r ed9585ce0a86 -r 31231da60ee3 external/bsd/tmux/dist/client.c
--- a/external/bsd/tmux/dist/client.c   Wed Jun 28 22:10:15 2023 +0000
+++ b/external/bsd/tmux/dist/client.c   Wed Jun 28 22:21:26 2023 +0000
@@ -243,6 +243,7 @@ client_main(struct event_base *base, int
        ssize_t                  linelen;
        char                    *line = NULL, **caps = NULL, *cause;
        u_int                    ncaps = 0;
+       struct args_value       *values;
 
        /* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */
        signal(SIGCHLD, SIG_IGN);
@@ -258,17 +259,20 @@ client_main(struct event_base *base, int
                msg = MSG_COMMAND;
 
                /*
-                * It sucks parsing the command string twice (in client and
-                * later in server) but it is necessary to get the start server
-                * flag.
+                * It's annoying parsing the command string twice (in client
+                * and later in server) but it is necessary to get the start
+                * server flag.
                 */
-               pr = cmd_parse_from_arguments(argc, argv, NULL);
+               values = args_from_vector(argc, argv);
+               pr = cmd_parse_from_arguments(values, argc, NULL);
                if (pr->status == CMD_PARSE_SUCCESS) {
                        if (cmd_list_any_have(pr->cmdlist, CMD_STARTSERVER))
                                flags |= CLIENT_STARTSERVER;
                        cmd_list_free(pr->cmdlist);
                } else
                        free(pr->error);
+               args_free_values(values, argc);
+               free(values);
        }
 
        /* Create client process structure (starts logging). */
@@ -357,6 +361,7 @@ client_main(struct event_base *base, int
        /* Send identify messages. */
        client_send_identify(ttynam, termname, caps, ncaps, cwd, feat);
        tty_term_free_list(caps, ncaps);
+       proc_flush_peer(client_peer);
 
        /* Send first command. */
        if (msg == MSG_COMMAND) {
@@ -527,7 +532,7 @@ client_signal(int sig)
        if (sig == SIGCHLD)
                waitpid(WAIT_ANY, &status, WNOHANG);
        else if (!client_attached) {
-               if (sig == SIGTERM)
+               if (sig == SIGTERM || sig == SIGHUP)
                        proc_exit(client_proc);
        } else {
                switch (sig) {
diff -r ed9585ce0a86 -r 31231da60ee3 external/bsd/tmux/dist/cmd-attach-session.c
--- a/external/bsd/tmux/dist/cmd-attach-session.c       Wed Jun 28 22:10:15 2023 +0000
+++ b/external/bsd/tmux/dist/cmd-attach-session.c       Wed Jun 28 22:21:26 2023 +0000
@@ -37,13 +37,13 @@ const struct cmd_entry cmd_attach_sessio
        .name = "attach-session",
        .alias = "attach",
 
-       .args = { "c:dEf:rt:x", 0, 0 },
+       .args = { "c:dEf:rt:x", 0, 0, NULL },
        .usage = "[-dErx] [-c working-directory] [-f flags] "
                 CMD_TARGET_SESSION_USAGE,
 
        /* -t is special */
 
-       .flags = CMD_STARTSERVER,
+       .flags = CMD_STARTSERVER|CMD_READONLY,
        .exec = cmd_attach_session_exec
 };
 
@@ -69,6 +69,7 @@ cmd_attach_session(struct cmdq_item *ite
 
        if (c == NULL)
                return (CMD_RETURN_NORMAL);
+
        if (server_client_check_nested(c)) {
                cmdq_error(item, "sessions should be nested with care, "
                    "unset $TMUX to force");
@@ -124,17 +125,9 @@ cmd_attach_session(struct cmdq_item *ite
                if (!Eflag)
                        environ_update(s->options, c->environ, s->environ);
 
-               c->session = s;
+               server_client_set_session(c, s);
                if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT)
                        server_client_set_key_table(c, NULL);
-               tty_update_client_offset(c);
-               status_timer_start(c);
-               notify_client("client-session-changed", c);
-               session_update_activity(s, NULL);
-               gettimeofday(&s->last_attached_time, NULL);
-               server_redraw_client(c);
-               s->curw->flags &= ~WINLINK_ALERTFLAGS;
-               s->curw->window->latest = c;
        } else {
                if (server_client_open(c, &cause) != 0) {
                        cmdq_error(item, "open terminal failed: %s", cause);
@@ -156,25 +149,14 @@ cmd_attach_session(struct cmdq_item *ite
                if (!Eflag)
                        environ_update(s->options, c->environ, s->environ);
 
-               c->session = s;
+               server_client_set_session(c, s);
                server_client_set_key_table(c, NULL);
-               tty_update_client_offset(c);
-               status_timer_start(c);
-               notify_client("client-session-changed", c);
-               session_update_activity(s, NULL);
-               gettimeofday(&s->last_attached_time, NULL);
-               server_redraw_client(c);
-               s->curw->flags &= ~WINLINK_ALERTFLAGS;
-               s->curw->window->latest = c;
 
                if (~c->flags & CLIENT_CONTROL)
                        proc_send(c->peer, MSG_READY, -1, NULL, 0);
                notify_client("client-attached", c);
                c->flags |= CLIENT_ATTACHED;
        }
-       recalculate_sizes();
-       alerts_check_session(s);
-       server_update_socket();
 
        return (CMD_RETURN_NORMAL);
 }
diff -r ed9585ce0a86 -r 31231da60ee3 external/bsd/tmux/dist/cmd-capture-pane.c
--- a/external/bsd/tmux/dist/cmd-capture-pane.c Wed Jun 28 22:10:15 2023 +0000
+++ b/external/bsd/tmux/dist/cmd-capture-pane.c Wed Jun 28 22:21:26 2023 +0000
@@ -39,7 +39,7 @@ const struct cmd_entry cmd_capture_pane_
        .name = "capture-pane",
        .alias = "capturep",
 
-       .args = { "ab:CeE:JNpPqS:t:", 0, 0 },
+       .args = { "ab:CeE:JNpPqS:t:", 0, 0, NULL },
        .usage = "[-aCeJNpPq] " CMD_BUFFER_USAGE " [-E end-line] "
                 "[-S start-line] " CMD_TARGET_PANE_USAGE,
 
@@ -53,7 +53,7 @@ const struct cmd_entry cmd_clear_history
        .name = "clear-history",
        .alias = "clearhist",
 
-       .args = { "t:", 0, 0 },
+       .args = { "t:", 0, 0, NULL },
        .usage = CMD_TARGET_PANE_USAGE,
 
        .target = { 't', CMD_FIND_PANE, 0 },
diff -r ed9585ce0a86 -r 31231da60ee3 external/bsd/tmux/dist/cmd-display-menu.c
--- a/external/bsd/tmux/dist/cmd-display-menu.c Wed Jun 28 22:10:15 2023 +0000
+++ b/external/bsd/tmux/dist/cmd-display-menu.c Wed Jun 28 22:21:26 2023 +0000
@@ -27,16 +27,18 @@
  * Display a menu on a client.
  */
 
-static enum cmd_retval cmd_display_menu_exec(struct cmd *,
-                           struct cmdq_item *);
-static enum cmd_retval cmd_display_popup_exec(struct cmd *,
-                           struct cmdq_item *);
+static enum args_parse_type    cmd_display_menu_args_parse(struct args *,
+                                   u_int, char **);
+static enum cmd_retval         cmd_display_menu_exec(struct cmd *,
+                                   struct cmdq_item *);
+static enum cmd_retval         cmd_display_popup_exec(struct cmd *,
+                                   struct cmdq_item *);
 
 const struct cmd_entry cmd_display_menu_entry = {
        .name = "display-menu",
        .alias = "menu",
 
-       .args = { "c:t:OT:x:y:", 1, -1 },
+       .args = { "c:t:OT:x:y:", 1, -1, cmd_display_menu_args_parse },
        .usage = "[-O] [-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
                 "[-x position] [-y position] name key command ...",
 
@@ -50,10 +52,12 @@ const struct cmd_entry cmd_display_popup
        .name = "display-popup",
        .alias = "popup",
 
-       .args = { "Cc:d:Eh:t:w:x:y:", 0, -1 },
-       .usage = "[-CE] [-c target-client] [-d start-directory] [-h height] "
-                CMD_TARGET_PANE_USAGE " [-w width] "
-                "[-x position] [-y position] [command]",
+       .args = { "Bb:Cc:d:e:Eh:s:S:t:T:w:x:y:", 0, -1, NULL },
+       .usage = "[-BCE] [-b border-lines] [-c target-client] "
+                "[-d start-directory] [-e environment] [-h height] "
+                "[-s style] [-S border-style] " CMD_TARGET_PANE_USAGE
+                "[-T title] [-w width] [-x position] [-y position] "
+                "[shell-command]",
 
        .target = { 't', CMD_FIND_PANE, 0 },
 
@@ -61,6 +65,30 @@ const struct cmd_entry cmd_display_popup
        .exec = cmd_display_popup_exec
 };
 
+static enum args_parse_type
+cmd_display_menu_args_parse(struct args *args, u_int idx, __unused char **cause)
+{
+       u_int                    i = 0;
+       enum args_parse_type     type = ARGS_PARSE_STRING;
+
+       for (;;) {
+               type = ARGS_PARSE_STRING;
+               if (i == idx)
+                       break;
+               if (*args_string(args, i++) == '\0')
+                       continue;
+
+               type = ARGS_PARSE_STRING;
+               if (i++ == idx)
+                       break;
+
+               type = ARGS_PARSE_COMMANDS_OR_STRING;
+               if (i++ == idx)
+                       break;
+       }
+       return (type);
+}
+
 static int
 cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
     struct args *args, u_int *px, u_int *py, u_int w, u_int h)
@@ -120,8 +148,6 @@ cmd_display_menu_get_position(struct cli
                        if (sr != NULL)
                                break;
                }
-               if (line == lines)
-                       ranges = &tc->status.entries[0].ranges;
 
                if (sr != NULL) {
                        format_add(ft, "popup_window_status_line_x", "%u",
@@ -174,8 +200,8 @@ cmd_display_menu_get_position(struct cli
                } else
                        format_add(ft, "popup_mouse_centre_y", "%ld", n);
                n = (long)event->m.y + h;
-               if (n + h >= tty->sy)
-                       format_add(ft, "popup_mouse_top", "%u", tty->sy - h);
+               if (n >= tty->sy)
+                       format_add(ft, "popup_mouse_top", "%u", tty->sy - 1);
                else
                        format_add(ft, "popup_mouse_top", "%ld", n);
                n = event->m.y - h;
@@ -219,7 +245,7 @@ cmd_display_menu_get_position(struct cli
        else if (n < 0)
                n = 0;
        *px = n;
-       log_debug("%s: -x: %s = %s = %u", __func__, xp, p, *px);
+       log_debug("%s: -x: %s = %s = %u (-w %u)", __func__, xp, p, *px, w);
        free(p);
 
        /* Expand vertical position  */
@@ -245,7 +271,7 @@ cmd_display_menu_get_position(struct cli
        else if (n < 0)
                n = 0;
        *py = n;
-       log_debug("%s: -y: %s = %s = %u", __func__, yp, p, *py);
+       log_debug("%s: -y: %s = %s = %u (-h %u)", __func__, yp, p, *py, h);
        free(p);
 
        return (1);
@@ -260,10 +286,10 @@ cmd_display_menu_exec(struct cmd *self, 
        struct client           *tc = cmdq_get_target_client(item);
        struct menu             *menu = NULL;
        struct menu_item         menu_item;
-       const char              *key;
-       char                    *title, *name;
-       int                      flags = 0, i;
-       u_int                    px, py;
+       const char              *key, *name;
+       char                    *title;
+       int                      flags = 0;
+       u_int                    px, py, i, count = args_count(args);
 
        if (tc->overlay_draw != NULL)
                return (CMD_RETURN_NORMAL);
@@ -274,24 +300,24 @@ cmd_display_menu_exec(struct cmd *self, 
                title = xstrdup("");
        menu = menu_create(title);
 
-       for (i = 0; i != args->argc; /* nothing */) {
-               name = args->argv[i++];
+       for (i = 0; i != count; /* nothing */) {
+               name = args_string(args, i++);
                if (*name == '\0') {
                        menu_add_item(menu, NULL, item, tc, target);
                        continue;
                }
 
-               if (args->argc - i < 2) {
+               if (count - i < 2) {
                        cmdq_error(item, "not enough arguments");
                        free(title);
                        menu_free(menu);
                        return (CMD_RETURN_ERROR);
                }
-               key = args->argv[i++];
+               key = args_string(args, i++);
 
                menu_item.name = name;
                menu_item.key = key_string_lookup_string(key);



Home | Main Index | Thread Index | Old Index