mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 01:34:18 +00:00 
			
		
		
		
	Add scroll-top and scroll-bottom commands to scroll so cursor is at top
or bottom. From Anindya Mukherjee, GitHub issue 3334.
This commit is contained in:
		
							
								
								
									
										11
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								tmux.1
									
									
									
									
									
								
							@@ -1808,7 +1808,9 @@ The following commands are supported in copy mode:
 | 
				
			|||||||
.It Li "search-forward <for>" Ta "/" Ta ""
 | 
					.It Li "search-forward <for>" Ta "/" Ta ""
 | 
				
			||||||
.It Li "search-forward-incremental <for>" Ta "" Ta "C-s"
 | 
					.It Li "search-forward-incremental <for>" Ta "" Ta "C-s"
 | 
				
			||||||
.It Li "search-forward-text <for>" Ta "" Ta ""
 | 
					.It Li "search-forward-text <for>" Ta "" Ta ""
 | 
				
			||||||
 | 
					.It Li "scroll-bottom" Ta "" Ta ""
 | 
				
			||||||
.It Li "scroll-middle" Ta "z" Ta ""
 | 
					.It Li "scroll-middle" Ta "z" Ta ""
 | 
				
			||||||
 | 
					.It Li "scroll-top" Ta "" Ta ""
 | 
				
			||||||
.It Li "search-reverse" Ta "N" Ta "N"
 | 
					.It Li "search-reverse" Ta "N" Ta "N"
 | 
				
			||||||
.It Li "select-line" Ta "V" Ta ""
 | 
					.It Li "select-line" Ta "V" Ta ""
 | 
				
			||||||
.It Li "select-word" Ta "" Ta ""
 | 
					.It Li "select-word" Ta "" Ta ""
 | 
				
			||||||
@@ -2011,7 +2013,7 @@ but a different format may be specified with
 | 
				
			|||||||
.Fl F .
 | 
					.Fl F .
 | 
				
			||||||
.Tg capturep
 | 
					.Tg capturep
 | 
				
			||||||
.It Xo Ic capture-pane
 | 
					.It Xo Ic capture-pane
 | 
				
			||||||
.Op Fl aepPqCJN
 | 
					.Op Fl aAepPqCJN
 | 
				
			||||||
.Op Fl b Ar buffer-name
 | 
					.Op Fl b Ar buffer-name
 | 
				
			||||||
.Op Fl E Ar end-line
 | 
					.Op Fl E Ar end-line
 | 
				
			||||||
.Op Fl S Ar start-line
 | 
					.Op Fl S Ar start-line
 | 
				
			||||||
@@ -2036,10 +2038,15 @@ is given, the output includes escape sequences for text and background
 | 
				
			|||||||
attributes.
 | 
					attributes.
 | 
				
			||||||
.Fl C
 | 
					.Fl C
 | 
				
			||||||
also escapes non-printable characters as octal \exxx.
 | 
					also escapes non-printable characters as octal \exxx.
 | 
				
			||||||
 | 
					.Fl T
 | 
				
			||||||
 | 
					ignores trailing positions that do not contain a character.
 | 
				
			||||||
.Fl N
 | 
					.Fl N
 | 
				
			||||||
preserves trailing spaces at each line's end and
 | 
					preserves trailing spaces at each line's end and
 | 
				
			||||||
.Fl J
 | 
					.Fl J
 | 
				
			||||||
preserves trailing spaces and joins any wrapped lines.
 | 
					preserves trailing spaces and joins any wrapped lines;
 | 
				
			||||||
 | 
					.Fl J
 | 
				
			||||||
 | 
					implies
 | 
				
			||||||
 | 
					.Fl T .
 | 
				
			||||||
.Fl P
 | 
					.Fl P
 | 
				
			||||||
captures only any output that the pane has received that is the beginning of an
 | 
					captures only any output that the pane has received that is the beginning of an
 | 
				
			||||||
as-yet incomplete escape sequence.
 | 
					as-yet incomplete escape sequence.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1250,20 +1250,23 @@ window_copy_cmd_cursor_right(struct window_copy_cmd_state *cs)
 | 
				
			|||||||
	return (WINDOW_COPY_CMD_NOTHING);
 | 
						return (WINDOW_COPY_CMD_NOTHING);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Scroll line containing the cursor to the given position. */
 | 
				
			||||||
static enum window_copy_cmd_action
 | 
					static enum window_copy_cmd_action
 | 
				
			||||||
