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

Diff for /src/usr.bin/tmux/format.c between version 1.212 and 1.213

version 1.212, 2019/10/14 09:24:06 version 1.213, 2019/10/23 07:42:05
Line 703 
Line 703 
                 xasprintf(&fe->value, "%.*s", (int)gc.data.size, gc.data.data);                  xasprintf(&fe->value, "%.*s", (int)gc.data.size, gc.data.data);
 }  }
   
 /* Callback for mouse_word. */  /* Return word at given coordinates. Caller frees. */
 static void  char *
 format_cb_mouse_word(struct format_tree *ft, struct format_entry *fe)  format_grid_word(struct grid *gd, u_int x, u_int y)
 {  {
         struct window_pane      *wp;  
         u_int                    x, y, end;  
         struct grid             *gd;  
         struct grid_line        *gl;          struct grid_line        *gl;
         struct grid_cell         gc;          struct grid_cell         gc;
         const char              *ws;          const char              *ws;
         struct utf8_data        *ud = NULL;          struct utf8_data        *ud = NULL;
           u_int                    end;
         size_t                   size = 0;          size_t                   size = 0;
         int                      found = 0;          int                      found = 0;
           char                    *s = NULL;
   
         if (!ft->m.valid)  
                 return;  
         wp = cmd_mouse_pane(&ft->m, NULL, NULL);  
         if (wp == NULL)  
                 return;  
         if (!TAILQ_EMPTY (&wp->modes))  
                 return;  
         if (cmd_mouse_at(wp, &ft->m, &x, &y, 0) != 0)  
                 return;  
         gd = wp->base.grid;  
         ws = options_get_string(global_s_options, "word-separators");          ws = options_get_string(global_s_options, "word-separators");
   
         y = gd->hsize + y;          y = gd->hsize + y;
Line 779 
Line 768 
         }          }
         if (size != 0) {          if (size != 0) {
                 ud[size].size = 0;                  ud[size].size = 0;
                 fe->value = utf8_tocstr(ud);                  s = utf8_tocstr(ud);
                 free(ud);                  free(ud);
         }          }
           return (s);
 }  }
   
 /* Callback for mouse_line. */  /* Callback for mouse_word. */
 static void  static void
 format_cb_mouse_line(struct format_tree *ft, struct format_entry *fe)  format_cb_mouse_word(struct format_tree *ft, struct format_entry *fe)
 {  {
         struct window_pane      *wp;          struct window_pane      *wp;
         u_int                    x, y;          u_int                    x, y;
         struct grid             *gd;          char                    *s;
         struct grid_cell         gc;  
         struct utf8_data        *ud = NULL;  
         size_t                   size = 0;  
   
         if (!ft->m.valid)          if (!ft->m.valid)
                 return;                  return;
Line 804 
Line 791 
                 return;                  return;
         if (cmd_mouse_at(wp, &ft->m, &x, &y, 0) != 0)          if (cmd_mouse_at(wp, &ft->m, &x, &y, 0) != 0)
                 return;                  return;
         gd = wp->base.grid;  
   
           s = format_grid_word(wp->base.grid, x, y);
           if (s != NULL)
                   fe->value = s;
   }
   
   /* Return line at given coordinates. Caller frees. */
   char *
   format_grid_line(struct grid *gd, u_int y)
   {
           struct grid_cell         gc;
           struct utf8_data        *ud = NULL;
           u_int                    x;
           size_t                   size = 0;
           char                    *s = NULL;
   
         y = gd->hsize + y;          y = gd->hsize + y;
         for (x = 0; x < grid_line_length(gd, y); x++) {          for (x = 0; x < grid_line_length(gd, y); x++) {
                 grid_get_cell(gd, x, y, &gc);                  grid_get_cell(gd, x, y, &gc);
Line 817 
Line 818 
         }          }
         if (size != 0) {          if (size != 0) {
                 ud[size].size = 0;                  ud[size].size = 0;
                 fe->value = utf8_tocstr(ud);                  s = utf8_tocstr(ud);
                 free(ud);                  free(ud);
         }          }
           return (s);
   }
   
   /* Callback for mouse_line. */
   static void
   format_cb_mouse_line(struct format_tree *ft, struct format_entry *fe)
   {
           struct window_pane      *wp;
           u_int                    x, y;
           char                    *s;
   
           if (!ft->m.valid)
                   return;
           wp = cmd_mouse_pane(&ft->m, NULL, NULL);
           if (wp == NULL)
                   return;
           if (!TAILQ_EMPTY (&wp->modes))
                   return;
           if (cmd_mouse_at(wp, &ft->m, &x, &y, 0) != 0)
                   return;
   
           s = format_grid_line(wp->base.grid, y);
           if (s != NULL)
                   fe->value = s;
 }  }
   
 /* Merge a format tree. */  /* Merge a format tree. */

Legend:
Removed from v.1.212  
changed lines
  Added in v.1.213