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

Diff for /src/usr.bin/tmux/control.c between version 1.31 and 1.32

version 1.31, 2020/05/21 07:24:13 version 1.32, 2020/05/22 11:07:04
Line 26 
Line 26 
   
 #include "tmux.h"  #include "tmux.h"
   
   /* Control offsets. */
   struct control_offset {
           u_int                           pane;
   
           struct window_pane_offset       offset;
           int                             flags;
   #define CONTROL_OFFSET_OFF 0x1
   
           RB_ENTRY(control_offset)                entry;
   };
   RB_HEAD(control_offsets, control_offset);
   
   /* Compare client offsets. */
   static int
   control_offset_cmp(struct control_offset *co1, struct control_offset *co2)
   {
           if (co1->pane < co2->pane)
                   return (-1);
           if (co1->pane > co2->pane)
                   return (1);
           return (0);
   }
   RB_GENERATE_STATIC(control_offsets, control_offset, entry, control_offset_cmp);
   
   /* Get pane offsets for this client. */
   static struct control_offset *
   control_get_offset(struct client *c, struct window_pane *wp)
   {
           struct control_offset   co = { .pane = wp->id };
   
           if (c->offsets == NULL)
                   return (NULL);
           return (RB_FIND(control_offsets, c->offsets, &co));
   }
   
   /* Add pane offsets for this client. */
   static struct control_offset *
   control_add_offset(struct client *c, struct window_pane *wp)
   {
           struct control_offset   *co;
   
           co = control_get_offset(c, wp);
           if (co != NULL)
                   return (co);
   
           if (c->offsets == NULL) {
                   c->offsets = xmalloc(sizeof *c->offsets);
                   RB_INIT(c->offsets);
           }
   
           co = xcalloc(1, sizeof *co);
           co->pane = wp->id;
           RB_INSERT(control_offsets, c->offsets, co);
           memcpy(&co->offset, &wp->offset, sizeof co->offset);
           return (co);
   }
   
   /* Free control offsets. */
   void
   control_free_offsets(struct client *c)
   {
           struct control_offset   *co, *co1;
   
           if (c->offsets == NULL)
                   return;
           RB_FOREACH_SAFE(co, control_offsets, c->offsets, co1) {
                   RB_REMOVE(control_offsets, c->offsets, co);
                   free(co);
           }
           free(c->offsets);
   }
   
   /* Get offsets for client. */
   struct window_pane_offset *
   control_pane_offset(struct client *c, struct window_pane *wp, int *off)
   {
           struct control_offset   *co;
   
           if (c->flags & CLIENT_CONTROL_NOOUTPUT) {
                   *off = 0;
                   return (NULL);
           }
   
           co = control_get_offset(c, wp);
           if (co == NULL) {
                   *off = 0;
                   return (NULL);
           }
           if (co->flags & CONTROL_OFFSET_OFF) {
                   *off = 1;
                   return (NULL);
           }
           return (&co->offset);
   }
   
   /* Set pane as on. */
   void
   control_set_pane_on(struct client *c, struct window_pane *wp)
   {
           struct control_offset   *co;
   
           co = control_get_offset(c, wp);
           if (co != NULL) {
                   co->flags &= ~CONTROL_OFFSET_OFF;
                   memcpy(&co->offset, &wp->offset, sizeof co->offset);
           }
   }
   
   /* Set pane as off. */
   void
   control_set_pane_off(struct client *c, struct window_pane *wp)
   {
           struct control_offset   *co;
   
           co = control_add_offset(c, wp);
           co->flags |= CONTROL_OFFSET_OFF;
   }
   
 /* Write a line. */  /* Write a line. */
 void  void
 control_write(struct client *c, const char *fmt, ...)  control_write(struct client *c, const char *fmt, ...)
Line 42 
Line 160 
 void  void
 control_write_output(struct client *c, struct window_pane *wp)  control_write_output(struct client *c, struct window_pane *wp)
 {  {
         struct client_offset    *co;          struct control_offset   *co;
         struct evbuffer         *message;          struct evbuffer         *message;
         u_char                  *new_data;          u_char                  *new_data;
         size_t                   new_size, i;          size_t                   new_size, i;
Line 57 
Line 175 
         if (winlink_find_by_window(&c->session->windows, wp->window) == NULL)          if (winlink_find_by_window(&c->session->windows, wp->window) == NULL)
                 return;                  return;
   
         co = server_client_add_pane_offset(c, wp);          co = control_add_offset(c, wp);
         if (co->flags & CLIENT_OFFSET_OFF) {          if (co->flags & CONTROL_OFFSET_OFF) {
                 window_pane_update_used_data(wp, &co->offset, SIZE_MAX, 1);                  window_pane_update_used_data(wp, &co->offset, SIZE_MAX, 1);
                 return;                  return;
         }          }
Line 133 
Line 251 
         }          }
 }  }
   
   /* Initialize for control mode. */
 void  void
 control_start(struct client *c)  control_start(struct client *c)
 {  {

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32