summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-10-06 07:09:01 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-10-06 07:09:01 +0000
commitd5a448bb3f07df7581aec4fb1f4ae1d580940f9b (patch)
tree7a2743f840a0c56873c7a12486559956adda2ace
parentac7379e425d74a8cf8688959ad150d72aa1d195b (diff)
Make C-Up and C-Down in copy mode scroll the screen up and down one line
without moving the cursor, like Up and Down in scroll mode (which will shortly disappear).
-rw-r--r--usr.bin/tmux/mode-key.c8
-rw-r--r--usr.bin/tmux/tmux.16
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/window-copy.c40
4 files changed, 39 insertions, 19 deletions
diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c
index c4e431d4753..13bb2399538 100644
--- a/usr.bin/tmux/mode-key.c
+++ b/usr.bin/tmux/mode-key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mode-key.c,v 1.20 2009/10/04 11:18:26 nicm Exp $ */
+/* $OpenBSD: mode-key.c,v 1.21 2009/10/06 07:09:00 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -89,6 +89,8 @@ struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
{ MODEKEYCOPY_PREVIOUSPAGE, "page-up" },
{ MODEKEYCOPY_PREVIOUSWORD, "previous-word" },
{ MODEKEYCOPY_RIGHT, "cursor-right" },
+ { MODEKEYCOPY_SCROLLDOWN, "scroll-down" },
+ { MODEKEYCOPY_SCROLLUP, "scroll-up" },
{ MODEKEYCOPY_SEARCHAGAIN, "search-again" },
{ MODEKEYCOPY_SEARCHDOWN, "search-forward" },
{ MODEKEYCOPY_SEARCHUP, "search-backward" },
@@ -177,11 +179,13 @@ const struct mode_key_entry mode_key_vi_copy[] = {
{ 'q', 0, MODEKEYCOPY_CANCEL },
{ 'w', 0, MODEKEYCOPY_NEXTWORD },
{ KEYC_BSPACE, 0, MODEKEYCOPY_LEFT },
+ { KEYC_DOWN | KEYC_CTRL,0, MODEKEYCOPY_SCROLLDOWN },
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN },
{ KEYC_LEFT, 0, MODEKEYCOPY_LEFT },
{ KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE },
{ KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE },
{ KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT },
+ { KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP },
{ KEYC_UP, 0, MODEKEYCOPY_UP },
{ 0, -1, 0 }
@@ -262,12 +266,14 @@ const struct mode_key_entry mode_key_emacs_copy[] = {
{ 'q', 0, MODEKEYCOPY_CANCEL },
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE },
{ 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION },
+ { KEYC_DOWN | KEYC_CTRL,0, MODEKEYCOPY_SCROLLDOWN },
{ KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN },
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN },
{ KEYC_LEFT, 0, MODEKEYCOPY_LEFT },
{ KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE },
{ KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE },
{ KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT },
+ { KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP },
{ KEYC_UP | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEUP },
{ KEYC_UP, 0, MODEKEYCOPY_UP },
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 328b91a473b..a224fab1c5a 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.95 2009/10/04 11:33:35 jmc Exp $
+.\" $OpenBSD: tmux.1,v 1.96 2009/10/06 07:09:00 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" 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: October 4 2009 $
+.Dd $Mdocdate: October 6 2009 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -515,6 +515,8 @@ The following keys are supported as appropriate for the mode:
.It Li "Previous page" Ta "C-u" Ta "Page up"
.It Li "Previous word" Ta "b" Ta "M-b"
.It Li "Quit mode" Ta "q" Ta "Escape"
+.It Li "Scroll down" Ta "C-Down" Ta "C-Down"
+.It Li "Scroll up" Ta "C-Up" Ta "C-Up"
.It Li "Search again" Ta "n" Ta "n"
.It Li "Search backward" Ta "?" Ta "C-r"
.It Li "Search forward" Ta "/" Ta "C-s"
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 600ff4ce362..4b94b5d2b75 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.119 2009/10/05 18:30:54 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.120 2009/10/06 07:09:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -402,6 +402,8 @@ enum mode_key_cmd {
MODEKEYCOPY_PREVIOUSPAGE,
MODEKEYCOPY_PREVIOUSWORD,
MODEKEYCOPY_RIGHT,
+ MODEKEYCOPY_SCROLLDOWN,
+ MODEKEYCOPY_SCROLLUP,
MODEKEYCOPY_SEARCHAGAIN,
MODEKEYCOPY_SEARCHDOWN,
MODEKEYCOPY_SEARCHUP,
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index ec0a5966ef2..00223e5142a 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.27 2009/09/10 17:16:24 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.28 2009/10/06 07:09:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -61,8 +61,8 @@ void window_copy_cursor_back_to_indentation(struct window_pane *);
void window_copy_cursor_end_of_line(struct window_pane *);
void window_copy_cursor_left(struct window_pane *);
void window_copy_cursor_right(struct window_pane *);
-void window_copy_cursor_up(struct window_pane *);
-void window_copy_cursor_down(struct window_pane *);
+void window_copy_cursor_up(struct window_pane *, int);
+void window_copy_cursor_down(struct window_pane *, int);
void window_copy_cursor_next_word(struct window_pane *);
void window_copy_cursor_previous_word(struct window_pane *);
void window_copy_scroll_up(struct window_pane *, u_int);
@@ -235,11 +235,17 @@ window_copy_key(struct window_pane *wp, struct client *c, int key)
window_copy_cursor_right(wp);
return;
case MODEKEYCOPY_UP:
- window_copy_cursor_up(wp);
+ window_copy_cursor_up(wp, 0);
return;
case MODEKEYCOPY_DOWN:
- window_copy_cursor_down(wp);
+ window_copy_cursor_down(wp, 0);
return;
+ case MODEKEYCOPY_SCROLLUP:
+ window_copy_cursor_up(wp, 1);
+ break;
+ case MODEKEYCOPY_SCROLLDOWN:
+ window_copy_cursor_down(wp, 1);
+ break;
case MODEKEYCOPY_PREVIOUSPAGE:
window_copy_pageup(wp);
break;
@@ -1020,7 +1026,7 @@ window_copy_cursor_left(struct window_pane *wp)
struct window_copy_mode_data *data = wp->modedata;
if (data->cx == 0) {
- window_copy_cursor_up(wp);
+ window_copy_cursor_up(wp, 0);
window_copy_cursor_end_of_line(wp);
} else {
window_copy_update_cursor(wp, data->cx - 1, data->cy);
@@ -1040,7 +1046,7 @@ window_copy_cursor_right(struct window_pane *wp)
if (data->cx >= px) {
window_copy_cursor_start_of_line(wp);
- window_copy_cursor_down(wp);
+ window_copy_cursor_down(wp, 0);
} else {
window_copy_update_cursor(wp, data->cx + 1, data->cy);
if (window_copy_update_selection(wp))
@@ -1049,7 +1055,7 @@ window_copy_cursor_right(struct window_pane *wp)
}
void
-window_copy_cursor_up(struct window_pane *wp)
+window_copy_cursor_up(struct window_pane *wp, int scroll_only)
{
struct window_copy_mode_data *data = wp->modedata;
u_int ox, oy, px, py;
@@ -1062,9 +1068,11 @@ window_copy_cursor_up(struct window_pane *wp)
}
data->cx = data->lastcx;
- if (data->cy == 0)
+ if (scroll_only || data->cy == 0) {
window_copy_scroll_down(wp, 1);
- else {
+ if (scroll_only && window_copy_update_selection(wp))
+ window_copy_redraw_lines(wp, data->cy, 2);
+ } else {
window_copy_update_cursor(wp, data->cx, data->cy - 1);
if (window_copy_update_selection(wp))
window_copy_redraw_lines(wp, data->cy, 2);
@@ -1077,7 +1085,7 @@ window_copy_cursor_up(struct window_pane *wp)
}
void
-window_copy_cursor_down(struct window_pane *wp)
+window_copy_cursor_down(struct window_pane *wp, int scroll_only)
{
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
@@ -1091,9 +1099,11 @@ window_copy_cursor_down(struct window_pane *wp)
}
data->cx = data->lastcx;
- if (data->cy == screen_size_y(s) - 1)
+ if (scroll_only || data->cy == screen_size_y(s) - 1) {
window_copy_scroll_up(wp, 1);
- else {
+ if (scroll_only && window_copy_update_selection(wp))
+ window_copy_redraw_lines(wp, data->cy - 1, 2);
+ } else {
window_copy_update_cursor(wp, data->cx, data->cy + 1);
if (window_copy_update_selection(wp))
window_copy_redraw_lines(wp, data->cy - 1, 2);
@@ -1137,7 +1147,7 @@ window_copy_cursor_next_word(struct window_pane *wp)
}
px = 0;
- window_copy_cursor_down(wp);
+ window_copy_cursor_down(wp, 0);
py =screen_hsize(
&wp->base) + data->cy - data->oy;
@@ -1185,7 +1195,7 @@ window_copy_cursor_previous_word(struct window_pane *wp)
(screen_hsize(&wp->base) == 0 ||
data->oy >= screen_hsize(&wp->base) - 1))
goto out;
- window_copy_cursor_up(wp);
+ window_copy_cursor_up(wp, 0);
py = screen_hsize(
&wp->base) + data->cy - data->oy;