mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Add window_pane_mode helper function to tell if a pane is in copy mode,
from Michael Grant.
This commit is contained in:
		
							
								
								
									
										6
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								format.c
									
									
									
									
									
								
							@@ -1136,8 +1136,7 @@ format_cb_mouse_word(struct format_tree *ft)
 | 
			
		||||
		return (NULL);
 | 
			
		||||
 | 
			
		||||
	if (!TAILQ_EMPTY(&wp->modes)) {
 | 
			
		||||
		if (TAILQ_FIRST(&wp->modes)->mode == &window_copy_mode ||
 | 
			
		||||
		    TAILQ_FIRST(&wp->modes)->mode == &window_view_mode)
 | 
			
		||||
		if (window_pane_mode(wp) != WINDOW_PANE_NO_MODE)
 | 
			
		||||
			return (window_copy_get_word(wp, x, y));
 | 
			
		||||
		return (NULL);
 | 
			
		||||
	}
 | 
			
		||||
@@ -1181,8 +1180,7 @@ format_cb_mouse_line(struct format_tree *ft)
 | 
			
		||||
		return (NULL);
 | 
			
		||||
 | 
			
		||||
	if (!TAILQ_EMPTY(&wp->modes)) {
 | 
			
		||||
		if (TAILQ_FIRST(&wp->modes)->mode == &window_copy_mode ||
 | 
			
		||||
		    TAILQ_FIRST(&wp->modes)->mode == &window_view_mode)
 | 
			
		||||
		if (window_pane_mode(wp) != WINDOW_PANE_NO_MODE)
 | 
			
		||||
			return (window_copy_get_line(wp, y));
 | 
			
		||||
		return (NULL);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								tmux.h
									
									
									
									
									
								
							@@ -966,6 +966,11 @@ enum pane_lines {
 | 
			
		||||
#define PANE_BORDER_ARROWS 2
 | 
			
		||||
#define PANE_BORDER_BOTH 3
 | 
			
		||||
 | 
			
		||||
/* Mode returned by window_pane_mode function. */
 | 
			
		||||
#define WINDOW_PANE_NO_MODE 0
 | 
			
		||||
#define WINDOW_PANE_COPY_MODE 1
 | 
			
		||||
#define WINDOW_PANE_VIEW_MODE 2
 | 
			
		||||
 | 
			
		||||
/* Screen redraw context. */
 | 
			
		||||
struct screen_redraw_ctx {
 | 
			
		||||
	struct client	*c;
 | 
			
		||||
@@ -3112,6 +3117,7 @@ void		 window_pane_update_used_data(struct window_pane *,
 | 
			
		||||
		     struct window_pane_offset *, size_t);
 | 
			
		||||
void		 window_set_fill_character(struct window *);
 | 
			
		||||
void		 window_pane_default_cursor(struct window_pane *);
 | 
			
		||||
int		 window_pane_mode(struct window_pane *);
 | 
			
		||||
 | 
			
		||||
/* layout.c */
 | 
			
		||||
u_int		 layout_count_cells(struct layout_cell *);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								window.c
									
									
									
									
									
								
							@@ -1662,3 +1662,15 @@ window_pane_default_cursor(struct window_pane *wp)
 | 
			
		||||
	s->default_mode = 0;
 | 
			
		||||
	screen_set_cursor_style(c, &s->default_cstyle, &s->default_mode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
window_pane_mode(struct window_pane *wp)
 | 
			
		||||
{
 | 
			
		||||
	if (TAILQ_FIRST(&wp->modes) != NULL) {
 | 
			
		||||
		if (TAILQ_FIRST(&wp->modes)->mode == &window_copy_mode)
 | 
			
		||||
			return (WINDOW_PANE_COPY_MODE);
 | 
			
		||||
		if (TAILQ_FIRST(&wp->modes)->mode == &window_view_mode)
 | 
			
		||||
			return (WINDOW_PANE_VIEW_MODE);
 | 
			
		||||
	}
 | 
			
		||||
	return (WINDOW_PANE_NO_MODE);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user