[BACK]Return to window-copy.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/window-copy.c between version 1.295 and 1.296

version 1.295, 2020/06/04 10:24:14 version 1.296, 2020/06/04 20:41:57
Line 52 
Line 52 
 static void     window_copy_write_lines(struct window_mode_entry *,  static void     window_copy_write_lines(struct window_mode_entry *,
                     struct screen_write_ctx *, u_int, u_int);                      struct screen_write_ctx *, u_int, u_int);
   
 static void     window_copy_scroll_to(struct window_mode_entry *, u_int, u_int);  static void     window_copy_scroll_to(struct window_mode_entry *, u_int, u_int,
                       int);
 static int      window_copy_search_compare(struct grid *, u_int, u_int,  static int      window_copy_search_compare(struct grid *, u_int, u_int,
                     struct grid *, u_int, int);                      struct grid *, u_int, int);
 static int      window_copy_search_lr(struct grid *, struct grid *, u_int *,  static int      window_copy_search_lr(struct grid *, struct grid *, u_int *,
Line 67 
Line 68 
 static void     window_copy_cstrtocellpos(struct grid *, u_int, u_int *, u_int *,  static void     window_copy_cstrtocellpos(struct grid *, u_int, u_int *, u_int *,
                     const char *str);                      const char *str);
 static int      window_copy_search_marks(struct window_mode_entry *,  static int      window_copy_search_marks(struct window_mode_entry *,
                     struct screen *, int);                      struct screen *, int, int);
 static void     window_copy_clear_marks(struct window_mode_entry *);  static void     window_copy_clear_marks(struct window_mode_entry *);
 static void     window_copy_move_left(struct screen *, u_int *, u_int *, int);  static void     window_copy_move_left(struct screen *, u_int *, u_int *, int);
 static void     window_copy_move_right(struct screen *, u_int *, u_int *, int);  static void     window_copy_move_right(struct screen *, u_int *, u_int *, int);
Line 265 
Line 266 
         u_int            my;          u_int            my;
         int              showmark;          int              showmark;
   
           uint64_t         searchtime;
         int              searchtype;          int              searchtype;
         int              searchregex;          int              searchregex;
         char            *searchstr;          char            *searchstr;
Line 280 
Line 282 
         int              timeout;       /* search has timed out */          int              timeout;       /* search has timed out */
 #define WINDOW_COPY_SEARCH_TIMEOUT 10000  #define WINDOW_COPY_SEARCH_TIMEOUT 10000
 #define WINDOW_COPY_SEARCH_ALL_TIMEOUT 200  #define WINDOW_COPY_SEARCH_ALL_TIMEOUT 200
   #define WINDOW_COPY_SEARCH_REPEAT 50
   
         int              jumptype;          int              jumptype;
         char             jumpchar;          char             jumpchar;
Line 588 
Line 591 
         }          }
   
         if (data->searchmark != NULL && !data->timeout)          if (data->searchmark != NULL && !data->timeout)
                 window_copy_search_marks(wme, NULL, data->searchregex);                  window_copy_search_marks(wme, NULL, data->searchregex, 1);
         window_copy_update_selection(wme, 1, 0);          window_copy_update_selection(wme, 1, 0);
         window_copy_redraw_screen(wme);          window_copy_redraw_screen(wme);
 }  }
Line 638 
Line 641 
         if (scroll_exit && data->oy == 0)          if (scroll_exit && data->oy == 0)
                 return (1);                  return (1);
         if (data->searchmark != NULL && !data->timeout)          if (data->searchmark != NULL && !data->timeout)
                 window_copy_search_marks(wme, NULL, data->searchregex);                  window_copy_search_marks(wme, NULL, data->searchregex, 1);
         window_copy_update_selection(wme, 1, 0);          window_copy_update_selection(wme, 1, 0);
         window_copy_redraw_screen(wme);          window_copy_redraw_screen(wme);
         return (0);          return (0);
Line 658 
Line 661 
         while (oy > 0 && window_copy_find_length(wme, oy) > 0)          while (oy > 0 && window_copy_find_length(wme, oy) > 0)
                 oy--;                  oy--;
   
         window_copy_scroll_to(wme, 0, oy);          window_copy_scroll_to(wme, 0, oy, 0);
 }  }
   
 static void  static void
Line 678 
Line 681 
                 oy++;                  oy++;
   
         ox = window_copy_find_length(wme, oy);          ox = window_copy_find_length(wme, oy);
         window_copy_scroll_to(wme, ox, oy);          window_copy_scroll_to(wme, ox, oy, 0);
 }  }
   
 char *  char *
