summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-04-27 09:39:10 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-04-27 09:39:10 +0000
commit8bd31522885776f7948ff6c64e9137097ca4cb80 (patch)
tree6d63ff073df6737949352e602ea1888291ec2168
parent4cfd93ac03c7fe5c36c15f7693b4df0aa7ed288f (diff)
Add next/previous paragraph, from J Raynor.
-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.c50
4 files changed, 63 insertions, 5 deletions
diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c
index 1d55a381e0d..a51c282d688 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.67 2016/03/18 07:28:27 nicm Exp $ */
+/* $OpenBSD: mode-key.c,v 1.68 2016/04/27 09:39:09 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -140,12 +140,14 @@ const struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
{ MODEKEYCOPY_RECTANGLETOGGLE, "rectangle-toggle" },
{ MODEKEYCOPY_MIDDLELINE, "middle-line" },
{ MODEKEYCOPY_NEXTPAGE, "page-down" },
+ { MODEKEYCOPY_NEXTPARAGRAPH, "next-paragraph" },
{ MODEKEYCOPY_NEXTSPACE, "next-space" },
{ MODEKEYCOPY_NEXTSPACEEND, "next-space-end" },
{ MODEKEYCOPY_NEXTWORD, "next-word" },
{ MODEKEYCOPY_NEXTWORDEND, "next-word-end" },
{ MODEKEYCOPY_OTHEREND, "other-end" },
{ MODEKEYCOPY_PREVIOUSPAGE, "page-up" },
+ { MODEKEYCOPY_PREVIOUSPARAGRAPH, "previous-paragraph" },
{ MODEKEYCOPY_PREVIOUSSPACE, "previous-space" },
{ MODEKEYCOPY_PREVIOUSWORD, "previous-word" },
{ MODEKEYCOPY_RIGHT, "cursor-right" },
@@ -335,6 +337,8 @@ const struct mode_key_entry mode_key_vi_copy[] = {
{ 'q', 0, MODEKEYCOPY_CANCEL },
{ 'v', 0, MODEKEYCOPY_RECTANGLETOGGLE },
{ 'w', 0, MODEKEYCOPY_NEXTWORD },
+ { '{', 0, MODEKEYCOPY_PREVIOUSPARAGRAPH },
+ { '}', 0, MODEKEYCOPY_NEXTPARAGRAPH },
{ KEYC_BSPACE, 0, MODEKEYCOPY_LEFT },
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN },
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN },
@@ -483,6 +487,8 @@ const struct mode_key_entry mode_key_emacs_copy[] = {
{ 't', 0, MODEKEYCOPY_JUMPTO },
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE },
{ 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION },
+ { '{' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPARAGRAPH },
+ { '}' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTPARAGRAPH },
{ KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN },
{ KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN },
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN },
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index b0595a7821f..446eae31045 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.481 2016/03/18 07:28:27 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.482 2016/04/27 09:39:09 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -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: March 18 2016 $
+.Dd $Mdocdate: April 27 2016 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1025,6 +1025,7 @@ The following keys are supported as appropriate for the mode:
.It Li "Jump to backward" Ta "T" Ta ""
.It Li "Jump to forward" Ta "t" Ta ""
.It Li "Next page" Ta "C-f" Ta "Page down"
+.It Li "Next paragraph" Ta "}" Ta "M-}"
.It Li "Next space" Ta "W" Ta ""
.It Li "Next space, end of word" Ta "E" Ta ""
.It Li "Next word" Ta "w" Ta ""
@@ -1032,6 +1033,7 @@ The following keys are supported as appropriate for the mode:
.It Li "Other end of selection" Ta "o" Ta ""
.It Li "Paste buffer" Ta "p" Ta "C-y"
.It Li "Previous page" Ta "C-b" Ta "Page up"
+.It Li "Previous paragraph" Ta "{" Ta "M-{"
.It Li "Previous space" Ta "B" Ta ""
.It Li "Previous word" Ta "b" Ta "M-b"
.It Li "Quit mode" Ta "q" Ta "Escape"
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 846e5eb4c8e..8b5c09132df 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.623 2016/03/18 07:28:27 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.624 2016/04/27 09:39:09 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -536,12 +536,14 @@ enum mode_key_cmd {
MODEKEYCOPY_LEFT,
MODEKEYCOPY_MIDDLELINE,
MODEKEYCOPY_NEXTPAGE,
+ MODEKEYCOPY_NEXTPARAGRAPH,
MODEKEYCOPY_NEXTSPACE,
MODEKEYCOPY_NEXTSPACEEND,
MODEKEYCOPY_NEXTWORD,
MODEKEYCOPY_NEXTWORDEND,
MODEKEYCOPY_OTHEREND,
MODEKEYCOPY_PREVIOUSPAGE,
+ MODEKEYCOPY_PREVIOUSPARAGRAPH,
MODEKEYCOPY_PREVIOUSSPACE,
MODEKEYCOPY_PREVIOUSWORD,
MODEKEYCOPY_RECTANGLETOGGLE,
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 6a11fa053e2..1f9e4e9af23 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.147 2016/03/18 14:27:24 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.148 2016/04/27 09:39:09 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -27,6 +27,8 @@
struct screen *window_copy_init(struct window_pane *);
void window_copy_free(struct window_pane *);
void window_copy_pagedown(struct window_pane *);
+void window_copy_next_paragraph(struct window_pane *);
+void window_copy_previous_paragraph(struct window_pane *);
void window_copy_resize(struct window_pane *, u_int, u_int);
void window_copy_key(struct window_pane *, struct client *, struct session *,
key_code, struct mouse_event *);
@@ -404,6 +406,44 @@ window_copy_pagedown(struct window_pane *wp)
}
void
+window_copy_previous_paragraph(struct window_pane *wp)
+{
+ struct window_copy_mode_data *data = wp->modedata;
+ u_int ox, oy;
+
+ oy = screen_hsize(data->backing) + data->cy - data->oy;
+ ox = window_copy_find_length(wp, oy);
+
+ while (oy > 0 && window_copy_find_length(wp, oy) == 0)
+ oy--;
+
+ while (oy > 0 && window_copy_find_length(wp, oy) > 0)
+ oy--;
+
+ window_copy_scroll_to(wp, 0, oy);
+}
+
+void
+window_copy_next_paragraph(struct window_pane *wp)
+{
+ struct window_copy_mode_data *data = wp->modedata;
+ struct screen *s = &data->screen;
+ u_int maxy, ox, oy;
+
+ oy = screen_hsize(data->backing) + data->cy - data->oy;
+ maxy = screen_hsize(data->backing) + screen_size_y(s) - 1;
+
+ while (oy < maxy && window_copy_find_length(wp, oy) == 0)
+ oy++;
+
+ while (oy < maxy && window_copy_find_length(wp, oy) > 0)
+ oy++;
+
+ ox = window_copy_find_length(wp, oy);
+ window_copy_scroll_to(wp, ox, oy);
+}
+
+void
window_copy_resize(struct window_pane *wp, u_int sx, u_int sy)
{
struct window_copy_mode_data *data = wp->modedata;
@@ -548,6 +588,14 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
for (; np != 0; np--)
window_copy_pagedown(wp);
break;
+ case MODEKEYCOPY_PREVIOUSPARAGRAPH:
+ for (; np != 0; np--)
+ window_copy_previous_paragraph(wp);
+ break;
+ case MODEKEYCOPY_NEXTPARAGRAPH:
+ for (; np != 0; np--)
+ window_copy_next_paragraph(wp);
+ break;
case MODEKEYCOPY_HALFPAGEUP:
n = screen_size_y(s) / 2;
for (; np != 0; np--) {