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

Diff for /src/usr.bin/tmux/grid-reader.c between version 1.1 and 1.2

version 1.1, 2020/12/22 09:22:14 version 1.2, 2021/02/22 06:53:04
Line 17 
Line 17 
  */   */
   
 #include "tmux.h"  #include "tmux.h"
   #include <string.h>
   
 /* Initialise virtual cursor. */  /* Initialise virtual cursor. */
 void  void
Line 300 
Line 301 
         } while (!grid_reader_in_set(gr, separators));          } while (!grid_reader_in_set(gr, separators));
         gr->cx = oldx;          gr->cx = oldx;
         gr->cy = oldy;          gr->cy = oldy;
   }
   
   /* Jump forward to character. */
   int
   grid_reader_cursor_jump(struct grid_reader *gr, const struct utf8_data *jc)
   {
           struct grid_cell        gc;
           u_int                   px, py, xx, yy;
   
           px = gr->cx;
           yy = gr->gd->hsize + gr->gd->sy - 1;
   
           for (py = gr->cy; py <= yy; py++) {
                   xx = grid_line_length(gr->gd, py);
                   while (px < xx) {
                           grid_get_cell(gr->gd, px, py, &gc);
                           if (!(gc.flags & GRID_FLAG_PADDING) &&
                               gc.data.size == jc->size &&
                               memcmp(gc.data.data, jc->data, gc.data.size) == 0) {
                                   gr->cx = px;
                                   gr->cy = py;
                                   return 1;
                           }
                           px++;
                   }
   
                   if (py == yy ||
                       !(grid_get_line(gr->gd, py)->flags & GRID_LINE_WRAPPED))
                           return 0;
                   px = 0;
           }
           return 0;
   }
   
   /* Jump back to character. */
   int
   grid_reader_cursor_jump_back(struct grid_reader *gr, const struct utf8_data *jc)
   {
           struct grid_cell        gc;
           u_int                   px, py, xx;
   
           xx = gr->cx + 1;
   
           for (py = gr->cy + 1; py > 0; py--) {
                   for (px = xx; px > 0; px--) {
                           grid_get_cell(gr->gd, px - 1, py - 1, &gc);
                           if (!(gc.flags & GRID_FLAG_PADDING) &&
                               gc.data.size == jc->size &&
                               memcmp(gc.data.data, jc->data, gc.data.size) == 0) {
                                   gr->cx = px - 1;
                                   gr->cy = py - 1;
                                   return 1;
                           }
                   }
   
                   if (py == 1 ||
                       !(grid_get_line(gr->gd, py - 2)->flags & GRID_LINE_WRAPPED))
                           return 0;
                   xx = grid_line_length(gr->gd, py - 2);
           }
           return 0;
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2