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

Diff for /src/usr.bin/tmux/tty-keys.c between version 1.110 and 1.111

version 1.110, 2019/04/25 19:36:59 version 1.111, 2019/05/03 14:51:31
Line 46 
Line 46 
 static int      tty_keys_next1(struct tty *, const char *, size_t, key_code *,  static int      tty_keys_next1(struct tty *, const char *, size_t, key_code *,
                     size_t *, int);                      size_t *, int);
 static void     tty_keys_callback(int, short, void *);  static void     tty_keys_callback(int, short, void *);
 static int      tty_keys_mouse(struct tty *, const char *, size_t, size_t *);  static int      tty_keys_mouse(struct tty *, const char *, size_t, size_t *,
                       struct mouse_event *);
 static int      tty_keys_clipboard(struct tty *, const char *, size_t,  static int      tty_keys_clipboard(struct tty *, const char *, size_t,
                     size_t *);                      size_t *);
 static int      tty_keys_device_attributes(struct tty *, const char *, size_t,  static int      tty_keys_device_attributes(struct tty *, const char *, size_t,
Line 560 
Line 561 
         return (-1);          return (-1);
 }  }
   
 /*  /* Process at least one key in the buffer. Return 0 if no keys present. */
  * Process at least one key in the buffer and invoke tty->key_callback. Return  int
  * 0 if there are no further keys, or 1 if there could be more in the buffer.  
  */  
 key_code  
 tty_keys_next(struct tty *tty)  tty_keys_next(struct tty *tty)
 {  {
         struct client   *c = tty->client;          struct client           *c = tty->client;
         struct timeval   tv;          struct timeval           tv;
         const char      *buf;          const char              *buf;
         size_t           len, size;          size_t                   len, size;
         cc_t             bspace;          cc_t                     bspace;
         int              delay, expired = 0, n;          int                      delay, expired = 0, n;
         key_code         key;          key_code                 key;
           struct cmdq_item        *item;
           struct mouse_event       m = { 0 };
           struct key_event        *event;
   
           gettimeofday(&tv, NULL);
   
         /* Get key buffer. */          /* Get key buffer. */
         buf = EVBUFFER_DATA(tty->in);          buf = EVBUFFER_DATA(tty->in);
         len = EVBUFFER_LENGTH(tty->in);          len = EVBUFFER_LENGTH(tty->in);
   
         if (len == 0)          if (len == 0)
                 return (0);                  return (0);
         log_debug("%s: keys are %zu (%.*s)", c->name, len, (int)len, buf);          log_debug("%s: keys are %zu (%.*s)", c->name, len, (int)len, buf);
Line 606 
Line 608 
         }          }
   
         /* Is this a mouse key press? */          /* Is this a mouse key press? */
         switch (tty_keys_mouse(tty, buf, len, &size)) {          switch (tty_keys_mouse(tty, buf, len, &size, &m)) {
         case 0:         /* yes */          case 0:         /* yes */
                 key = KEYC_MOUSE;                  key = KEYC_MOUSE;
                 goto complete_key;                  goto complete_key;
Line 725 
Line 727 
         }          }
   
         /* Fire the key. */          /* Fire the key. */
         if (key != KEYC_UNKNOWN)          if (key != KEYC_UNKNOWN) {
                 server_client_handle_key(tty->client, key);                  event = xmalloc(sizeof *event);
                   event->key = key;
                   memcpy(&event->m, &m, sizeof event->m);
   
                   item = cmdq_get_callback(server_client_key_callback, event);
                   cmdq_append(c, item);
           }
   
         return (1);          return (1);
   
 discard_key:  discard_key:
Line 756 
Line 764 
  * (probably a mouse sequence but need more data).   * (probably a mouse sequence but need more data).
  */   */
 static int  static int
 tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)  tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size,
       struct mouse_event *m)
 {  {
         struct client           *c = tty->client;          struct client   *c = tty->client;
         struct mouse_event      *m = &tty->mouse;          u_int            i, x, y, b, sgr_b;
         u_int                    i, x, y, b, sgr_b;          u_char           sgr_type, ch;
         u_char                   sgr_type, ch;  
   
         /*          /*
          * Standard mouse sequences are \033[M followed by three characters           * Standard mouse sequences are \033[M followed by three characters
Line 882 
Line 890 
                 return (-1);                  return (-1);
   
         /* Fill mouse event. */          /* Fill mouse event. */
         m->lx = m->x;          m->lx = tty->mouse_last_x;
         m->x = x;          m->x = x;
         m->ly = m->y;          m->ly = tty->mouse_last_y;
         m->y = y;          m->y = y;
         m->lb = m->b;          m->lb = m->b;
         m->b = b;          m->b = b;
         m->sgr_type = sgr_type;          m->sgr_type = sgr_type;
         m->sgr_b = sgr_b;          m->sgr_b = sgr_b;
   
           /* Update last mouse state. */
           tty->mouse_last_x = x;
           tty->mouse_last_y = y;
   
         return (0);          return (0);
 }  }

Legend:
Removed from v.1.110  
changed lines
  Added in v.1.111