window_copy_cmd_scroll_middle(struct window_copy_cmd_state *cs)
 | 
					window_copy_cmd_scroll_to(struct window_copy_cmd_state *cs, u_int to)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct window_mode_entry	*wme = cs->wme;
 | 
						struct window_mode_entry	*wme = cs->wme;
 | 
				
			||||||
	struct window_copy_mode_data	*data = wme->data;
 | 
						struct window_copy_mode_data	*data = wme->data;
 | 
				
			||||||
	u_int				 mid_value, oy, delta;
 | 
						u_int				 oy, delta;
 | 
				
			||||||
	int				 scroll_up; /* >0 up, <0 down */
 | 
						int				 scroll_up; /* >0 up, <0 down */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mid_value = (screen_size_y(&data->screen) - 1) / 2;
 | 
						scroll_up = data->cy - to;
 | 
				
			||||||
	scroll_up = data->cy - mid_value;
 | 
					 | 
				
			||||||
	delta = abs(scroll_up);
 | 
						delta = abs(scroll_up);
 | 
				
			||||||
	oy = screen_hsize(data->backing) + data->cy - data->oy;
 | 
						oy = screen_hsize(data->backing) - data->oy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log_debug ("XXX %u %u %u %d %u", mid_value, oy, delta, scroll_up, data->oy);
 | 
						/*
 | 
				
			||||||
 | 
						 * oy is the maximum scroll down amount, while data->oy is the maximum
 | 
				
			||||||
 | 
						 * scroll up amount.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	if (scroll_up > 0 && data->oy >= delta) {
 | 
						if (scroll_up > 0 && data->oy >= delta) {
 | 
				
			||||||
		window_copy_scroll_up(wme, delta);
 | 
							window_copy_scroll_up(wme, delta);
 | 
				
			||||||
		data->cy -= delta;
 | 
							data->cy -= delta;
 | 
				
			||||||
@@ -1276,6 +1279,35 @@ window_copy_cmd_scroll_middle(struct window_copy_cmd_state *cs)
 | 
				
			|||||||
	return (WINDOW_COPY_CMD_REDRAW);
 | 
						return (WINDOW_COPY_CMD_REDRAW);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Scroll line containing the cursor to the bottom. */
 | 
				
			||||||
 | 
					static enum window_copy_cmd_action
 | 
				
			||||||
 | 
					window_copy_cmd_scroll_bottom(struct window_copy_cmd_state *cs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct window_copy_mode_data	*data = cs->wme->data;
 | 
				
			||||||
 | 
						u_int				 bottom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bottom = screen_size_y(&data->screen) - 1;
 | 
				
			||||||
 | 
						return (window_copy_cmd_scroll_to(cs, bottom));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Scroll line containing the cursor to the middle. */
 | 
				
			||||||
 | 
					static enum window_copy_cmd_action
 | 
				
			||||||
 | 
					window_copy_cmd_scroll_middle(struct window_copy_cmd_state *cs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct window_copy_mode_data	*data = cs->wme->data;
 | 
				
			||||||
 | 
						u_int				 mid_value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						mid_value = (screen_size_y(&data->screen) - 1) / 2;
 | 
				
			||||||
 | 
						return (window_copy_cmd_scroll_to(cs, mid_value));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Scroll line containing the cursor to the top. */
 | 
				
			||||||
 | 
					static enum window_copy_cmd_action
 | 
				
			||||||
 | 
					window_copy_cmd_scroll_top(struct window_copy_cmd_state *cs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return (window_copy_cmd_scroll_to(cs, 0));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static enum window_copy_cmd_action
 | 
					static enum window_copy_cmd_action
 | 
				
			||||||
window_copy_cmd_cursor_up(struct window_copy_cmd_state *cs)
 | 
					window_copy_cmd_cursor_up(struct window_copy_cmd_state *cs)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -2794,6 +2826,12 @@ static const struct {
 | 
				
			|||||||
	  .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
 | 
						  .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
 | 
				
			||||||
	  .f = window_copy_cmd_refresh_from_pane
 | 
						  .f = window_copy_cmd_refresh_from_pane
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{ .command = "scroll-bottom",
 | 
				
			||||||
 | 
						  .minargs = 0,
 | 
				
			||||||
 | 
						  .maxargs = 0,
 | 
				
			||||||
 | 
						  .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
 | 
				
			||||||
 | 
						  .f = window_copy_cmd_scroll_bottom
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	{ .command = "scroll-down",
 | 
						{ .command = "scroll-down",
 | 
				
			||||||
	  .minargs = 0,
 | 
						  .minargs = 0,
 | 
				
			||||||
	  .maxargs = 0,
 | 
						  .maxargs = 0,
 | 
				
			||||||
@@ -2812,6 +2850,12 @@ static const struct {
 | 
				
			|||||||
	  .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
 | 
						  .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
 | 
				
			||||||
	  .f = window_copy_cmd_scroll_middle
 | 
						  .f = window_copy_cmd_scroll_middle
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{ .command = "scroll-top",
 | 
				
			||||||
 | 
						  .minargs = 0,
 | 
				
			||||||
 | 
						  .maxargs = 0,
 | 
				
			||||||
 | 
						  .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
 | 
				
			||||||
 | 
						  .f = window_copy_cmd_scroll_top
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	{ .command = "scroll-up",
 | 
						{ .command = "scroll-up",
 | 
				
			||||||
	  .minargs = 0,
 | 
						  .minargs = 0,
 | 
				
			||||||
	  .maxargs = 0,
 | 
						  .maxargs = 0,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user