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

Diff for /src/usr.bin/tmux/cmd-send-keys.c between version 1.48 and 1.49

version 1.48, 2019/05/12 08:58:09 version 1.49, 2019/07/09 14:03:12
Line 33 
Line 33 
         .name = "send-keys",          .name = "send-keys",
         .alias = "send",          .alias = "send",
   
         .args = { "lXRMN:t:", 0, -1 },          .args = { "HlXRMN:t:", 0, -1 },
         .usage = "[-lXRM] [-N repeat-count] " CMD_TARGET_PANE_USAGE " key ...",          .usage = "[-HlXRM] [-N repeat-count] " CMD_TARGET_PANE_USAGE " key ...",
   
         .target = { 't', CMD_FIND_PANE, 0 },          .target = { 't', CMD_FIND_PANE, 0 },
   
Line 56 
Line 56 
 };  };
   
 static struct cmdq_item *  static struct cmdq_item *
 cmd_send_keys_inject(struct client *c, struct cmd_find_state *fs,  cmd_send_keys_inject_key(struct client *c, struct cmdq_item *item, key_code key)
     struct cmdq_item *item, key_code key)  
 {  {
           struct cmd_find_state           *fs = &item->target;
         struct window_mode_entry        *wme;          struct window_mode_entry        *wme;
         struct key_table                *table;          struct key_table                *table;
         struct key_binding              *bd;          struct key_binding              *bd;
Line 81 
Line 81 
         return (item);          return (item);
 }  }
   
   static struct cmdq_item *
   cmd_send_keys_inject_string(struct client *c, struct cmdq_item *item,
       struct args *args, int i)
   {
           const char              *s = args->argv[i];
           struct utf8_data        *ud, *uc;
           wchar_t                  wc;
           key_code                 key;
           char                    *endptr;
           long                     n;
           int                      literal;
   
           if (args_has(args, 'H')) {
                   n = strtol(s, &endptr, 16);
                   if (*s =='\0' || n < 0 || n > 0xff || *endptr != '\0')
                           return (item);
                   return (cmd_send_keys_inject_key(c, item, KEYC_LITERAL|n));
           }
   
           literal = args_has(args, 'l');
           if (!literal) {
                   key = key_string_lookup_string(s);
                   if (key != KEYC_NONE && key != KEYC_UNKNOWN)
                           return (cmd_send_keys_inject_key(c, item, key));
                   literal = 1;
           }
           if (literal) {
                   ud = utf8_fromcstr(s);
                   for (uc = ud; uc->size != 0; uc++) {
                           if (utf8_combine(uc, &wc) != UTF8_DONE)
                                   continue;
                           item = cmd_send_keys_inject_key(c, item, wc);
                           }
                   free(ud);
           }
           return (item);
   }
   
 static enum cmd_retval  static enum cmd_retval
 cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)  cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
 {  {
Line 90 
Line 128 
         struct session                  *s = item->target.s;          struct session                  *s = item->target.s;
         struct winlink                  *wl = item->target.wl;          struct winlink                  *wl = item->target.wl;
         struct mouse_event              *m = &item->shared->mouse;          struct mouse_event              *m = &item->shared->mouse;
         struct cmd_find_state           *fs = &item->target;  
         struct window_mode_entry        *wme = TAILQ_FIRST(&wp->modes);          struct window_mode_entry        *wme = TAILQ_FIRST(&wp->modes);
         struct utf8_data                *ud, *uc;          int                              i;
         wchar_t                          wc;  
         int                              i, literal;  
         key_code                         key;          key_code                         key;
         u_int                            np = 1;          u_int                            np = 1;
         char                            *cause = NULL;          char                            *cause = NULL;
Line 141 
Line 176 
                         key = options_get_number(s->options, "prefix2");                          key = options_get_number(s->options, "prefix2");
                 else                  else
                         key = options_get_number(s->options, "prefix");                          key = options_get_number(s->options, "prefix");
                 cmd_send_keys_inject(c, fs, item, key);                  cmd_send_keys_inject_key(c, item, key);
                 return (CMD_RETURN_NORMAL);                  return (CMD_RETURN_NORMAL);
         }          }
   
Line 151 
Line 186 
         }          }
   
         for (; np != 0; np--) {          for (; np != 0; np--) {
                 for (i = 0; i < args->argc; i++) {                  for (i = 0; i < args->argc; i++)
                         literal = args_has(args, 'l');                          item = cmd_send_keys_inject_string(c, item, args, i);
                         if (!literal) {  
                                 key = key_string_lookup_string(args->argv[i]);  
                                 if (key != KEYC_NONE && key != KEYC_UNKNOWN) {  
                                         item = cmd_send_keys_inject(c, fs, item,  
                                             key);  
                                 } else  
                                         literal = 1;  
                         }  
                         if (literal) {  
                                 ud = utf8_fromcstr(args->argv[i]);  
                                 for (uc = ud; uc->size != 0; uc++) {  
                                         if (utf8_combine(uc, &wc) != UTF8_DONE)  
                                                 continue;  
                                         item = cmd_send_keys_inject(c, fs, item,  
                                             wc);  
                                 }  
                                 free(ud);  
                         }  
                 }  
   
         }          }
   
         return (CMD_RETURN_NORMAL);          return (CMD_RETURN_NORMAL);

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49