summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-07-12 16:15:35 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-07-12 16:15:35 +0000
commitc364a2e66a6ad8a24597aec99363087a84b466c9 (patch)
tree7360b2e316001994a930c83d1ee2042888084588 /usr.bin
parentcce3b6f7896fd45d90f7eeefeedd71e28daabea9 (diff)
Add a "back to indentation" key in copy mode to move the cursor to the first
non-whitespace character. ^ with vi and M-m with emacs key bindings. Another from Kalle Olavi Niemitalo, thanks.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/mode-key.c7
-rw-r--r--usr.bin/tmux/status.c3
-rw-r--r--usr.bin/tmux/tmux.15
-rw-r--r--usr.bin/tmux/tmux.h3
-rw-r--r--usr.bin/tmux/window-copy.c33
5 files changed, 44 insertions, 7 deletions
diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c
index e89e52d5572..79c3a473c50 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.1 2009/06/01 22:58:49 nicm Exp $ */
+/* $OpenBSD: mode-key.c,v 1.2 2009/07/12 16:15:34 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -105,8 +105,9 @@ mode_key_lookup_vi(struct mode_key_data *mdata, int key)
return (MODEKEYCMD_CHOOSE);
return (MODEKEYCMD_COPYSELECTION);
case '0':
- case '^':
return (MODEKEYCMD_STARTOFLINE);
+ case '^':
+ return (MODEKEYCMD_BACKTOINDENTATION);
case '\033':
return (MODEKEYCMD_CLEARSELECTION);
case 'j':
@@ -160,6 +161,8 @@ mode_key_lookup_emacs(struct mode_key_data *mdata, int key)
return (MODEKEYCMD_CHOOSE);
case '\001':
return (MODEKEYCMD_STARTOFLINE);
+ case KEYC_ADDESC('m'):
+ return (MODEKEYCMD_BACKTOINDENTATION);
case '\007':
return (MODEKEYCMD_CLEARSELECTION);
case '\027':
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index ab57738aec4..6f6f5a2320d 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.5 2009/06/26 15:13:39 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.6 2009/07/12 16:15:34 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -709,6 +709,7 @@ status_prompt_key(struct client *c, int key)
}
break;
case MODEKEYCMD_STARTOFLINE:
+ case MODEKEYCMD_BACKTOINDENTATION:
if (c->prompt_index != 0) {
c->prompt_index = 0;
c->flags |= CLIENT_STATUS;
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index d0824c74bb3..0c5c70108d8 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.26 2009/07/12 16:07:56 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.27 2009/07/12 16:15:34 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -306,7 +306,8 @@ option).
The following keys are supported as appropriate for the mode:
.Bl -column "FunctionXXXXXXXXXXXX" "viXXXXXX" "emacs" -offset indent
.It Sy "Function" Ta Sy "vi" Ta Sy "emacs"
-.It Li "Start of line" Ta "0 or ^" Ta "C-a"
+.It Li "Start of line" Ta "0" Ta "C-a"
+.It Li "Back to indentation" Ta "^" Ta "M-m"
.It Li "Clear selection" Ta "Escape" Ta "C-g"
.It Li "Copy selection" Ta "Enter" Ta "M-w"
.It Li "Cursor down" Ta "j" Ta "Down"
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index c1703c8f6fc..0350b834c66 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.22 2009/07/12 16:07:56 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.23 2009/07/12 16:15:34 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -357,6 +357,7 @@ struct msg_resize_data {
/* Editing keys. */
enum mode_key_cmd {
MODEKEYCMD_BACKSPACE = 0x1000,
+ MODEKEYCMD_BACKTOINDENTATION,
MODEKEYCMD_CHOOSE,
MODEKEYCMD_CLEARSELECTION,
MODEKEYCMD_COMPLETE,
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 115a8a2b1cc..f9afc385b44 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.5 2009/07/12 16:12:34 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.6 2009/07/12 16:15:34 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -50,6 +50,7 @@ int window_copy_is_space(struct window_pane *, u_int, u_int);
u_int window_copy_find_length(struct window_pane *, u_int);
void window_copy_set_cursor_x(struct window_pane *, u_int);
void window_copy_cursor_start_of_line(struct window_pane *);
+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 *);
@@ -207,6 +208,9 @@ window_copy_key(struct window_pane *wp, struct client *c, int key)
case MODEKEYCMD_STARTOFLINE:
window_copy_cursor_start_of_line(wp);
break;
+ case MODEKEYCMD_BACKTOINDENTATION:
+ window_copy_cursor_back_to_indentation(wp);
+ break;
case MODEKEYCMD_ENDOFLINE:
window_copy_cursor_end_of_line(wp);
break;
@@ -601,6 +605,33 @@ window_copy_cursor_start_of_line(struct window_pane *wp)
}
void
+window_copy_cursor_back_to_indentation(struct window_pane *wp)
+{
+ struct window_copy_mode_data *data = wp->modedata;
+ u_int px, py, xx;
+ const struct grid_cell *gc;
+
+ px = 0;
+ py = screen_hsize(&wp->base) + data->cy - data->oy;
+ xx = window_copy_find_length(wp, py);
+
+ /*
+ * Don't use window_copy_is_space because that treats some word
+ * delimiters as spaces.
+ */
+ while (px < xx) {
+ gc = grid_peek_cell(wp->base.grid, px, py);
+ if (gc->flags & GRID_FLAG_UTF8)
+ break;
+ if (gc->data != ' ')
+ break;
+ px++;
+ }
+
+ window_copy_set_cursor_x(wp, px);
+}
+
+void
window_copy_cursor_end_of_line(struct window_pane *wp)
{
struct window_copy_mode_data *data = wp->modedata;