[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.39 and 1.40

version 1.39, 2016/10/14 22:14:22 version 1.40, 2016/10/16 19:04:05
Line 27 
Line 27 
  * List key bindings.   * List key bindings.
  */   */
   
 static enum cmd_retval   cmd_list_keys_exec(struct cmd *, struct cmd_q *);  static enum cmd_retval  cmd_list_keys_exec(struct cmd *, struct cmdq_item *);
   
 static enum cmd_retval   cmd_list_keys_table(struct cmd *, struct cmd_q *);  static enum cmd_retval  cmd_list_keys_table(struct cmd *, struct cmdq_item *);
 static enum cmd_retval   cmd_list_keys_commands(struct cmd *, struct cmd_q *);  static enum cmd_retval  cmd_list_keys_commands(struct cmd *,
                               struct cmdq_item *);
   
 const struct cmd_entry cmd_list_keys_entry = {  const struct cmd_entry cmd_list_keys_entry = {
         .name = "list-keys",          .name = "list-keys",
Line 55 
Line 56 
 };  };
   
 static enum cmd_retval  static enum cmd_retval
 cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)  cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item)
 {  {
         struct args             *args = self->args;          struct args             *args = self->args;
         struct key_table        *table;          struct key_table        *table;
Line 65 
Line 66 
         int                      repeat, width, tablewidth, keywidth;          int                      repeat, width, tablewidth, keywidth;
   
         if (self->entry == &cmd_list_commands_entry)          if (self->entry == &cmd_list_commands_entry)
                 return (cmd_list_keys_commands(self, cmdq));                  return (cmd_list_keys_commands(self, item));
   
         if (args_has(args, 't'))          if (args_has(args, 't'))
                 return (cmd_list_keys_table(self, cmdq));                  return (cmd_list_keys_table(self, item));
   
         tablename = args_get(args, 'T');          tablename = args_get(args, 'T');
         if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) {          if (tablename != NULL && key_bindings_get_table(tablename, 0) == NULL) {
                 cmdq_error(cmdq, "table %s doesn't exist", tablename);                  cmdq_error(item, "table %s doesn't exist", tablename);
                 return (CMD_RETURN_ERROR);                  return (CMD_RETURN_ERROR);
         }          }
   
Line 124 
Line 125 
                         strlcat(tmp, cp, sizeof tmp);                          strlcat(tmp, cp, sizeof tmp);
                         free(cp);                          free(cp);
   
                         cmdq_print(cmdq, "bind-key %s", tmp);                          cmdq_print(item, "bind-key %s", tmp);
                 }                  }
         }          }
   
Line 132 
Line 133 
 }  }
   
 static enum cmd_retval  static enum cmd_retval
 cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)  cmd_list_keys_table(struct cmd *self, struct cmdq_item *item)
 {  {
         struct args                     *args = self->args;          struct args                     *args = self->args;
         const char                      *tablename, *cmdstr;          const char                      *tablename, *cmdstr;
Line 142 
Line 143 
   
         tablename = args_get(args, 't');          tablename = args_get(args, 't');
         if ((mtab = mode_key_findtable(tablename)) == NULL) {          if ((mtab = mode_key_findtable(tablename)) == NULL) {
                 cmdq_error(cmdq, "unknown key table: %s", tablename);                  cmdq_error(item, "unknown key table: %s", tablename);
                 return (CMD_RETURN_ERROR);                  return (CMD_RETURN_ERROR);
         }          }
   
Line 156 
Line 157 
         RB_FOREACH(mbind, mode_key_tree, mtab->tree) {          RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
                 cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);                  cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
                 if (cmdstr != NULL) {                  if (cmdstr != NULL) {
                         cmdq_print(cmdq, "bind-key -t %s %*s %s",                          cmdq_print(item, "bind-key -t %s %*s %s",
                             mtab->name, (int)keywidth,                              mtab->name, (int)keywidth,
                             key_string_lookup_key(mbind->key), cmdstr);                              key_string_lookup_key(mbind->key), cmdstr);
                 }                  }
Line 166 
Line 167 
 }  }
   
 static enum cmd_retval  static enum cmd_retval
 cmd_list_keys_commands(struct cmd *self, struct cmd_q *cmdq)  cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
 {  {
         struct args             *args = self->args;          struct args             *args = self->args;
         const struct cmd_entry  **entryp;          const struct cmd_entry  **entryp;
         const struct cmd_entry   *entry;          const struct cmd_entry   *entry;
         struct format_tree       *ft;          struct format_tree       *ft;
         const char               *template;          const char               *template, *s;
         char                     *line;          char                     *line;
   
         if ((template = args_get(args, 'F')) == NULL) {          if ((template = args_get(args, 'F')) == NULL) {
Line 181 
Line 182 
                     "#{command_list_usage}";                      "#{command_list_usage}";
         }          }
   
         ft = format_create(cmdq, 0);          ft = format_create(item, 0);
         format_defaults(ft, NULL, NULL, NULL, NULL);          format_defaults(ft, NULL, NULL, NULL, NULL);
   
         for (entryp = cmd_table; *entryp != NULL; entryp++) {          for (entryp = cmd_table; *entryp != NULL; entryp++) {
                 entry = *entryp;                  entry = *entryp;
   
                 format_add(ft, "command_list_name", "%s", entry->name);                  format_add(ft, "command_list_name", "%s", entry->name);
                 if (entry->alias != NULL) {                  if (entry->alias != NULL)
                         format_add(ft, "command_list_alias", "%s",                          s = entry->alias;
                             entry->alias);                  else
                 }                          s = "";
                 if (entry->alias != NULL) {                  format_add(ft, "command_list_alias", "%s", s);
                         format_add(ft, "command_list_usage", "%s",                  if (entry->usage != NULL)
                             entry->usage);                          s = entry->usage;
                 }                  else
                           s = "";
                   format_add(ft, "command_list_usage", "%s", s);
   
                 line = format_expand(ft, template);                  line = format_expand(ft, template);
                 if (*line != '\0')                  if (*line != '\0')
                         cmdq_print(cmdq, "%s", line);                          cmdq_print(item, "%s", line);
                 free(line);                  free(line);
         }          }
   

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.40