mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Add window_visible_layout which ignores zoomed panes and use it for
control mode (which needs to know all panes), from George Nachman.
This commit is contained in:
		@@ -19,6 +19,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CONTROL_SHOULD_NOTIFY_CLIENT(c) \
 | 
					#define CONTROL_SHOULD_NOTIFY_CLIENT(c) \
 | 
				
			||||||
@@ -65,6 +67,10 @@ control_notify_window_layout_changed(struct window *w)
 | 
				
			|||||||
	struct format_tree	*ft;
 | 
						struct format_tree	*ft;
 | 
				
			||||||
	struct winlink		*wl;
 | 
						struct winlink		*wl;
 | 
				
			||||||
	const char		*template;
 | 
						const char		*template;
 | 
				
			||||||
 | 
						char			*expanded;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						template = "%layout-change #{window_id} #{window_layout} "
 | 
				
			||||||
 | 
						    "#{window_visible_layout} #{window_flags}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TAILQ_FOREACH(c, &clients, entry) {
 | 
						TAILQ_FOREACH(c, &clients, entry) {
 | 
				
			||||||
		if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
 | 
							if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
 | 
				
			||||||
@@ -81,13 +87,14 @@ control_notify_window_layout_changed(struct window *w)
 | 
				
			|||||||
		 */
 | 
							 */
 | 
				
			||||||
		if (w->layout_root == NULL)
 | 
							if (w->layout_root == NULL)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		template = "%layout-change #{window_id} #{window_layout}";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ft = format_create();
 | 
							ft = format_create();
 | 
				
			||||||
		wl = winlink_find_by_window(&s->windows, w);
 | 
							wl = winlink_find_by_window(&s->windows, w);
 | 
				
			||||||
		if (wl != NULL) {
 | 
							if (wl != NULL) {
 | 
				
			||||||
			format_defaults(ft, c, NULL, wl, NULL);
 | 
								format_defaults(ft, c, NULL, wl, NULL);
 | 
				
			||||||
			control_write(c, "%s", format_expand(ft, template));
 | 
								expanded = format_expand(ft, template);
 | 
				
			||||||
 | 
								control_write(c, "%s", expanded);
 | 
				
			||||||
 | 
								free(expanded);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		format_free(ft);
 | 
							format_free(ft);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								format.c
									
									
									
									
									
								
							@@ -48,6 +48,7 @@ void	 format_cb_host_short(struct format_tree *, struct format_entry *);
 | 
				
			|||||||
void	 format_cb_pid(struct format_tree *, struct format_entry *);
 | 
					void	 format_cb_pid(struct format_tree *, struct format_entry *);
 | 
				
			||||||
void	 format_cb_session_alerts(struct format_tree *, struct format_entry *);
 | 
					void	 format_cb_session_alerts(struct format_tree *, struct format_entry *);
 | 
				
			||||||
void	 format_cb_window_layout(struct format_tree *, struct format_entry *);
 | 
					void	 format_cb_window_layout(struct format_tree *, struct format_entry *);
 | 
				
			||||||
 | 
					void format_cb_window_visible_layout(struct format_tree *, struct format_entry *);
 | 
				
			||||||
void	 format_cb_start_command(struct format_tree *, struct format_entry *);
 | 
					void	 format_cb_start_command(struct format_tree *, struct format_entry *);
 | 
				
			||||||
void	 format_cb_current_command(struct format_tree *, struct format_entry *);
 | 
					void	 format_cb_current_command(struct format_tree *, struct format_entry *);
 | 
				
			||||||
void	 format_cb_history_bytes(struct format_tree *, struct format_entry *);
 | 
					void	 format_cb_history_bytes(struct format_tree *, struct format_entry *);
 | 
				
			||||||
@@ -362,6 +363,18 @@ format_cb_window_layout(struct format_tree *ft, struct format_entry *fe)
 | 
				
			|||||||
		fe->value = layout_dump(w->layout_root);
 | 
							fe->value = layout_dump(w->layout_root);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Callback for window_visible_layout. */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					format_cb_window_visible_layout(struct format_tree *ft, struct format_entry *fe)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct window	*w = ft->w;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (w == NULL)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fe->value = layout_dump(w->layout_root);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Callback for pane_start_command. */
 | 
					/* Callback for pane_start_command. */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
format_cb_start_command(struct format_tree *ft, struct format_entry *fe)
 | 
					format_cb_start_command(struct format_tree *ft, struct format_entry *fe)
 | 
				
			||||||
@@ -1024,6 +1037,8 @@ format_defaults_window(struct format_tree *ft, struct window *w)
 | 
				
			|||||||
	format_add(ft, "window_width", "%u", w->sx);
 | 
						format_add(ft, "window_width", "%u", w->sx);
 | 
				
			||||||
	format_add(ft, "window_height", "%u", w->sy);
 | 
						format_add(ft, "window_height", "%u", w->sy);
 | 
				
			||||||
	format_add_cb(ft, "window_layout", format_cb_window_layout);
 | 
						format_add_cb(ft, "window_layout", format_cb_window_layout);
 | 
				
			||||||
 | 
						format_add_cb(ft, "window_visible_layout",
 | 
				
			||||||
 | 
						    format_cb_window_visible_layout);
 | 
				
			||||||
	format_add(ft, "window_panes", "%u", window_count_panes(w));
 | 
						format_add(ft, "window_panes", "%u", window_count_panes(w));
 | 
				
			||||||
	format_add(ft, "window_zoomed_flag", "%d",
 | 
						format_add(ft, "window_zoomed_flag", "%d",
 | 
				
			||||||
	    !!(w->flags & WINDOW_ZOOMED));
 | 
						    !!(w->flags & WINDOW_ZOOMED));
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								tmux.1
									
									
									
									
									
								
							@@ -3412,11 +3412,12 @@ The following variables are available, where appropriate:
 | 
				
			|||||||
.It Li "window_id" Ta "" Ta "Unique window ID"
 | 
					.It Li "window_id" Ta "" Ta "Unique window ID"
 | 
				
			||||||
.It Li "window_index" Ta "#I" Ta "Index of window"
 | 
					.It Li "window_index" Ta "#I" Ta "Index of window"
 | 
				
			||||||
.It Li "window_last_flag" Ta "" Ta "1 if window is the last used"
 | 
					.It Li "window_last_flag" Ta "" Ta "1 if window is the last used"
 | 
				
			||||||
.It Li "window_layout" Ta "" Ta "Window layout description"
 | 
					.It Li "window_layout" Ta "" Ta "Window layout description, ignoring zoomed window panes"
 | 
				
			||||||
.It Li "window_linked" Ta "" Ta "1 if window is linked across sessions"
 | 
					.It Li "window_linked" Ta "" Ta "1 if window is linked across sessions"
 | 
				
			||||||
.It Li "window_name" Ta "#W" Ta "Name of window"
 | 
					.It Li "window_name" Ta "#W" Ta "Name of window"
 | 
				
			||||||
.It Li "window_panes" Ta "" Ta "Number of panes in window"
 | 
					.It Li "window_panes" Ta "" Ta "Number of panes in window"
 | 
				
			||||||
.It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
 | 
					.It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
 | 
				
			||||||
 | 
					.It Li "window_visible_layout" Ta "" Ta "Window layout description, respecting zoomed window panes"
 | 
				
			||||||
.It Li "window_width" Ta "" Ta "Width of window"
 | 
					.It Li "window_width" Ta "" Ta "Width of window"
 | 
				
			||||||
.It Li "window_zoomed_flag" Ta "" Ta "1 if window is zoomed"
 | 
					.It Li "window_zoomed_flag" Ta "" Ta "1 if window is zoomed"
 | 
				
			||||||
.It Li "wrap_flag" Ta "" Ta "Pane wrap flag"
 | 
					.It Li "wrap_flag" Ta "" Ta "Pane wrap flag"
 | 
				
			||||||
@@ -4007,12 +4008,16 @@ or an error occurred.
 | 
				
			|||||||
If present,
 | 
					If present,
 | 
				
			||||||
.Ar reason
 | 
					.Ar reason
 | 
				
			||||||
describes why the client exited.
 | 
					describes why the client exited.
 | 
				
			||||||
.It Ic %layout-change Ar window-id Ar window-layout
 | 
					.It Ic %layout-change Ar window-id Ar window-layout Ar window-visible-layout Ar window-flags
 | 
				
			||||||
The layout of a window with ID
 | 
					The layout of a window with ID
 | 
				
			||||||
.Ar window-id
 | 
					.Ar window-id
 | 
				
			||||||
changed.
 | 
					changed.
 | 
				
			||||||
The new layout is
 | 
					The new layout is
 | 
				
			||||||
.Ar window-layout .
 | 
					.Ar window-layout .
 | 
				
			||||||
 | 
					The window's visible layout is
 | 
				
			||||||
 | 
					.Ar window-visible-layout
 | 
				
			||||||
 | 
					and the window flags are
 | 
				
			||||||
 | 
					.Ar window-flags .
 | 
				
			||||||
.It Ic %output Ar pane-id Ar value
 | 
					.It Ic %output Ar pane-id Ar value
 | 
				
			||||||
A window pane produced output.
 | 
					A window pane produced output.
 | 
				
			||||||
.Ar value
 | 
					.Ar value
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user