Thomas Adam
unread,May 14, 2019, 3:13:47 PM5/14/19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to tmux-...@googlegroups.com, Thomas Adam
1. Expose server_client_clear_overlay() to enable menus to be
manpulated outside of the client which has the menu open. If the client
receives a command from a different client to display a new menu, tear
the current one down and use the new one.
2. Start the menu selection at 0 so the first item is highlighted by
default.
I'm not precious about either change...
---
cmd-display-menu.c | 2 +-
menu.c | 2 +-
server-client.c | 3 +--
tmux.h | 1 +
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cmd-display-menu.c b/cmd-display-menu.c
index 27bf454d..582a59c4 100644
--- a/cmd-display-menu.c
+++ b/cmd-display-menu.c
@@ -63,7 +63,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
if ((c = cmd_find_client(item, args_get(args, 'c'), 0)) == NULL)
return (CMD_RETURN_ERROR);
if (c->overlay_draw != NULL)
- return (CMD_RETURN_NORMAL);
+ server_client_clear_overlay(c);
at = status_at_line(c);
string = args_get(args, 'M');
diff --git a/menu.c b/menu.c
index 0443d22f..9c0a93d6 100644
--- a/menu.c
+++ b/menu.c
@@ -331,7 +331,7 @@ menu_display(struct menu *menu, int flags, struct cmdq_item *item, u_int px,
md->py = py;
md->menu = menu;
- md->choice = -1;
+ md->choice = 0;
md->cb = cb;
md->data = data;
diff --git a/server-client.c b/server-client.c
index fdc40d8d..f131bfd0 100644
--- a/server-client.c
+++ b/server-client.c
@@ -41,7 +41,6 @@ static void server_client_check_redraw(struct client *);
static void server_client_set_title(struct client *);
static void server_client_reset_state(struct client *);
static int server_client_assume_paste(struct session *);
-static void server_client_clear_overlay(struct client *);
static void server_client_dispatch(struct imsg *, void *);
static void server_client_dispatch_command(struct client *, struct imsg *);
@@ -99,7 +98,7 @@ server_client_set_overlay(struct client *c, u_int delay, overlay_draw_cb drawcb,
}
/* Clear overlay mode on client. */
-static void
+void
server_client_clear_overlay(struct client *c)
{
if (c->overlay_draw == NULL)
diff --git a/tmux.h b/tmux.h
index 794dd3d7..67e93631 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2049,6 +2049,7 @@ void server_add_accept(int);
u_int server_client_how_many(void);
void server_client_set_overlay(struct client *, u_int, overlay_draw_cb,
overlay_key_cb, overlay_free_cb, void *);
+void server_client_clear_overlay(struct client *);
void server_client_set_key_table(struct client *, const char *);
const char *server_client_get_key_table(struct client *);
int server_client_check_nested(struct client *);
--
2.20.1