summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2011-05-18 18:06:37 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2011-05-18 18:06:37 +0000
commit8f2eeb33edcc8775f8e23ebf5353b5d1d602bc72 (patch)
treee3a7fa04304313f9fbdab135e1579f08bbf3923c /usr.bin
parentf59edd4a5159ecaf0467d98b25966880418c00a2 (diff)
Add three new copy-mode commands - select-line, copy-line,
copy-end-of-line. From Dave Disser and Randy Stauner a while back.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/mode-key.c7
-rw-r--r--usr.bin/tmux/tmux.16
-rw-r--r--usr.bin/tmux/tmux.h5
-rw-r--r--usr.bin/tmux/window-copy.c22
4 files changed, 34 insertions, 6 deletions
diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c
index 1f09d4e5b6b..fd57508fc16 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.37 2011/04/05 18:55:38 nicm Exp $ */
+/* $OpenBSD: mode-key.c,v 1.38 2011/05/18 18:06:36 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -82,6 +82,8 @@ const struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
{ MODEKEYCOPY_BOTTOMLINE, "bottom-line" },
{ MODEKEYCOPY_CANCEL, "cancel" },
{ MODEKEYCOPY_CLEARSELECTION, "clear-selection" },
+ { MODEKEYCOPY_COPYLINE, "copy-line" },
+ { MODEKEYCOPY_COPYENDOFLINE, "copy-end-of-line" },
{ MODEKEYCOPY_COPYSELECTION, "copy-selection" },
{ MODEKEYCOPY_DOWN, "cursor-down" },
{ MODEKEYCOPY_ENDOFLINE, "end-of-line" },
@@ -110,6 +112,7 @@ const struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
{ MODEKEYCOPY_SEARCHDOWN, "search-forward" },
{ MODEKEYCOPY_SEARCHREVERSE, "search-reverse" },
{ MODEKEYCOPY_SEARCHUP, "search-backward" },
+ { MODEKEYCOPY_SELECTLINE, "select-line" },
{ MODEKEYCOPY_STARTNUMBERPREFIX, "start-number-prefix" },
{ MODEKEYCOPY_STARTOFLINE, "start-of-line" },
{ MODEKEYCOPY_STARTSELECTION, "begin-selection" },
@@ -198,6 +201,7 @@ const struct mode_key_entry mode_key_vi_copy[] = {
{ ':', 0, MODEKEYCOPY_GOTOLINE },
{ '?', 0, MODEKEYCOPY_SEARCHUP },
{ 'B', 0, MODEKEYCOPY_PREVIOUSSPACE },
+ { 'D', 0, MODEKEYCOPY_COPYENDOFLINE },
{ 'E', 0, MODEKEYCOPY_NEXTSPACEEND },
{ 'F', 0, MODEKEYCOPY_JUMPBACK },
{ 'G', 0, MODEKEYCOPY_HISTORYBOTTOM },
@@ -323,6 +327,7 @@ const struct mode_key_entry mode_key_emacs_copy[] = {
{ '\005' /* C-e */, 0, MODEKEYCOPY_ENDOFLINE },
{ '\006' /* C-f */, 0, MODEKEYCOPY_RIGHT },
{ '\007' /* C-g */, 0, MODEKEYCOPY_CLEARSELECTION },
+ { '\013' /* C-k */, 0, MODEKEYCOPY_COPYENDOFLINE },
{ '\016' /* C-n */, 0, MODEKEYCOPY_DOWN },
{ '\020' /* C-p */, 0, MODEKEYCOPY_UP },
{ '\022' /* C-r */, 0, MODEKEYCOPY_SEARCHUP },
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 7d0120a28b4..731727752b5 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.226 2011/05/08 20:34:12 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.227 2011/05/18 18:06:36 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: May 8 2011 $
+.Dd $Mdocdate: May 18 2011 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -766,7 +766,7 @@ The following keys are supported as appropriate for the mode:
.It Li "Cursor to top line" Ta "H" Ta "M-R"
.It Li "Cursor up" Ta "k" Ta "Up"
.It Li "Delete entire line" Ta "d" Ta "C-u"
-.It Li "Delete to end of line" Ta "D" Ta "C-k"
+.It Li "Delete/Copy to end of line" Ta "D" Ta "C-k"
.It Li "End of line" Ta "$" Ta "C-e"
.It Li "Go to line" Ta ":" Ta "g"
.It Li "Half page down" Ta "C-d" Ta "M-Down"
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 9db4977b952..8c4fafadff2 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.284 2011/05/08 20:34:12 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.285 2011/05/18 18:06:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -461,6 +461,8 @@ enum mode_key_cmd {
MODEKEYCOPY_BOTTOMLINE,
MODEKEYCOPY_CANCEL,
MODEKEYCOPY_CLEARSELECTION,
+ MODEKEYCOPY_COPYLINE,
+ MODEKEYCOPY_COPYENDOFLINE,
MODEKEYCOPY_COPYSELECTION,
MODEKEYCOPY_DOWN,
MODEKEYCOPY_ENDOFLINE,
@@ -491,6 +493,7 @@ enum mode_key_cmd {
MODEKEYCOPY_SEARCHDOWN,
MODEKEYCOPY_SEARCHREVERSE,
MODEKEYCOPY_SEARCHUP,
+ MODEKEYCOPY_SELECTLINE,
MODEKEYCOPY_STARTNUMBERPREFIX,
MODEKEYCOPY_STARTOFLINE,
MODEKEYCOPY_STARTSELECTION,
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 496750f73c2..26f82505400 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.70 2011/05/18 08:04:47 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.71 2011/05/18 18:06:36 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -500,6 +500,26 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
window_copy_start_selection(wp);
window_copy_redraw_screen(wp);
break;
+ case MODEKEYCOPY_COPYLINE:
+ case MODEKEYCOPY_SELECTLINE:
+ window_copy_cursor_start_of_line(wp);
+ /* FALLTHROUGH */
+ case MODEKEYCOPY_COPYENDOFLINE:
+ window_copy_start_selection(wp);
+ for (; np > 1; np--)
+ window_copy_cursor_down(wp, 0);
+ window_copy_cursor_end_of_line(wp);
+ window_copy_redraw_screen(wp);
+
+ /* If a copy command then copy the selection and exit. */
+ if (sess != NULL &&
+ (cmd == MODEKEYCOPY_COPYLINE ||
+ cmd == MODEKEYCOPY_COPYENDOFLINE)) {
+ window_copy_copy_selection(wp);
+ window_pane_reset_mode(wp);
+ return;
+ }
+ break;
case MODEKEYCOPY_CLEARSELECTION:
window_copy_clear_selection(wp);
window_copy_redraw_screen(wp);