-/* $OpenBSD: key-bindings.c,v 1.145 2022/08/15 08:41:13 nicm Exp $ */
+/* $OpenBSD: key-bindings.c,v 1.146 2022/08/23 08:14:19 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
"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 }",
-.\" $OpenBSD: tmux.1,v 1.899 2022/08/15 09:10:34 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.900 2022/08/23 08:14:19 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 15 2022 $
+.Dd $Mdocdate: August 23 2022 $
.Dt TMUX 1
.Os
.Sh NAME
.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 ""
-/* $OpenBSD: window-copy.c,v 1.338 2022/08/03 13:27:48 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.339 2022/08/23 08:14:19 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
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)
{
.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,