Okay, these diffs have been rebased to before the copy-output-merge
stuff (and to the latest OpenBSD changes), and reworked a bit. They
should be applied in the order: word-separators, then cmd-prefixes.
--
Micah J. Cowan
http://micah.cowan.name/
Index: mode-key.c
===
--- mode-key.c.orig
+++ mode-key.c
@@ -106,6 +106,7 @@ struct mode_key_cmdstr mode_key_cmdstr_c
{ MODEKEYCOPY_SEARCHDOWN, "search-forward" },
{ MODEKEYCOPY_SEARCHREVERSE, "search-reverse" },
{ MODEKEYCOPY_SEARCHUP, "search-backward" },
+ { MODEKEYCOPY_STARTNUMBERPREFIX, "start-number-prefix" },
{ MODEKEYCOPY_STARTOFLINE, "start-of-line" },
{ MODEKEYCOPY_STARTSELECTION, "begin-selection" },
{ MODEKEYCOPY_TOPLINE, "top-line" },
@@ -178,6 +179,15 @@ const struct mode_key_entry mode_key_vi_
{ '$', 0, MODEKEYCOPY_ENDOFLINE },
{ '/', 0, MODEKEYCOPY_SEARCHDOWN },
{ '0', 0, MODEKEYCOPY_STARTOFLINE },
+ { '1', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '2', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '3', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '4', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '5', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '6', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '7', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '8', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '9', 0, MODEKEYCOPY_STARTNUMBERPREFIX },
{ ':', 0, MODEKEYCOPY_GOTOLINE },
{ '?', 0, MODEKEYCOPY_SEARCHUP },
{ 'B', 0, MODEKEYCOPY_PREVIOUSSPACE },
@@ -280,6 +290,15 @@ struct mode_key_tree mode_key_tree_emacs
/* emacs copy mode keys. */
const struct mode_key_entry mode_key_emacs_copy[] = {
{ ' ', 0, MODEKEYCOPY_NEXTPAGE },
+ { '1' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '2' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '3' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '4' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '5' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '6' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '7' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '8' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
+ { '9' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX },
{ '<' | KEYC_ESCAPE,0, MODEKEYCOPY_HISTORYTOP },
{ '>' | KEYC_ESCAPE,0, MODEKEYCOPY_HISTORYBOTTOM },
{ 'R' | KEYC_ESCAPE, 0, MODEKEYCOPY_TOPLINE },
Index: tmux.h
===
--- tmux.h.orig
+++ tmux.h
@@ -476,6 +476,7 @@ enum mode_key_cmd {
MODEKEYCOPY_SEARCHDOWN,
MODEKEYCOPY_SEARCHREVERSE,
MODEKEYCOPY_SEARCHUP,
+ MODEKEYCOPY_STARTNUMBERPREFIX,
MODEKEYCOPY_STARTOFLINE,
MODEKEYCOPY_STARTSELECTION,
MODEKEYCOPY_TOPLINE,
Index: window-copy.c
===
--- window-copy.c.orig
+++ window-copy.c
@@ -28,6 +28,7 @@ void window_copy_free(struct window_pane
void window_copy_resize(struct window_pane *, u_int, u_int);
void window_copy_key(struct window_pane *, struct client *, int);
int window_copy_key_input(struct window_pane *, int);
+int window_copy_key_numeric_prefix(struct window_pane *, int);
void window_copy_mouse(
struct window_pane *, struct client *, struct mouse_event *);
@@ -81,6 +82,7 @@ const struct window_mode window_copy_mod
enum window_copy_input_type {
WINDOW_COPY_OFF,
+ WINDOW_COPY_NUMERICPREFIX,
WINDOW_COPY_SEARCHUP,
WINDOW_COPY_SEARCHDOWN,
WINDOW_COPY_GOTOLINE,
@@ -108,6 +110,8 @@ struct window_copy_mode_data {
const char *inputprompt;
char *inputstr;
+ u_int numprefix;
+
enum window_copy_input_type searchtype;
char *searchstr;
};
@@ -134,6 +138,7 @@ window_copy_init(struct window_pane *wp)
data->inputtype = WINDOW_COPY_OFF;
data->inputprompt = NULL;
data->inputstr = xstrdup("");
+ data->numprefix = 0;
data->searchtype = WINDOW_COPY_OFF;
data->searchstr = NULL;
@@ -222,11 +227,20 @@ window_copy_key(struct window_pane *wp,
const char *word_separators;
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
- u_int n;
+ u_int n, np;
int keys;
enum mode_key_cmd cmd;
- if (data->inputtype != WINDOW_COPY_OFF) {
+ np = data->numprefix;
+ if (np == 0)
+ np = 1;
+
+ if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) {
+ if (window_copy_key_numeric_prefix(wp, key) == 0)
+ return;
+ data->inputtype = WINDOW_COPY_OFF;
+ window_copy_redraw_lines(wp, screen_size_y(s) - 1, 1);
+ } else if (data->inputtype != WINDOW_COPY_OFF) {
if (window_copy_key_input(wp, key) != 0)
goto input_off;
return;
@@ -235,55 +249,69 @@ window_copy_key(struct window_pane *wp,
cmd = mode_key_lookup(&data->mdata, key);
switch (cmd) {
case MODEKEYCOPY_CANCEL:
- window_pane_reset_mode(wp);
+ for (; np != 0; np--)
+ window_pane_reset_mode(wp);
break;
case MODEKEYCOPY_LEFT:
- window_copy_cursor_left(wp);
- return;
+ for (; np != 0; np--)
+ window_copy_cursor_left(wp);
+