[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.21 and 1.22

version 1.21, 2009/11/12 08:01:02 version 1.22, 2009/11/26 15:14:03
Line 418 
Line 418 
   
 /*  /*
  * Process at least one key in the buffer and invoke tty->key_callback. Return   * Process at least one key in the buffer and invoke tty->key_callback. Return
  * 1 if there are no further keys, or 0 if there is more in the buffer.   * 0 if there are no further keys, or 1 if there could be more in the buffer.
  */   */
 int  int
 tty_keys_next(struct tty *tty)  tty_keys_next(struct tty *tty)
Line 461 
Line 461 
         }          }
   
         /* Not found. Is this a mouse key press? */          /* Not found. Is this a mouse key press? */
         key = tty_keys_mouse(buf, len, &size, &mouse);          switch (tty_keys_mouse(buf, len, &size, &mouse)) {
         if (key != KEYC_NONE) {          case 0:         /* yes */
                 evbuffer_drain(tty->event->input, size);                  evbuffer_drain(tty->event->input, size);
                   key = KEYC_MOUSE;
                 goto handle_key;                  goto handle_key;
           case -1:        /* no, or not valid */
                   evbuffer_drain(tty->event->input, size);
                   return (1);
           case 1:         /* partial */
                   goto partial_key;
         }          }
   
   
         /* Not found. Try to parse a key with an xterm-style modifier. */          /* Not found. Try to parse a key with an xterm-style modifier. */
         key = xterm_keys_find(buf, len, &size);          key = xterm_keys_find(buf, len, &size);
         if (key != KEYC_NONE) {          if (key != KEYC_NONE) {
Line 560 
Line 567 
                 ;                  ;
 }  }
   
 /* Handle mouse key input. */  /*
    * Handle mouse key input. Returns 0 for success, -1 for failure, 1 for partial
    * (probably a mouse sequence but need more data).
    */
 int  int
 tty_keys_mouse(const char *buf, size_t len, size_t *size, struct mouse_event *m)  tty_keys_mouse(const char *buf, size_t len, size_t *size, struct mouse_event *m)
 {  {
Line 569 
Line 579 
          * buttons, X and Y, all based at 32 with 1,1 top-left.           * buttons, X and Y, all based at 32 with 1,1 top-left.
          */           */
   
         if (len != 6 || memcmp(buf, "\033[M", 3) != 0)          *size = 0;
                 return (KEYC_NONE);  
           if (buf[0] != '\033')
                   return (-1);
           if (len == 1)
                   return (1);
   
           if (buf[1] != '[')
                   return (-1);
           if (len == 2)
                   return (1);
   
           if (buf[2] != 'M')
                   return (-1);
           if (len == 3)
                   return (1);
   
           if (len < 6)
                   return (1);
         *size = 6;          *size = 6;
   
         log_debug("mouse input is: %.*s", (int) len, buf);          log_debug("mouse input is: %.6s", buf);
   
         m->b = buf[3];          m->b = buf[3];
         m->x = buf[4];          m->x = buf[4];
         m->y = buf[5];          m->y = buf[5];
         if (m->b < 32 || m->x < 33 || m->y < 33)          if (m->b < 32 || m->x < 33 || m->y < 33)
                 return (KEYC_NONE);                  return (-1);
         m->b -= 32;          m->b -= 32;
         m->x -= 33;          m->x -= 33;
         m->y -= 33;          m->y -= 33;
         return (KEYC_MOUSE);          return (0);
 }  }

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22