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

Diff for /src/usr.bin/tmux/cmd-unbind-key.c between version 1.29 and 1.30

version 1.29, 2016/10/16 19:04:05 version 1.30, 2017/01/24 21:50:22
Line 28 
Line 28 
   
 static enum cmd_retval  cmd_unbind_key_exec(struct cmd *, struct cmdq_item *);  static enum cmd_retval  cmd_unbind_key_exec(struct cmd *, struct cmdq_item *);
   
 static enum cmd_retval  cmd_unbind_key_mode_table(struct cmd *,  
                             struct cmdq_item *, key_code);  
   
 const struct cmd_entry cmd_unbind_key_entry = {  const struct cmd_entry cmd_unbind_key_entry = {
         .name = "unbind-key",          .name = "unbind-key",
         .alias = "unbind",          .alias = "unbind",
   
         .args = { "ant:T:", 0, 1 },          .args = { "anT:", 0, 1 },
         .usage = "[-an] [-t mode-table] [-T key-table] key",          .usage = "[-an] [-T key-table] key",
   
         .flags = CMD_AFTERHOOK,          .flags = CMD_AFTERHOOK,
         .exec = cmd_unbind_key_exec          .exec = cmd_unbind_key_exec
Line 67 
Line 64 
                 key = KEYC_UNKNOWN;                  key = KEYC_UNKNOWN;
         }          }
   
         if (args_has(args, 't'))  
                 return (cmd_unbind_key_mode_table(self, item, key));  
   
         if (key == KEYC_UNKNOWN) {          if (key == KEYC_UNKNOWN) {
                 tablename = args_get(args, 'T');                  tablename = args_get(args, 'T');
                 if (tablename == NULL) {                  if (tablename == NULL) {
Line 96 
Line 90 
         else          else
                 tablename = "prefix";                  tablename = "prefix";
         key_bindings_remove(tablename, key);          key_bindings_remove(tablename, key);
         return (CMD_RETURN_NORMAL);  
 }  
   
 static enum cmd_retval  
 cmd_unbind_key_mode_table(struct cmd *self, struct cmdq_item *item,  
     key_code key)  
 {  
         struct args                     *args = self->args;  
         const char                      *tablename;  
         const struct mode_key_table     *mtab;  
         struct mode_key_binding         *mbind, mtmp;  
   
         tablename = args_get(args, 't');  
         if ((mtab = mode_key_findtable(tablename)) == NULL) {  
                 cmdq_error(item, "unknown key table: %s", tablename);  
                 return (CMD_RETURN_ERROR);  
         }  
   
         if (key == KEYC_UNKNOWN) {  
                 while (!RB_EMPTY(mtab->tree)) {  
                         mbind = RB_ROOT(mtab->tree);  
                         RB_REMOVE(mode_key_tree, mtab->tree, mbind);  
                         free(mbind);  
                 }  
                 return (CMD_RETURN_NORMAL);  
         }  
   
         mtmp.key = key;  
         if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {  
                 RB_REMOVE(mode_key_tree, mtab->tree, mbind);  
                 free(mbind);  
         }  
         return (CMD_RETURN_NORMAL);          return (CMD_RETURN_NORMAL);
 }  }

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30