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

Diff for /src/usr.bin/tmux/cmd-list-keys.c between version 1.13 and 1.14

version 1.13, 2011/01/04 00:42:46 version 1.14, 2011/07/04 00:31:57
Line 46 
Line 46 
         struct args             *args = self->args;          struct args             *args = self->args;
         struct key_binding      *bd;          struct key_binding      *bd;
         const char              *key;          const char              *key;
         char                     tmp[BUFSIZ];          char                     tmp[BUFSIZ], flags[8];
         size_t                   used;          size_t                   used;
         int                      width, keywidth;          int                      width, keywidth;
   
Line 59 
Line 59 
                 if (key == NULL)                  if (key == NULL)
                         continue;                          continue;
   
                 keywidth = strlen(key) + 1;                  keywidth = strlen(key);
                 if (!(bd->key & KEYC_PREFIX))                  if (!(bd->key & KEYC_PREFIX)) {
                         keywidth += 2;                          if (bd->can_repeat)
                                   keywidth += 4;
                           else
                                   keywidth += 3;
                   } else if (bd->can_repeat)
                           keywidth += 3;
                 if (keywidth > width)                  if (keywidth > width)
                         width = keywidth;                          width = keywidth;
         }          }
Line 70 
Line 75 
                 key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);                  key = key_string_lookup_key(bd->key & ~KEYC_PREFIX);
                 if (key == NULL)                  if (key == NULL)
                         continue;                          continue;
                 used = xsnprintf(tmp, sizeof tmp, "%*s: ", width, key);  
                   if (!(bd->key & KEYC_PREFIX)) {
                           if (bd->can_repeat)
                                   xsnprintf(flags, sizeof flags, "-rn ");
                           else
                                   xsnprintf(flags, sizeof flags, "-n ");
                   } else if (bd->can_repeat)
                           xsnprintf(flags, sizeof flags, "-r ");
   
                   used = xsnprintf(tmp, sizeof tmp, "%s%*s ",
                       flags, (int) (width - strlen(flags)), key);
                 if (used >= sizeof tmp)                  if (used >= sizeof tmp)
                         continue;                          continue;
   
                 if (!(bd->key & KEYC_PREFIX)) {  
                         used = strlcat(tmp, "(no prefix) ", sizeof tmp);  
                         if (used >= sizeof tmp)  
                                 continue;  
                 }  
                 if (bd->can_repeat) {  
                         used = strlcat(tmp, "(repeat) ", sizeof tmp);  
                         if (used >= sizeof tmp)  
                                 continue;  
                 }  
                 cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);                  cmd_list_print(bd->cmdlist, tmp + used, (sizeof tmp) - used);
                 ctx->print(ctx, "%s", tmp);                  ctx->print(ctx, "bind-key %s", tmp);
         }          }
   
         return (0);          return (0);
Line 99 
Line 104 
         const struct mode_key_table     *mtab;          const struct mode_key_table     *mtab;
         struct mode_key_binding         *mbind;          struct mode_key_binding         *mbind;
         const char                      *key, *cmdstr, *mode;          const char                      *key, *cmdstr, *mode;
         int                              width, keywidth;          int                              width, keywidth, any_mode;
   
         tablename = args_get(args, 't');          tablename = args_get(args, 't');
         if ((mtab = mode_key_findtable(tablename)) == NULL) {          if ((mtab = mode_key_findtable(tablename)) == NULL) {
Line 108 
Line 113 
         }          }
   
         width = 0;          width = 0;
           any_mode = 0;
         SPLAY_FOREACH(mbind, mode_key_tree, mtab->tree) {          SPLAY_FOREACH(mbind, mode_key_tree, mtab->tree) {
                 key = key_string_lookup_key(mbind->key);                  key = key_string_lookup_key(mbind->key);
                 if (key == NULL)                  if (key == NULL)
                         continue;                          continue;
   
                 keywidth = strlen(key) + 1;                  if (mbind->mode != 0)
                           any_mode = 1;
   
                   keywidth = strlen(key);
                 if (keywidth > width)                  if (keywidth > width)
                         width = keywidth;                          width = keywidth;
         }          }
Line 125 
Line 134 
   
                 mode = "";                  mode = "";
                 if (mbind->mode != 0)                  if (mbind->mode != 0)
                         mode = "(command mode) ";                          mode = "c";
                 cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);                  cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
                 if (cmdstr != NULL)                  if (cmdstr != NULL) {
                         ctx->print(ctx, "%*s: %s%s", width, key, mode, cmdstr);                          ctx->print(ctx, "bind-key -%st %s%s %*s %s",
                               mode, any_mode && *mode == '\0' ? " " : "",
                               mtab->name, (int) width, key, cmdstr);
                   }
         }          }
   
         return (0);          return (0);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14