[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.57 and 1.58

version 1.57, 2020/05/16 16:33:16 version 1.58, 2020/05/16 16:35:13
Line 212 
Line 212 
                                 return (KEYC_UNKNOWN);                                  return (KEYC_UNKNOWN);
                         if (utf8_combine(&ud, &wc) != UTF8_DONE)                          if (utf8_combine(&ud, &wc) != UTF8_DONE)
                                 return (KEYC_UNKNOWN);                                  return (KEYC_UNKNOWN);
                         return (wc | modifiers);                          return (wc|modifiers);
                 }                  }
   
                 /* Otherwise look the key up in the table. */                  /* Otherwise look the key up in the table. */
Line 236 
Line 236 
                 modifiers &= ~KEYC_CTRL;                  modifiers &= ~KEYC_CTRL;
         }          }
   
         return (key | modifiers);          return (key|modifiers);
 }  }
   
 /* Convert a key code into string format, with prefix if necessary. */  /* Convert a key code into string format, with prefix if necessary. */
 const char *  const char *
 key_string_lookup_key(key_code key)  key_string_lookup_key(key_code key, int with_flags)
 {  {
         static char              out[32];          key_code                 saved = key;
           static char              out[64];
         char                     tmp[8];          char                     tmp[8];
         const char              *s;          const char              *s;
         u_int                    i;          u_int                    i;
Line 255 
Line 256 
         /* Literal keys are themselves. */          /* Literal keys are themselves. */
         if (key & KEYC_LITERAL) {          if (key & KEYC_LITERAL) {
                 snprintf(out, sizeof out, "%c", (int)(key & 0xff));                  snprintf(out, sizeof out, "%c", (int)(key & 0xff));
                 return (out);                  goto out;
         }          }
   
         /* Display C-@ as C-Space. */          /* Display C-@ as C-Space. */
         if ((key & KEYC_MASK_KEY) == 0)          if ((key & (KEYC_MASK_KEY|KEYC_MASK_MODIFIERS)) == 0)
                 key = ' ' | KEYC_CTRL | (key & KEYC_MASK_MOD);                  key = ' '|KEYC_CTRL;
   
         /* Fill in the modifiers. */          /* Fill in the modifiers. */
         if (key & KEYC_CTRL)          if (key & KEYC_CTRL)
Line 272 
Line 273 
         key &= KEYC_MASK_KEY;          key &= KEYC_MASK_KEY;
   
         /* Handle no key. */          /* Handle no key. */
         if (key == KEYC_NONE)          if (key == KEYC_NONE) {
                 return ("None");                  s = "None";
                   goto append;
           }
   
         /* Handle special keys. */          /* Handle special keys. */
         if (key == KEYC_UNKNOWN) {          if (key == KEYC_UNKNOWN) {
Line 331 
Line 334 
         if (key >= KEYC_USER && key < KEYC_USER + KEYC_NUSER) {          if (key >= KEYC_USER && key < KEYC_USER + KEYC_NUSER) {
                 snprintf(tmp, sizeof tmp, "User%u", (u_int)(key - KEYC_USER));                  snprintf(tmp, sizeof tmp, "User%u", (u_int)(key - KEYC_USER));
                 strlcat(out, tmp, sizeof out);                  strlcat(out, tmp, sizeof out);
                 return (out);                  goto out;
         }          }
   
         /* Try the key against the string table. */          /* Try the key against the string table. */
Line 341 
Line 344 
         }          }
         if (i != nitems(key_string_table)) {          if (i != nitems(key_string_table)) {
                 strlcat(out, key_string_table[i].string, sizeof out);                  strlcat(out, key_string_table[i].string, sizeof out);
                 return (out);                  goto out;
         }          }
   
         /* Is this a UTF-8 key? */          /* Is this a UTF-8 key? */
Line 350 
Line 353 
                         off = strlen(out);                          off = strlen(out);
                         memcpy(out + off, ud.data, ud.size);                          memcpy(out + off, ud.data, ud.size);
                         out[off + ud.size] = '\0';                          out[off + ud.size] = '\0';
                         return (out);                          goto out;
                 }                  }
         }          }
   
         /* Invalid keys are errors. */          /* Invalid keys are errors. */
         if (key > 255) {          if (key > 255) {
                 snprintf(out, sizeof out, "Invalid#%llx", key);                  snprintf(out, sizeof out, "Invalid#%llx", key);
                 return (out);                  goto out;
         }          }
   
         /* Check for standard or control key. */          /* Check for standard or control key. */
Line 375 
Line 378 
                 xsnprintf(tmp, sizeof tmp, "\\%llo", key);                  xsnprintf(tmp, sizeof tmp, "\\%llo", key);
   
         strlcat(out, tmp, sizeof out);          strlcat(out, tmp, sizeof out);
         return (out);          goto out;
   
 append:  append:
         strlcat(out, s, sizeof out);          strlcat(out, s, sizeof out);
   
   out:
           if (with_flags && (saved & KEYC_MASK_FLAGS) != 0) {
                   strlcat(out, "[", sizeof out);
                   if (saved & KEYC_LITERAL)
                           strlcat(out, "L", sizeof out);
                   if (saved & KEYC_KEYPAD)
                           strlcat(out, "K", sizeof out);
                   if (saved & KEYC_CURSOR)
                           strlcat(out, "C", sizeof out);
                   if (saved & KEYC_IMPLIED_META)
                           strlcat(out, "I", sizeof out);
                   if (saved & KEYC_BUILD_MODIFIERS)
                           strlcat(out, "B", sizeof out);
                   strlcat(out, "]", sizeof out);
           }
         return (out);          return (out);
 }  }

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.58