New version of the patch.
Nicholas Marriott wrote:
> Hi
>
> Thanks for the diff,
>
> n retains the sense of the last search (repeats in the same direction), so
> this
> is to reverse the sense of the last search?
>
>> + if ((data->searchtype == WINDOW_COPY_SEARCHUP)
>> + == (cmd == MODEKEYCOPY_SEARCHAGAIN))
>
> This should be &&, I expect.
>
> I think I would rather have a separate if in each case, eg:
>
> case WINDOW_COPY_SEARCHUP:
> if (cmd == MODEKEYCOPY_SEARCHAGAIN)
> window_copy_search_up(wp, data->searchstr);
> else
> window_copy_search_down(wp, data->searchstr);
>
> break;
>
> And similar for WINDOW_COPY_SEARCHDOWN.
--
Micah J. Cowan
http://micah.cowan.name/
Index: mode-key.c
===================================================================
--- mode-key.c.orig
+++ mode-key.c
@@ -104,6 +104,7 @@
{ MODEKEYCOPY_SCROLLUP, "scroll-up" },
{ MODEKEYCOPY_SEARCHAGAIN, "search-again" },
{ MODEKEYCOPY_SEARCHDOWN, "search-forward" },
+ { MODEKEYCOPY_SEARCHREVERSE, "search-reverse" },
{ MODEKEYCOPY_SEARCHUP, "search-backward" },
{ MODEKEYCOPY_STARTOFLINE, "start-of-line" },
{ MODEKEYCOPY_STARTSELECTION, "begin-selection" },
@@ -187,6 +188,7 @@
{ 'K', 0, MODEKEYCOPY_SCROLLUP },
{ 'L', 0, MODEKEYCOPY_BOTTOMLINE },
{ 'M', 0, MODEKEYCOPY_MIDDLELINE },
+ { 'N', 0, MODEKEYCOPY_SEARCHREVERSE },
{ 'W', 0, MODEKEYCOPY_NEXTSPACE },
{ '\002' /* C-b */, 0, MODEKEYCOPY_PREVIOUSPAGE },
{ '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL },
@@ -296,6 +298,7 @@
{ '\026' /* C-v */, 0, MODEKEYCOPY_NEXTPAGE },
{ '\027' /* C-w */, 0, MODEKEYCOPY_COPYSELECTION },
{ '\033' /* Escape */, 0, MODEKEYCOPY_CANCEL },
+ { 'N', 0, MODEKEYCOPY_SEARCHREVERSE },
{ 'b' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSWORD },
{ 'f' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTWORDEND },
{ 'g', 0, MODEKEYCOPY_GOTOLINE },
Index: tmux.h
===================================================================
--- tmux.h.orig
+++ tmux.h
@@ -474,6 +474,7 @@
MODEKEYCOPY_SCROLLUP,
MODEKEYCOPY_SEARCHAGAIN,
MODEKEYCOPY_SEARCHDOWN,
+ MODEKEYCOPY_SEARCHREVERSE,
MODEKEYCOPY_SEARCHUP,
MODEKEYCOPY_STARTOFLINE,
MODEKEYCOPY_STARTSELECTION,
Index: window-copy.c
===================================================================
--- window-copy.c.orig
+++ window-copy.c
@@ -224,6 +224,7 @@
struct screen *s = &data->screen;
u_int n;
int keys;
+ enum mode_key_cmd cmd;
if (data->inputtype != WINDOW_COPY_OFF) {
if (window_copy_key_input(wp, key) != 0)
@@ -231,7 +232,8 @@
return;
}
- switch (mode_key_lookup(&data->mdata, key)) {
+ cmd = mode_key_lookup(&data->mdata, key);
+ switch (cmd) {
case MODEKEYCOPY_CANCEL:
window_pane_reset_mode(wp);
break;
@@ -367,15 +369,22 @@
data->inputprompt = "Search Down";
goto input_on;
case MODEKEYCOPY_SEARCHAGAIN:
+ case MODEKEYCOPY_SEARCHREVERSE:
switch (data->searchtype) {
case WINDOW_COPY_OFF:
case WINDOW_COPY_GOTOLINE:
break;
case WINDOW_COPY_SEARCHUP:
- window_copy_search_up(wp, data->searchstr);
+ if (cmd == MODEKEYCOPY_SEARCHAGAIN)
+ window_copy_search_up(wp, data->searchstr);
+ else
+ window_copy_search_down(wp, data->searchstr);
break;
case WINDOW_COPY_SEARCHDOWN:
- window_copy_search_down(wp, data->searchstr);
+ if (cmd == MODEKEYCOPY_SEARCHAGAIN)
+ window_copy_search_down(wp, data->searchstr);
+ else
+ window_copy_search_up(wp, data->searchstr);
break;
}
break;
Index: tmux.1
===================================================================
--- tmux.1.orig
+++ tmux.1
@@ -572,6 +572,7 @@
.It Li "Scroll down" Ta "C-Down or C-e" Ta "C-Down"
.It Li "Scroll up" Ta "C-Up or C-y" Ta "C-Up"
.It Li "Search again" Ta "n" Ta "n"
+.It Li "Search again in reverse" Ta "N" Ta "N"
.It Li "Search backward" Ta "?" Ta "C-r"
.It Li "Search forward" Ta "/" Ta "C-s"
.It Li "Start of line" Ta "0" Ta "C-a"
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users