mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Add simple menus to tree, client, buffer modes.
This commit is contained in:
@ -40,6 +40,16 @@ static void window_client_key(struct window_mode_entry *,
|
||||
"session #{session_name} " \
|
||||
"(#{client_width}x#{client_height}, #{t:client_activity})"
|
||||
|
||||
#define WINDOW_CLIENT_MENU \
|
||||
"Detach,d,|" \
|
||||
"Detach Tagged,D,|" \
|
||||
"|" \
|
||||
"Tag,t,|" \
|
||||
"Tag All,C-t,|" \
|
||||
"Tag None,T,|" \
|
||||
"|" \
|
||||
"Cancel,q,"
|
||||
|
||||
const struct window_mode window_client_mode = {
|
||||
.name = "client-mode",
|
||||
.default_format = WINDOW_CLIENT_DEFAULT_FORMAT,
|
||||
@ -68,6 +78,8 @@ struct window_client_itemdata {
|
||||
};
|
||||
|
||||
struct window_client_modedata {
|
||||
struct window_pane *wp;
|
||||
|
||||
struct mode_tree_data *data;
|
||||
char *format;
|
||||
char *command;
|
||||
@ -249,6 +261,19 @@ window_client_draw(__unused void *modedata, void *itemdata,
|
||||
screen_write_fast_copy(ctx, &c->status.screen, 0, 0, sx, lines);
|
||||
}
|
||||
|
||||
static void
|
||||
window_client_menu(void *modedata, struct client *c, key_code key)
|
||||
{
|
||||
struct window_client_modedata *data = modedata;
|
||||
struct window_pane *wp = data->wp;
|
||||
struct window_mode_entry *wme;
|
||||
|
||||
wme = TAILQ_FIRST(&wp->modes);
|
||||
if (wme == NULL || wme->data != modedata)
|
||||
return;
|
||||
window_client_key(wme, c, NULL, NULL, key, NULL);
|
||||
}
|
||||
|
||||
static struct screen *
|
||||
window_client_init(struct window_mode_entry *wme,
|
||||
__unused struct cmd_find_state *fs, struct args *args)
|
||||
@ -258,6 +283,7 @@ window_client_init(struct window_mode_entry *wme,
|
||||
struct screen *s;
|
||||
|
||||
wme->data = data = xcalloc(1, sizeof *data);
|
||||
data->wp = wp;
|
||||
|
||||
if (args == NULL || !args_has(args, 'F'))
|
||||
data->format = xstrdup(WINDOW_CLIENT_DEFAULT_FORMAT);
|
||||
@ -269,7 +295,8 @@ window_client_init(struct window_mode_entry *wme,
|
||||
data->command = xstrdup(args->argv[0]);
|
||||
|
||||
data->data = mode_tree_start(wp, args, window_client_build,
|
||||
window_client_draw, NULL, data, window_client_sort_list,
|
||||
window_client_draw, NULL, window_client_menu, data,
|
||||
WINDOW_CLIENT_MENU, window_client_sort_list,
|
||||
nitems(window_client_sort_list), &s);
|
||||
mode_tree_zoom(data->data, args);
|
||||
|
||||
|
Reference in New Issue
Block a user