Line 754 
Line 757 
         screen_write_stop(&ctx);          screen_write_stop(&ctx);
   
         if (search && !data->timeout)          if (search && !data->timeout)
                 window_copy_search_marks(wme, NULL, data->searchregex);                  window_copy_search_marks(wme, NULL, data->searchregex, 0);
         data->searchx = data->cx;          data->searchx = data->cx;
         data->searchy = data->cy;          data->searchy = data->cy;
         data->searcho = data->oy;          data->searcho = data->oy;
Line 1150 
Line 1153 
         data->oy = 0;          data->oy = 0;
   
         if (data->searchmark != NULL && !data->timeout)          if (data->searchmark != NULL && !data->timeout)
                 window_copy_search_marks(wme, NULL, data->searchregex);                  window_copy_search_marks(wme, NULL, data->searchregex, 1);
         window_copy_update_selection(wme, 1, 0);          window_copy_update_selection(wme, 1, 0);
         return (WINDOW_COPY_CMD_REDRAW);          return (WINDOW_COPY_CMD_REDRAW);
 }  }
Line 1171 
Line 1174 
         data->oy = screen_hsize(data->backing);          data->oy = screen_hsize(data->backing);
   
         if (data->searchmark != NULL && !data->timeout)          if (data->searchmark != NULL && !data->timeout)
                 window_copy_search_marks(wme, NULL, data->searchregex);                  window_copy_search_marks(wme, NULL, data->searchregex, 1);
         window_copy_update_selection(wme, 1, 0);          window_copy_update_selection(wme, 1, 0);
         return (WINDOW_COPY_CMD_REDRAW);          return (WINDOW_COPY_CMD_REDRAW);
 }  }
Line 1325 
Line 1328 
   
                 /* Move the cursor to the found location if any. */                  /* Move the cursor to the found location if any. */
                 if (!failed)                  if (!failed)
                         window_copy_scroll_to(wme, px, py);                          window_copy_scroll_to(wme, px, py, 0);
         }          }
   
         return (WINDOW_COPY_CMD_NOTHING);          return (WINDOW_COPY_CMD_NOTHING);
Line 1376 
Line 1379 
                                 sx = data->cx;                                  sx = data->cx;
                                 sy = screen_hsize(s) + data->cy - data->oy;                                  sy = screen_hsize(s) + data->cy - data->oy;
   
                                 window_copy_scroll_to(wme, px, py);                                  window_copy_scroll_to(wme, px, py, 0);
                                 window_copy_cmd_previous_matching_bracket(cs);                                  window_copy_cmd_previous_matching_bracket(cs);
   
                                 px = data->cx;                                  px = data->cx;
Line 1385 
Line 1388 
                                 if (gc.data.size == 1 &&                                  if (gc.data.size == 1 &&
                                     (~gc.flags & GRID_FLAG_PADDING) &&                                      (~gc.flags & GRID_FLAG_PADDING) &&
                                     strchr(close, *gc.data.data) != NULL)                                      strchr(close, *gc.data.data) != NULL)
                                         window_copy_scroll_to(wme, sx, sy);                                          window_copy_scroll_to(wme, sx, sy, 0);
                                 break;                                  break;
                         }                          }
   
Line 1447 
Line 1450 
   
                 /* Move the cursor to the found location if any. */                  /* Move the cursor to the found location if any. */
                 if (!failed)                  if (!failed)
                         window_copy_scroll_to(wme, px, py);                          window_copy_scroll_to(wme, px, py, 0);
         }          }
   
         return (WINDOW_COPY_CMD_NOTHING);          return (WINDOW_COPY_CMD_NOTHING);
Line 1659 
Line 1662 
         struct window_copy_mode_data    *data = wme->data;          struct window_copy_mode_data    *data = wme->data;
         u_int                            np = wme->prefix;          u_int                            np = wme->prefix;
   
           if (data->searchtime != 0 &&
               get_timer() - data->searchtime < WINDOW_COPY_SEARCH_REPEAT)
                   return (WINDOW_COPY_CMD_NOTHING);
   
         if (data->searchtype == WINDOW_COPY_SEARCHUP) {          if (data->searchtype == WINDOW_COPY_SEARCHUP) {
                 for (; np != 0; np--)                  for (; np != 0; np--)
                         window_copy_search_up(wme, data->searchregex);                          window_copy_search_up(wme, data->searchregex);
Line 1666 
Line 1673 
                 for (; np != 0; np--)                  for (; np != 0; np--)
                         window_copy_search_down(wme, data->searchregex);                          window_copy_search_down(wme, data->searchregex);
         }          }
           data->searchtime = get_timer();
         return (WINDOW_COPY_CMD_NOTHING);          return (WINDOW_COPY_CMD_NOTHING);
 }  }
   
