mirror of
https://github.com/tmux/tmux.git
synced 2025-11-01 15:06:06 +00:00
Add commands to centre the cursor in copy mode, from m-einfalt at gmx
dot de in GitHub issue 4662.
This commit is contained in:
@@ -493,6 +493,8 @@ key_bindings_init(void)
|
|||||||
"bind -Tcopy-mode C-b { send -X cursor-left }",
|
"bind -Tcopy-mode C-b { send -X cursor-left }",
|
||||||
"bind -Tcopy-mode C-g { send -X clear-selection }",
|
"bind -Tcopy-mode C-g { send -X clear-selection }",
|
||||||
"bind -Tcopy-mode C-k { send -X copy-pipe-end-of-line-and-cancel }",
|
"bind -Tcopy-mode C-k { send -X copy-pipe-end-of-line-and-cancel }",
|
||||||
|
"bind -Tcopy-mode C-l { send -X cursor-centre-vertical }",
|
||||||
|
"bind -Tcopy-mode M-l { send -X cursor-centre-horizontal }",
|
||||||
"bind -Tcopy-mode C-n { send -X cursor-down }",
|
"bind -Tcopy-mode C-n { send -X cursor-down }",
|
||||||
"bind -Tcopy-mode C-p { send -X cursor-up }",
|
"bind -Tcopy-mode C-p { send -X cursor-up }",
|
||||||
"bind -Tcopy-mode C-r { command-prompt -T search -ip'(search up)' -I'#{pane_search_string}' { send -X search-backward-incremental -- '%%' } }",
|
"bind -Tcopy-mode C-r { command-prompt -T search -ip'(search up)' -I'#{pane_search_string}' { send -X search-backward-incremental -- '%%' } }",
|
||||||
|
|||||||
10
tmux.1
10
tmux.1
@@ -1951,6 +1951,16 @@ Move the cursor right.
|
|||||||
.Xc
|
.Xc
|
||||||
Move the cursor up.
|
Move the cursor up.
|
||||||
.It Xo
|
.It Xo
|
||||||
|
.Ic cursor-centre-vertical
|
||||||
|
(emacs: C-l)
|
||||||
|
.Xc
|
||||||
|
Moves the cursor to the vertical centre of the pane.
|
||||||
|
.It Xo
|
||||||
|
.Ic cursor-centre-horizontal
|
||||||
|
(emacs: M-l)
|
||||||
|
.Xc
|
||||||
|
Moves the cursor to the horizontal centre of the pane.
|
||||||
|
.It Xo
|
||||||
.Ic end-of-line
|
.Ic end-of-line
|
||||||
(vi: $)
|
(vi: $)
|
||||||
(emacs: C-e)
|
(emacs: C-e)
|
||||||
|
|||||||
@@ -1497,6 +1497,28 @@ window_copy_cmd_cursor_up(struct window_copy_cmd_state *cs)
|
|||||||
return (WINDOW_COPY_CMD_NOTHING);
|
return (WINDOW_COPY_CMD_NOTHING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum window_copy_cmd_action
|
||||||
|
window_copy_cmd_centre_vertical(struct window_copy_cmd_state *cs)
|
||||||
|
{
|
||||||
|
struct window_mode_entry *wme = cs->wme;
|
||||||
|
struct window_copy_mode_data *data = wme->data;
|
||||||
|
|
||||||
|
window_copy_update_cursor(wme, data->cx, wme->wp->sy / 2);
|
||||||
|
window_copy_update_selection(wme, 1, 0);
|
||||||
|
return (WINDOW_COPY_CMD_REDRAW);
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum window_copy_cmd_action
|
||||||
|
window_copy_cmd_centre_horizontal(struct window_copy_cmd_state *cs)
|
||||||
|
{
|
||||||
|
struct window_mode_entry *wme = cs->wme;
|
||||||
|
struct window_copy_mode_data *data = wme->data;
|
||||||
|
|
||||||
|
window_copy_update_cursor(wme, wme->wp->sx / 2, data->cy);
|
||||||
|
window_copy_update_selection(wme, 1, 0);
|
||||||
|
return (WINDOW_COPY_CMD_REDRAW);
|
||||||
|
}
|
||||||
|
|
||||||
static enum window_copy_cmd_action
|
static enum window_copy_cmd_action
|
||||||
window_copy_cmd_end_of_line(struct window_copy_cmd_state *cs)
|
window_copy_cmd_end_of_line(struct window_copy_cmd_state *cs)
|
||||||
{
|
{
|
||||||
@@ -2785,6 +2807,16 @@ static const struct {
|
|||||||
.clear = WINDOW_COPY_CMD_CLEAR_EMACS_ONLY,
|
.clear = WINDOW_COPY_CMD_CLEAR_EMACS_ONLY,
|
||||||
.f = window_copy_cmd_cursor_up
|
.f = window_copy_cmd_cursor_up
|
||||||
},
|
},
|
||||||
|
{ .command = "cursor-centre-vertical",
|
||||||
|
.args = { "", 0, 0, NULL },
|
||||||
|
.clear = WINDOW_COPY_CMD_CLEAR_EMACS_ONLY,
|
||||||
|
.f = window_copy_cmd_centre_vertical,
|
||||||
|
},
|
||||||
|
{ .command = "cursor-centre-horizontal",
|
||||||
|
.args = { "", 0, 0, NULL },
|
||||||
|
.clear = WINDOW_COPY_CMD_CLEAR_EMACS_ONLY,
|
||||||
|
.f = window_copy_cmd_centre_horizontal,
|
||||||
|
},
|
||||||
{ .command = "end-of-line",
|
{ .command = "end-of-line",
|
||||||
.args = { "", 0, 0, NULL },
|
.args = { "", 0, 0, NULL },
|
||||||
.clear = WINDOW_COPY_CMD_CLEAR_EMACS_ONLY,
|
.clear = WINDOW_COPY_CMD_CLEAR_EMACS_ONLY,
|
||||||
|
|||||||
Reference in New Issue
Block a user