diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-05-10 18:04:07 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-05-10 18:04:07 +0000 |
commit | c2e749ce9977afc1368916e031b551400ef29f2f (patch) | |
tree | 5a2aed239fab21d4b8e4b0268eb757b98aea2334 /usr.bin/tmux/format.c | |
parent | 77610458f85b49f77da7ec69e4a63942510bd1dd (diff) |
Add support for simple menus usable with mouse or keyboard. New command
display-menu shows a menu (bound to the mouse on status line by default)
and a couple of extra formats for the default menus.
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r-- | usr.bin/tmux/format.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index ccfac2b2512..e393430fef6 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.191 2019/05/09 08:38:13 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.192 2019/05/10 18:04:06 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -54,6 +54,49 @@ static void format_defaults_session(struct format_tree *, static void format_defaults_client(struct format_tree *, struct client *); static void format_defaults_winlink(struct format_tree *, struct winlink *); +/* Default menus. */ +#define DEFAULT_CLIENT_MENU \ + "Detach,d,detach-client|" \ + "Detach & Kill,X,detach-client -P|" \ + "Detach Others,o,detach-client -a|" \ + "|" \ + "#{?#{lock-command},Lock,},l,lock-client" +#define DEFAULT_SESSION_MENU \ + "Next,n,switch-client -n|" \ + "Previous,p,switch-client -p|" \ + "|" \ + "Renumber,N,move-window -r|" \ + "Rename,n,command-prompt -I \"#S\" \"rename-session -- '%%'\"|" \ + "|" \ + "New Session,s,new-session|" \ + "New Window,w,new-window" +#define DEFAULT_WINDOW_MENU \ + "Swap Left,l,swap-window -t,-1|" \ + "Swap Right,r,swap-window -t,+1|" \ + "#{?pane_marked_set,,#[dim]}Swap Marked,s,swap-window|" \ + "|" \ + "Kill,X,kill-window|" \ + "Respawn,R,respawn-window -k|" \ + "|" \ + "#{?pane_marked,Unmark,Mark},m,select-pane -m|" \ + "Rename,n,command-prompt -I \"#W\" \"rename-window -- '%%'\"|" \ + "|" \ + "New After,w,new-window -a|" \ + "New At End,W,new-window" +#define DEFAULT_PANE_MENU \ + "Horizontal Split,h,split-window -h|" \ + "Vertical Split,v,split-window -v|" \ + "|" \ + "Swap Up,u,swap-pane -U|" \ + "Swap Down,d,swap-pane -D|" \ + "#{?pane_marked_set,,#[dim]}Swap Marked,s,swap-pane|" \ + "|" \ + "Kill,X,kill-pane|" \ + "Respawn,R,respawn-pane -k|" \ + "|" \ + "#{?pane_marked,Unmark,Mark},m,select-pane -m|" \ + "#{?window_zoomed_flag,Unzoom,Zoom},z,resize-pane -Z" + /* Entry in format job tree. */ struct format_job { struct client *client; @@ -752,6 +795,11 @@ format_create(struct client *c, struct cmdq_item *item, int tag, int flags) } } + format_add(ft, "client_menu", "%s", DEFAULT_CLIENT_MENU); + format_add(ft, "session_menu", "%s", DEFAULT_SESSION_MENU); + format_add(ft, "window_menu", "%s", DEFAULT_WINDOW_MENU); + format_add(ft, "pane_menu", "%s", DEFAULT_PANE_MENU); + if (item != NULL) { if (item->cmd != NULL) format_add(ft, "command", "%s", item->cmd->entry->name); |