Line 1676 
Line 1684 
         struct window_copy_mode_data    *data = wme->data;          struct window_copy_mode_data    *data = wme->data;
         u_int                            np = wme->prefix;          u_int                            np = wme->prefix;
   
           if (data->searchtime != 0 &&
               get_timer() - data->searchtime < WINDOW_COPY_SEARCH_REPEAT)
                   return (WINDOW_COPY_CMD_NOTHING);
   
         if (data->searchtype == WINDOW_COPY_SEARCHUP) {          if (data->searchtype == WINDOW_COPY_SEARCHUP) {
                 for (; np != 0; np--)                  for (; np != 0; np--)
                         window_copy_search_down(wme, data->searchregex);                          window_copy_search_down(wme, data->searchregex);
Line 1683 
Line 1695 
                 for (; np != 0; np--)                  for (; np != 0; np--)
                         window_copy_search_up(wme, data->searchregex);                          window_copy_search_up(wme, data->searchregex);
         }          }
           data->searchtime = get_timer();
         return (WINDOW_COPY_CMD_NOTHING);          return (WINDOW_COPY_CMD_NOTHING);
 }  }
   
Line 2327 
Line 2340 
 }  }
   
 static void  static void
 window_copy_scroll_to(struct window_mode_entry *wme, u_int px, u_int py)  window_copy_scroll_to(struct window_mode_entry *wme, u_int px, u_int py,
       int no_redraw)
 {  {
         struct window_copy_mode_data    *data = wme->data;          struct window_copy_mode_data    *data = wme->data;
         struct grid                     *gd = data->backing->grid;          struct grid                     *gd = data->backing->grid;
Line 2352 
Line 2366 
                 data->oy = gd->hsize - offset;                  data->oy = gd->hsize - offset;
         }          }
   
         if (data->searchmark != NULL && !data->timeout)          if (!no_redraw && data->searchmark != NULL && !data->timeout)
                 window_copy_search_marks(wme, NULL, data->searchregex);                  window_copy_search_marks(wme, NULL, data->searchregex, 1);
         window_copy_update_selection(wme, 1, 0);          window_copy_update_selection(wme, 1, 0);
         window_copy_redraw_screen(wme);          if (!no_redraw)
                   window_copy_redraw_screen(wme);
 }  }
   
 static int  static int
Line 2877 
Line 2892 
         }          }
   
         if (found) {          if (found) {
                 window_copy_scroll_to(wme, px, i);                  window_copy_scroll_to(wme, px, i, 1);
                 return (1);                  return (1);
         }          }
         if (wrap) {          if (wrap) {
Line 2903 
Line 2918 
         struct grid                     *gd = s->grid;          struct grid                     *gd = s->grid;
         const char                      *str = data->searchstr;          const char                      *str = data->searchstr;
         u_int                            fx, fy, endline;          u_int                            fx, fy, endline;
         int                              wrapflag, cis, found;          int                              wrapflag, cis, found, visible_only;
   
         if (regex && str[strcspn(str, "^$*+()?[].\\")] == '\0')          if (regex && str[strcspn(str, "^$*+()?[].\\")] == '\0')
                 regex = 0;                  regex = 0;
Line 2911 
Line 2926 
         if (data->timeout)          if (data->timeout)
                 return (0);                  return (0);
   
           if (wp->searchstr == NULL || wp->searchregex != regex)
                   visible_only = 0;
           else
                   visible_only = (strcmp(wp->searchstr, str) == 0);
         free(wp->searchstr);          free(wp->searchstr);
         wp->searchstr = xstrdup(str);          wp->searchstr = xstrdup(str);
         wp->searchregex = regex;          wp->searchregex = regex;
Line 2936 
Line 2955 
   
         found = window_copy_search_jump(wme, gd, ss.grid, fx, fy, endline, cis,          found = window_copy_search_jump(wme, gd, ss.grid, fx, fy, endline, cis,
             wrapflag, direction, regex);              wrapflag, direction, regex);
           if (found)
                   window_copy_search_marks(wme, &ss, regex, visible_only);
           window_copy_redraw_screen(wme);
   
         if (window_copy_search_marks(wme, &ss, regex))  
                 window_copy_redraw_screen(wme);  
   
         screen_free(&ss);          screen_free(&ss);
         return (found);          return (found);
 }  }
   
   static void
   window_copy_visible_lines(struct window_copy_mode_data *data, u_int *start,
       u_int *end)
   {
           struct grid             *gd = data->backing->grid;
           const struct grid_line  *gl;
   
           for (*start = gd->hsize - data->oy; *start > 0; (*start)--) {
                   gl = grid_peek_line(gd, (*start) - 1);
                   if (~gl->flags & GRID_LINE_WRAPPED)
                           break;
           }
           *end = gd->hsize - data->oy + gd->sy;
   }
   
 static int  static int
 window_copy_search_marks(struct window_mode_entry *wme, struct screen *ssp,  window_copy_search_marks(struct window_mode_entry *wme, struct screen *ssp,
     int regex)      int regex, int visible_only)
 {  {
         struct window_copy_mode_data    *data = wme->data;          struct window_copy_mode_data    *data = wme->data;
         struct screen                   *s = data->backing, ss;          struct screen                   *s = data->backing, ss;
         struct screen_write_ctx          ctx;          struct screen_write_ctx          ctx;
         struct grid                     *gd = s->grid;          struct grid                     *gd = s->grid;
         const struct grid_line          *gl;  
         int                              found, cis, which = -1, stopped = 0;          int                              found, cis, which = -1, stopped = 0;
         int                              cflags = REG_EXTENDED;          int                              cflags = REG_EXTENDED;
         u_int                            px, py, i, b, nfound = 0, width;          u_int                            px, py, i, b, nfound = 0, width;
Line 2988 
Line 3021 
         }          }
         tstart = get_timer();          tstart = get_timer();
   
         start = 0;          if (visible_only)
         end = gd->hsize + gd->sy;                  window_copy_visible_lines(data, &start, &end);
         stop = get_timer() + WINDOW_COPY_SEARCH_ALL_TIMEOUT;          else {
                   start = 0;
                   end = gd->hsize + gd->sy;
                   stop = get_timer() + WINDOW_COPY_SEARCH_ALL_TIMEOUT;
           }
   
 again:  again:
         free(data->searchmark);          free(data->searchmark);
