Hi List,

Here is the patch for a new wrap-search window flag that controls if
the search should start over the other side of the pane contents when
one end is reached. I have found the need for this while, for example,
looking for failures in test runs and other similar cases.

Not long ago I asked how this could be done in one of stackexchange
question sites[1] and got a patch that simply removed all the wrapping
related code. I thought it would be nicer to have as an option because
sometimes I do want it to wrap.

Default is of course on to avoid surprises :)

Is this ok? did I miss anything? Thanks and regards,

Jacobo de Vera
http://www.jacobodevera.com

[1] http://unix.stackexchange.com/questions/31394/

Index: window-copy.c
===================================================================
--- window-copy.c       (revision 2721)
+++ window-copy.c       (working copy)
@@ -984,11 +984,12 @@
        struct grid_cell                 gc;
        size_t                           searchlen;
        u_int                            i, last, fx, fy, px;
-       int                              utf8flag, n, wrapped;
+       int                              utf8flag, n, wrapped, wrapflag;

        if (*searchstr == '\0')
                return;
        utf8flag = options_get_number(&wp->window->options, "utf8");
+       wrapflag = options_get_number(&wp->window->options, "wrap-search");
        searchlen = screen_write_strlen(utf8flag, "%s", searchstr);

        screen_init(&ss, searchlen, 1, 0);
@@ -1021,7 +1022,7 @@
                        break;
                }
        }
-       if (!n && !wrapped) {
+       if (wrapflag && !n && !wrapped) {
                fx = gd->sx - 1;
                fy = gd->hsize + gd->sy - 1;
                wrapped = 1;
@@ -1041,11 +1042,12 @@
        struct grid_cell                 gc;
        size_t                           searchlen;
        u_int                            i, first, fx, fy, px;
-       int                              utf8flag, n, wrapped;
+       int                              utf8flag, n, wrapped, wrapflag;

        if (*searchstr == '\0')
                return;
        utf8flag = options_get_number(&wp->window->options, "utf8");
+       wrapflag = options_get_number(&wp->window->options, "wrap-search");
        searchlen = screen_write_strlen(utf8flag, "%s", searchstr);

        screen_init(&ss, searchlen, 1, 0);
@@ -1078,7 +1080,7 @@
                        break;
                }
        }
-       if (!n && !wrapped) {
+       if (wrapflag && !n && !wrapped) {
                fx = 0;
                fy = 0;
                wrapped = 1;
Index: options-table.c
===================================================================
--- options-table.c     (revision 2721)
+++ options-table.c     (working copy)
@@ -673,6 +673,11 @@
          .default_num = 0
        },

+       { .name = "wrap-search",
+         .type = OPTIONS_TABLE_FLAG,
+         .default_num = 1
+       },
+
        { .name = NULL }
 };

Index: tmux.1
===================================================================
--- tmux.1      (revision 2721)
+++ tmux.1      (working copy)
@@ -2650,6 +2650,12 @@
 function key sequences; these have a number included to indicate modifiers such
 as Shift, Alt or Ctrl.
 The default is off.
+.Pp
+.It Xo Ic wrap-search
+.Op Ic on | off
+.Xc
+If this option is set, searches will wrap around the end of the pane contents.
+The default is on.
 .El
 .It Xo Ic show-options
 .Op Fl gsw
Index: window-copy.c
===================================================================
--- window-copy.c	(revision 2721)
+++ window-copy.c	(working copy)
@@ -984,11 +984,12 @@
 	struct grid_cell	 	 gc;
 	size_t				 searchlen;
 	u_int				 i, last, fx, fy, px;
-	int				 utf8flag, n, wrapped;
+	int				 utf8flag, n, wrapped, wrapflag;
 
 	if (*searchstr == '\0')
 		return;
 	utf8flag = options_get_number(&wp->window->options, "utf8");
+	wrapflag = options_get_number(&wp->window->options, "wrap-search");
 	searchlen = screen_write_strlen(utf8flag, "%s", searchstr);
 
 	screen_init(&ss, searchlen, 1, 0);
@@ -1021,7 +1022,7 @@
 			break;
 		}
 	}
-	if (!n && !wrapped) {
+	if (wrapflag && !n && !wrapped) {
 		fx = gd->sx - 1;
 		fy = gd->hsize + gd->sy - 1;
 		wrapped = 1;
@@ -1041,11 +1042,12 @@
 	struct grid_cell	 	 gc;
 	size_t				 searchlen;
 	u_int				 i, first, fx, fy, px;
-	int				 utf8flag, n, wrapped;
+	int				 utf8flag, n, wrapped, wrapflag;
 
 	if (*searchstr == '\0')
 		return;
 	utf8flag = options_get_number(&wp->window->options, "utf8");
+	wrapflag = options_get_number(&wp->window->options, "wrap-search");
 	searchlen = screen_write_strlen(utf8flag, "%s", searchstr);
 
 	screen_init(&ss, searchlen, 1, 0);
@@ -1078,7 +1080,7 @@
 			break;
 		}
 	}
-	if (!n && !wrapped) {
+	if (wrapflag && !n && !wrapped) {
 		fx = 0;
 		fy = 0;
 		wrapped = 1;
Index: options-table.c
===================================================================
--- options-table.c	(revision 2721)
+++ options-table.c	(working copy)
@@ -673,6 +673,11 @@
 	  .default_num = 0
 	},
 
+	{ .name = "wrap-search",
+	  .type = OPTIONS_TABLE_FLAG,
+	  .default_num = 1
+	},
+
 	{ .name = NULL }
 };
 
Index: tmux.1
===================================================================
--- tmux.1	(revision 2721)
+++ tmux.1	(working copy)
@@ -2650,6 +2650,12 @@
 function key sequences; these have a number included to indicate modifiers such
 as Shift, Alt or Ctrl.
 The default is off.
+.Pp
+.It Xo Ic wrap-search
+.Op Ic on | off
+.Xc
+If this option is set, searches will wrap around the end of the pane contents.
+The default is on.
 .El
 .It Xo Ic show-options
 .Op Fl gsw
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to