From 06c3079d66929e0c71575e877098fc533ae5f4a5 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Mar 2020 17:59:39 +0000 Subject: Make the mouse_word and mouse_line formats work in copy mode and enable the default pane menu in copy mode. --- key-bindings.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'key-bindings.c') diff --git a/key-bindings.c b/key-bindings.c index 57b71c0f..a31c338a 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -46,10 +46,13 @@ " 'New After' 'w' {new-window -a}" \ " 'New At End' 'W' {new-window}" #define DEFAULT_PANE_MENU \ + " '#{?#{==:#{pane_mode},copy-mode},Go To Top,}' '<' {send -X history-top}" \ + " '#{?#{==:#{pane_mode},copy-mode},Go To Bottom,}' '<' {send -X history-bottom}" \ + " ''" \ " '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {copy-mode -t=; send -Xt= search-backward \"#{q:mouse_word}\"}" \ - " '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {send-keys -l -- \"#{q:mouse_word}\"}" \ - " '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {set-buffer -- \"#{q:mouse_word}\"}" \ - " '#{?mouse_line,Copy Line,}' 'l' {set-buffer -- \"#{q:mouse_line}\"}" \ + " '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {copy-mode -q; send-keys -l -- \"#{q:mouse_word}\"}" \ + " '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {copy-mode -q; set-buffer -- \"#{q:mouse_word}\"}" \ + " '#{?mouse_line,Copy Line,}' 'l' {copy-mode -q; set-buffer -- \"#{q:mouse_line}\"}" \ " ''" \ " 'Horizontal Split' 'h' {split-window -h}" \ " 'Vertical Split' 'v' {split-window -v}" \ @@ -354,7 +357,7 @@ key_bindings_init(void) "bind -n MouseDown3Status display-menu -t= -xW -yS -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU, /* Mouse button 3 down on pane. */ - "bind -n MouseDown3Pane if -Ft= '#{||:#{mouse_any_flag},#{pane_in_mode}}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", + "bind -n MouseDown3Pane if -Ft= '#{mouse_any_flag}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", "bind -n M-MouseDown3Pane display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU, /* Copy mode (emacs) keys. */ -- cgit From 005cd486202c35327774857e9cef8e9d446dc092 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Mar 2020 18:05:22 +0000 Subject: Oops, typo in key binding. --- key-bindings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'key-bindings.c') diff --git a/key-bindings.c b/key-bindings.c index a31c338a..dc3b7b9b 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -47,7 +47,7 @@ " 'New At End' 'W' {new-window}" #define DEFAULT_PANE_MENU \ " '#{?#{==:#{pane_mode},copy-mode},Go To Top,}' '<' {send -X history-top}" \ - " '#{?#{==:#{pane_mode},copy-mode},Go To Bottom,}' '<' {send -X history-bottom}" \ + " '#{?#{==:#{pane_mode},copy-mode},Go To Bottom,}' '>' {send -X history-bottom}" \ " ''" \ " '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {copy-mode -t=; send -Xt= search-backward \"#{q:mouse_word}\"}" \ " '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {copy-mode -q; send-keys -l -- \"#{q:mouse_word}\"}" \ -- cgit From 68cf61aa4649e29f434750ff0ec45f78e9164320 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Mar 2020 18:11:56 +0000 Subject: Still want the per-mode menus outside copy mode. --- key-bindings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'key-bindings.c') diff --git a/key-bindings.c b/key-bindings.c index dc3b7b9b..99ce34ca 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -357,7 +357,7 @@ key_bindings_init(void) "bind -n MouseDown3Status display-menu -t= -xW -yS -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU, /* Mouse button 3 down on pane. */ - "bind -n MouseDown3Pane if -Ft= '#{mouse_any_flag}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", + "bind -n MouseDown3Pane if -Ft= '#{||:#{mouse_any_flag},#{&&:#{pane_in_mode},#{!=:#{pane_mode},copy-mode}}}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", "bind -n M-MouseDown3Pane display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU, /* Copy mode (emacs) keys. */ -- cgit From 4d6805284b502c710662985f286803d993572403 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Mar 2020 18:19:22 +0000 Subject: Disable swap entries if nothing to swap with. --- key-bindings.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'key-bindings.c') diff --git a/key-bindings.c b/key-bindings.c index 99ce34ca..7dcaa570 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -34,8 +34,8 @@ " '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}" \ + " '#{?#{>:#{session_windows},1},,-}Swap Left' 'l' {swap-window -t:-1}" \ + " '#{?#{>:#{session_windows},1},,-}Swap Right' 'r' {swap-window -t:+1}" \ " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-window}" \ " ''" \ " 'Kill' 'X' {kill-window}" \ @@ -57,8 +57,8 @@ " 'Horizontal Split' 'h' {split-window -h}" \ " 'Vertical Split' 'v' {split-window -v}" \ " ''" \ - " 'Swap Up' 'u' {swap-pane -U}" \ - " 'Swap Down' 'd' {swap-pane -D}" \ + " '#{?#{>:#{window_panes},1},,-}Swap Up' 'u' {swap-pane -U}" \ + " '#{?#|>:#{window_panes},1},,-}Swap Down' 'd' {swap-pane -D}" \ " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-pane}" \ " ''" \ " 'Kill' 'X' {kill-pane}" \ -- cgit From b66501df0c5de63d2883e7c3c4c1b8d7c31f9fad Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Mar 2020 18:20:58 +0000 Subject: Put swap down back in the right place. --- key-bindings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'key-bindings.c') diff --git a/key-bindings.c b/key-bindings.c index 7dcaa570..0a2163bf 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -58,7 +58,7 @@ " 'Vertical Split' 'v' {split-window -v}" \ " ''" \ " '#{?#{>:#{window_panes},1},,-}Swap Up' 'u' {swap-pane -U}" \ - " '#{?#|>:#{window_panes},1},,-}Swap Down' 'd' {swap-pane -D}" \ + " '#{?#{>:#{window_panes},1},,-}Swap Down' 'd' {swap-pane -D}" \ " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-pane}" \ " ''" \ " 'Kill' 'X' {kill-pane}" \ -- cgit From 7c25f22074bc453898dc9c65318ca73b0014996d Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Mar 2020 18:22:37 +0000 Subject: Similarly, disable zoom if only one pane. --- key-bindings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'key-bindings.c') diff --git a/key-bindings.c b/key-bindings.c index 0a2163bf..9730fb1b 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -64,7 +64,7 @@ " '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}" + " '#{?#{>:#{window_panes},1},,-}#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}" static int key_bindings_cmp(struct key_binding *, struct key_binding *); RB_GENERATE_STATIC(key_bindings, key_binding, entry, key_bindings_cmp); -- cgit From 1a4e64ba69c7c5f287558333b3acb0e98e767081 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Mar 2020 18:35:53 +0000 Subject: Apply same menu items to view mode like copy mode. --- key-bindings.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'key-bindings.c') diff --git a/key-bindings.c b/key-bindings.c index 9730fb1b..a528a6c0 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -46,10 +46,10 @@ " 'New After' 'w' {new-window -a}" \ " 'New At End' 'W' {new-window}" #define DEFAULT_PANE_MENU \ - " '#{?#{==:#{pane_mode},copy-mode},Go To Top,}' '<' {send -X history-top}" \ - " '#{?#{==:#{pane_mode},copy-mode},Go To Bottom,}' '>' {send -X history-bottom}" \ + " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Top,}' '<' {send -X history-top}" \ + " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Bottom,}' '>' {send -X history-bottom}" \ " ''" \ - " '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {copy-mode -t=; send -Xt= search-backward \"#{q:mouse_word}\"}" \ + " '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {if -F '#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}' 'copy-mode -t='; send -Xt= search-backward \"#{q:mouse_word}\"}" \ " '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {copy-mode -q; send-keys -l -- \"#{q:mouse_word}\"}" \ " '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {copy-mode -q; set-buffer -- \"#{q:mouse_word}\"}" \ " '#{?mouse_line,Copy Line,}' 'l' {copy-mode -q; set-buffer -- \"#{q:mouse_line}\"}" \ @@ -357,7 +357,7 @@ key_bindings_init(void) "bind -n MouseDown3Status display-menu -t= -xW -yS -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU, /* Mouse button 3 down on pane. */ - "bind -n MouseDown3Pane if -Ft= '#{||:#{mouse_any_flag},#{&&:#{pane_in_mode},#{!=:#{pane_mode},copy-mode}}}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", + "bind -n MouseDown3Pane if -Ft= '#{||:#{mouse_any_flag},#{&&:#{pane_in_mode},#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}}}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", "bind -n M-MouseDown3Pane display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU, /* Copy mode (emacs) keys. */ -- cgit