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

Diff for /src/usr.bin/tmux/key-string.c between version 1.32 and 1.33

version 1.32, 2015/11/14 11:45:43 version 1.33, 2015/12/12 18:19:00
Line 22 
Line 22 
   
 #include "tmux.h"  #include "tmux.h"
   
 key_code        key_string_search_table(const char *);  static key_code key_string_search_table(const char *);
 key_code        key_string_get_modifiers(const char **);  static key_code key_string_get_modifiers(const char **);
   
 const struct {  const struct {
         const char     *string;          const char     *string;
Line 98 
Line 98 
 };  };
   
 /* Find key string in table. */  /* Find key string in table. */
 key_code  static key_code
 key_string_search_table(const char *string)  key_string_search_table(const char *string)
 {  {
         u_int   i;          u_int   i;
Line 107 
Line 107 
                 if (strcasecmp(string, key_string_table[i].string) == 0)                  if (strcasecmp(string, key_string_table[i].string) == 0)
                         return (key_string_table[i].key);                          return (key_string_table[i].key);
         }          }
         return (KEYC_NONE);          return (KEYC_UNKNOWN);
 }  }
   
 /* Find modifiers. */  /* Find modifiers. */
 key_code  static key_code
 key_string_get_modifiers(const char **string)  key_string_get_modifiers(const char **string)
 {  {
         key_code        modifiers;          key_code        modifiers;
Line 150 
Line 150 
         u_int                    i;          u_int                    i;
         enum utf8_state          more;          enum utf8_state          more;
   
           /* Is this no key? */
           if (strcasecmp(string, "None") == 0)
                   return (KEYC_NONE);
   
         /* Is this a hexadecimal value? */          /* Is this a hexadecimal value? */
         if (string[0] == '0' && string[1] == 'x') {          if (string[0] == '0' && string[1] == 'x') {
                 if (sscanf(string + 2, "%hx%n", &u, &size) != 1 || size > 4)                  if (sscanf(string + 2, "%hx%n", &u, &size) != 1 || size > 4)
                         return (KEYC_NONE);                          return (KEYC_UNKNOWN);
                 return (u);                  return (u);
         }          }
   
Line 165 
Line 169 
         }          }
         modifiers |= key_string_get_modifiers(&string);          modifiers |= key_string_get_modifiers(&string);
         if (string[0] == '\0')          if (string[0] == '\0')
                 return (KEYC_NONE);                  return (KEYC_UNKNOWN);
   
         /* Is this a standard ASCII key? */          /* Is this a standard ASCII key? */
         if (string[1] == '\0' && (u_char)string[0] <= 127) {          if (string[1] == '\0' && (u_char)string[0] <= 127) {
                 key = (u_char)string[0];                  key = (u_char)string[0];
                 if (key < 32 || key == 127)                  if (key < 32 || key == 127)
                         return (KEYC_NONE);                          return (KEYC_UNKNOWN);
         } else {          } else {
                 /* Try as a UTF-8 key. */                  /* Try as a UTF-8 key. */
                 if ((more = utf8_open(&ud, (u_char)*string)) == UTF8_MORE) {                  if ((more = utf8_open(&ud, (u_char)*string)) == UTF8_MORE) {
                         if (strlen(string) != ud.size)                          if (strlen(string) != ud.size)
                                 return (KEYC_NONE);                                  return (KEYC_UNKNOWN);
                         for (i = 1; i < ud.size; i++)                          for (i = 1; i < ud.size; i++)
                                 more = utf8_append(&ud, (u_char)string[i]);                                  more = utf8_append(&ud, (u_char)string[i]);
                         if (more != UTF8_DONE)                          if (more != UTF8_DONE)
                                 return (KEYC_NONE);                                  return (KEYC_UNKNOWN);
                         key = utf8_combine(&ud);                          key = utf8_combine(&ud);
                         return (key | modifiers);                          return (key | modifiers);
                 }                  }
   
                 /* Otherwise look the key up in the table. */                  /* Otherwise look the key up in the table. */
                 key = key_string_search_table(string);                  key = key_string_search_table(string);
                 if (key == KEYC_NONE)                  if (key == KEYC_UNKNOWN)
                         return (KEYC_NONE);                          return (KEYC_UNKNOWN);
         }          }
   
         /* Convert the standard control keys. */          /* Convert the standard control keys. */
Line 202 
Line 206 
                 else if (key == 63)                  else if (key == 63)
                         key = KEYC_BSPACE;                          key = KEYC_BSPACE;
                 else                  else
                         return (KEYC_NONE);                          return (KEYC_UNKNOWN);
                 modifiers &= ~KEYC_CTRL;                  modifiers &= ~KEYC_CTRL;
         }          }
   
Line 222 
Line 226 
   
         /* Handle no key. */          /* Handle no key. */
         if (key == KEYC_NONE)          if (key == KEYC_NONE)
                 return ("<NONE>");                  return ("None");
   
           /* Handle special keys. */
           if (key == KEYC_UNKNOWN)
                   return ("Unknown");
         if (key == KEYC_MOUSE)          if (key == KEYC_MOUSE)
                 return ("<MOUSE>");                  return ("Mouse");
   
         /*          /*
          * Special case: display C-@ as C-Space. Could do this below in           * Special case: display C-@ as C-Space. Could do this below in
Line 265 
Line 273 
   
         /* Invalid keys are errors. */          /* Invalid keys are errors. */
         if (key == 127 || key > 255) {          if (key == 127 || key > 255) {
                 snprintf(out, sizeof out, "<INVALID#%llx>", key);                  snprintf(out, sizeof out, "Invalid#%llx", key);
                 return (out);                  return (out);
         }          }
   

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