mirror of
https://github.com/tmux/tmux.git
synced 2024-12-24 01:58:46 +00:00
Add scroll-middle copy mode command to make cursor line in the middle,
from Varun Kumar E in GitHub issue 3307.
This commit is contained in:
parent
7c2dcd7238
commit
416c27c995
@ -605,6 +605,7 @@ key_bindings_init(void)
|
||||
"bind -Tcopy-mode-vi h { send -X cursor-left }",
|
||||
"bind -Tcopy-mode-vi j { send -X cursor-down }",
|
||||
"bind -Tcopy-mode-vi k { send -X cursor-up }",
|
||||
"bind -Tcopy-mode-vi z { send -X scroll-middle }",
|
||||
"bind -Tcopy-mode-vi l { send -X cursor-right }",
|
||||
"bind -Tcopy-mode-vi n { send -X search-again }",
|
||||
"bind -Tcopy-mode-vi o { send -X other-end }",
|
||||
|
1
tmux.1
1
tmux.1
@ -1808,6 +1808,7 @@ The following commands are supported in copy mode:
|
||||
.It Li "search-forward <for>" Ta "/" Ta ""
|
||||
.It Li "search-forward-incremental <for>" Ta "" Ta "C-s"
|
||||
.It Li "search-forward-text <for>" Ta "" Ta ""
|
||||
.It Li "scroll-middle" Ta "z" Ta ""
|
||||
.It Li "search-reverse" Ta "N" Ta "N"
|
||||
.It Li "select-line" Ta "V" Ta ""
|
||||
.It Li "select-word" Ta "" Ta ""
|
||||
|
@ -1250,6 +1250,32 @@ window_copy_cmd_cursor_right(struct window_copy_cmd_state *cs)
|
||||
return (WINDOW_COPY_CMD_NOTHING);
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_scroll_middle(struct window_copy_cmd_state *cs)
|
||||
{
|
||||
struct window_mode_entry *wme = cs->wme;
|
||||
struct window_copy_mode_data *data = wme->data;
|
||||
u_int mid_value, oy, delta;
|
||||
int scroll_up; /* >0 up, <0 down */
|
||||
|
||||
mid_value = (screen_size_y(&data->screen) - 1) / 2;
|
||||
scroll_up = data->cy - mid_value;
|
||||
delta = abs(scroll_up);
|
||||
oy = screen_hsize(data->backing) + data->cy - data->oy;
|
||||
|
||||
log_debug ("XXX %u %u %u %d %u", mid_value, oy, delta, scroll_up, data->oy);
|
||||
if (scroll_up > 0 && data->oy >= delta) {
|
||||
window_copy_scroll_up(wme, delta);
|
||||
data->cy -= delta;
|
||||
} else if (scroll_up < 0 && oy >= delta) {
|
||||
window_copy_scroll_down(wme, delta);
|
||||
data->cy += delta;
|
||||
}
|
||||
|
||||
window_copy_update_selection(wme, 0, 0);
|
||||
return (WINDOW_COPY_CMD_REDRAW);
|
||||
}
|
||||
|
||||
static enum window_copy_cmd_action
|
||||
window_copy_cmd_cursor_up(struct window_copy_cmd_state *cs)
|
||||
{
|
||||
@ -2780,6 +2806,12 @@ static const struct {
|
||||
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
|
||||
.f = window_copy_cmd_scroll_down_and_cancel
|
||||
},
|
||||
{ .command = "scroll-middle",
|
||||
.minargs = 0,
|
||||
.maxargs = 0,
|
||||
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
|
||||
.f = window_copy_cmd_scroll_middle
|
||||
},
|
||||
{ .command = "scroll-up",
|
||||
.minargs = 0,
|
||||
.maxargs = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user