Line 3045 
Line 3082 
   
         if (stopped && stop != 0) {          if (stopped && stop != 0) {
                 /* Try again but just the visible context. */                  /* Try again but just the visible context. */
                 for (start = gd->hsize - data->oy; start > 0; start--) {                  window_copy_visible_lines(data, &start, &end);
                         gl = grid_peek_line(gd, start - 1);  
                         if (~gl->flags & GRID_LINE_WRAPPED)  
                                 break;  
                 }  
                 end = gd->hsize - data->oy + gd->sy;  
                 stop = 0;                  stop = 0;
                 goto again;                  goto again;
         }          }
   
         if (stopped) {          if (!visible_only) {
                 data->searchthis = -1;                  if (stopped) {
                 if (nfound > 1000)  
                         data->searchcount = 1000;  
                 else if (nfound > 100)  
                         data->searchcount = 100;  
                 else if (nfound > 10)  
                         data->searchcount = 10;  
                 else  
                         data->searchcount = -1;  
                 data->searchmore = 1;  
         } else {  
                 if (which != -1)  
                         data->searchthis = 1 + nfound - which;  
                 else  
                         data->searchthis = -1;                          data->searchthis = -1;
                 data->searchcount = nfound;                          if (nfound > 1000)
                 data->searchmore = 0;                                  data->searchcount = 1000;
                           else if (nfound > 100)
                                   data->searchcount = 100;
                           else if (nfound > 10)
                                   data->searchcount = 10;
                           else
                                   data->searchcount = -1;
                           data->searchmore = 1;
                   } else {
                           if (which != -1)
                                   data->searchthis = 1 + nfound - which;
                           else
                                   data->searchthis = -1;
                           data->searchcount = nfound;
                           data->searchmore = 0;
                   }
         }          }
   
 out:  out:
Line 4563 
Line 4597 
         data->oy -= ny;          data->oy -= ny;
   
         if (data->searchmark != NULL && !data->timeout)          if (data->searchmark != NULL && !data->timeout)
                 window_copy_search_marks(wme, NULL, data->searchregex);                  window_copy_search_marks(wme, NULL, data->searchregex, 1);
         window_copy_update_selection(wme, 0, 0);          window_copy_update_selection(wme, 0, 0);
   
         screen_write_start_pane(&ctx, wp, NULL);          screen_write_start_pane(&ctx, wp, NULL);
Line 4599 
Line 4633 
         data->oy += ny;          data->oy += ny;
   
         if (data->searchmark != NULL && !data->timeout)          if (data->searchmark != NULL && !data->timeout)
                 window_copy_search_marks(wme, NULL, data->searchregex);                  window_copy_search_marks(wme, NULL, data->searchregex, 1);
         window_copy_update_selection(wme, 0, 0);          window_copy_update_selection(wme, 0, 0);
   
         screen_write_start_pane(&ctx, wp, NULL);          screen_write_start_pane(&ctx, wp, NULL);

Legend:
Removed from v.1.295  
changed lines
  Added in v.1.296