[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.88 and 1.89

version 1.88, 2013/03/22 10:31:22 version 1.89, 2013/03/22 15:52:42
Line 52 
Line 52 
 void    window_copy_update_cursor(struct window_pane *, u_int, u_int);  void    window_copy_update_cursor(struct window_pane *, u_int, u_int);
 void    window_copy_start_selection(struct window_pane *);  void    window_copy_start_selection(struct window_pane *);
 int     window_copy_update_selection(struct window_pane *);  int     window_copy_update_selection(struct window_pane *);
   void   *window_copy_get_selection(struct window_pane *, size_t *);
   void    window_copy_copy_buffer(struct window_pane *, int, void *, size_t);
   void    window_copy_copy_pipe(struct window_pane *, int, const char *);
 void    window_copy_copy_selection(struct window_pane *, int);  void    window_copy_copy_selection(struct window_pane *, int);
 void    window_copy_clear_selection(struct window_pane *);  void    window_copy_clear_selection(struct window_pane *);
 void    window_copy_copy_line(  void    window_copy_copy_line(
Line 364 
Line 367 
         u_int                            n;          u_int                            n;
         int                              np, keys;          int                              np, keys;
         enum mode_key_cmd                cmd;          enum mode_key_cmd                cmd;
           const char                      *arg;
   
         np = data->numprefix;          np = data->numprefix;
         if (np <= 0)          if (np <= 0)
Line 405 
Line 409 
                 return;                  return;
         }          }
   
         cmd = mode_key_lookup(&data->mdata, key);          cmd = mode_key_lookup(&data->mdata, key, &arg);
         switch (cmd) {          switch (cmd) {
         case MODEKEYCOPY_CANCEL:          case MODEKEYCOPY_CANCEL:
                 window_pane_reset_mode(wp);                  window_pane_reset_mode(wp);
Line 533 
Line 537 
                 window_copy_clear_selection(wp);                  window_copy_clear_selection(wp);
                 window_copy_redraw_screen(wp);                  window_copy_redraw_screen(wp);
                 break;                  break;
           case MODEKEYCOPY_COPYPIPE:
                   if (sess != NULL) {
                           window_copy_copy_pipe(wp, data->numprefix, arg);
                           window_pane_reset_mode(wp);
                           return;
                   }
                   break;
         case MODEKEYCOPY_COPYSELECTION:          case MODEKEYCOPY_COPYSELECTION:
                 if (sess != NULL) {                  if (sess != NULL) {
                         window_copy_copy_selection(wp, data->numprefix);                          window_copy_copy_selection(wp, data->numprefix);
Line 735 
Line 746 
         size_t                           inputlen;          size_t                           inputlen;
         int                              np;          int                              np;
   
         switch (mode_key_lookup(&data->mdata, key)) {          switch (mode_key_lookup(&data->mdata, key, NULL)) {
         case MODEKEYEDIT_CANCEL:          case MODEKEYEDIT_CANCEL:
                 data->numprefix = -1;                  data->numprefix = -1;
                 return (-1);                  return (-1);
Line 1259 
Line 1270 
         return (1);          return (1);
 }  }
   
 void  void *
 window_copy_copy_selection(struct window_pane *wp, int idx)  window_copy_get_selection(struct window_pane *wp, size_t *len)
 {  {
         struct window_copy_mode_data    *data = wp->modedata;          struct window_copy_mode_data    *data = wp->modedata;
         struct screen                   *s = &data->screen;          struct screen                   *s = &data->screen;
         char                            *buf;          char                            *buf;
         size_t                           off;          size_t                           off;
         u_int                            i, xx, yy, sx, sy, ex, ey, limit;          u_int                            i, xx, yy, sx, sy, ex, ey;
         u_int                            firstsx, lastex, restex, restsx;          u_int                            firstsx, lastex, restex, restsx;
         int                              keys;          int                              keys;
   
         if (!s->sel.flag)          if (!s->sel.flag)
                 return;                  return (NULL);
   
         buf = xmalloc(1);          buf = xmalloc(1);
         off = 0;          off = 0;
Line 1364 
Line 1375 
         /* Don't bother if no data. */          /* Don't bother if no data. */
         if (off == 0) {          if (off == 0) {
                 free(buf);                  free(buf);
                 return;                  return (NULL);
         }          }
         off--;  /* remove final \n */          *len = off - 1; /* remove final \n */
           return (buf);
   }
   
   void
   window_copy_copy_buffer(struct window_pane *wp, int idx, void *buf, size_t len)
   {
           u_int   limit;
   
         if (options_get_number(&global_options, "set-clipboard"))          if (options_get_number(&global_options, "set-clipboard"))
                 screen_write_setselection(&wp->ictx.ctx, buf, off);                  screen_write_setselection(&wp->ictx.ctx, buf, len);
   
         /* Add the buffer to the stack. */  
         if (idx == -1) {          if (idx == -1) {
                 limit = options_get_number(&global_options, "buffer-limit");                  limit = options_get_number(&global_options, "buffer-limit");
                 paste_add(&global_buffers, buf, off, limit);                  paste_add(&global_buffers, buf, len, limit);
         } else          } else
                 paste_replace(&global_buffers, idx, buf, off);                  paste_replace(&global_buffers, idx, buf, len);
   }
   
   void
   window_copy_copy_pipe(struct window_pane *wp, int idx, const char *arg)
   {
           void*   buf;
           size_t  len;
           FILE*   f;
   
           buf = window_copy_get_selection(wp, &len);
           if (buf == NULL)
                   return;
   
           f = popen(arg, "w");
           if (f != NULL) {
                   fwrite(buf, 1, len, f);
                   pclose(f);
           }
   
           window_copy_copy_buffer(wp, idx, buf, len);
   }
   
   void
   window_copy_copy_selection(struct window_pane *wp, int idx)
   {
           void*   buf;
           size_t  len;
   
           buf = window_copy_get_selection(wp, &len);
           if (buf == NULL)
                   return;
   
           window_copy_copy_buffer(wp, idx, buf, len);
 }  }
   
 void  void

Legend:
Removed from v.1.88  
changed lines
  Added in v.1.89