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

Diff for /src/usr.bin/tmux/cmd-command-prompt.c between version 1.55 and 1.56

version 1.55, 2021/06/10 07:52:56 version 1.56, 2021/08/13 06:50:42
Line 40 
Line 40 
         .name = "command-prompt",          .name = "command-prompt",
         .alias = NULL,          .alias = NULL,
   
         .args = { "1FkiI:Np:t:T:", 0, 1 },          .args = { "1bFkiI:Np:t:T:", 0, 1 },
         .usage = "[-1FkiN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE          .usage = "[-1bFkiN] [-I inputs] [-p prompts] " CMD_TARGET_CLIENT_USAGE
                  " [-T type] [template]",                   " [-T type] [template]",
   
         .flags = CMD_CLIENT_TFLAG,          .flags = CMD_CLIENT_TFLAG,
Line 49 
Line 49 
 };  };
   
 struct cmd_command_prompt_cdata {  struct cmd_command_prompt_cdata {
         int              flags;          struct cmdq_item        *item;
         enum prompt_type prompt_type;          struct cmd_parse_input   pi;
   
         char            *inputs;          int                      flags;
         char            *next_input;          enum prompt_type         prompt_type;
   
         char            *prompts;          char                    *inputs;
         char            *next_prompt;          char                    *next_input;
   
         char            *template;          char                    *prompts;
         int              idx;          char                    *next_prompt;
   
           char                    *template;
           int                      idx;
 };  };
   
 static enum cmd_retval  static enum cmd_retval
Line 72 
Line 75 
         struct cmd_command_prompt_cdata *cdata;          struct cmd_command_prompt_cdata *cdata;
         char                            *prompt, *ptr, *input = NULL;          char                            *prompt, *ptr, *input = NULL;
         size_t                           n;          size_t                           n;
           int                              wait = !args_has(args, 'b');
   
         if (tc->prompt_string != NULL)          if (tc->prompt_string != NULL)
                 return (CMD_RETURN_NORMAL);                  return (CMD_RETURN_NORMAL);
   
         cdata = xcalloc(1, sizeof *cdata);          cdata = xcalloc(1, sizeof *cdata);
           cdata->idx = 1;
   
         cdata->inputs = NULL;          cmd_get_source(self, &cdata->pi.file, &cdata->pi.line);
         cdata->next_input = NULL;          if (wait)
                   cdata->pi.item = item;
           cdata->pi.c = tc;
           cmd_find_copy_state(&cdata->pi.fs, target);
   
         cdata->prompts = NULL;          if (wait)
         cdata->next_prompt = NULL;                  cdata->item = item;
   
         cdata->template = NULL;  
         cdata->idx = 1;  
   
         if (args->argc != 0 && args_has(args, 'F'))          if (args->argc != 0 && args_has(args, 'F'))
             cdata->template = format_single_from_target(item, args->argv[0]);              cdata->template = format_single_from_target(item, args->argv[0]);
         else if (args->argc != 0)          else if (args->argc != 0)
Line 140 
Line 145 
             cdata->flags, cdata->prompt_type);              cdata->flags, cdata->prompt_type);
         free(prompt);          free(prompt);
   
         return (CMD_RETURN_NORMAL);          if (!wait)
                   return (CMD_RETURN_NORMAL);
           return (CMD_RETURN_WAIT);
 }  }
   
 static int  static int
Line 150 
Line 157 
         struct cmd_command_prompt_cdata *cdata = data;          struct cmd_command_prompt_cdata *cdata = data;
         char                            *new_template, *prompt, *ptr, *error;          char                            *new_template, *prompt, *ptr, *error;
         char                            *input = NULL;          char                            *input = NULL;
           struct cmdq_item                *item = cdata->item;
         enum cmd_parse_status            status;          enum cmd_parse_status            status;
   
         if (s == NULL)          if (s == NULL)
                 return (0);                  goto out;
         if (done && (cdata->flags & PROMPT_INCREMENTAL))          if (done && (cdata->flags & PROMPT_INCREMENTAL))
                 return (0);                  goto out;
   
         new_template = cmd_template_replace(cdata->template, s, cdata->idx);          new_template = cmd_template_replace(cdata->template, s, cdata->idx);
         if (done) {          if (done) {
Line 177 
Line 185 
                 return (1);                  return (1);
         }          }
   
         status = cmd_parse_and_append(new_template, NULL, c, NULL, &error);          if (item != NULL) {
                   status = cmd_parse_and_insert(new_template, &cdata->pi, item,
                       cmdq_get_state(item), &error);
           } else {
                   status = cmd_parse_and_append(new_template, &cdata->pi, c, NULL,
                       &error);
           }
         if (status == CMD_PARSE_ERROR) {          if (status == CMD_PARSE_ERROR) {
                 cmdq_append(c, cmdq_get_error(error));                  cmdq_append(c, cmdq_get_error(error));
                 free(error);                  free(error);
Line 187 
Line 201 
                 free(new_template);                  free(new_template);
         if (c->prompt_inputcb != cmd_command_prompt_callback)          if (c->prompt_inputcb != cmd_command_prompt_callback)
                 return (1);                  return (1);
   
   out:
           if (item != NULL)
                   cmdq_continue(item);
         return (0);          return (0);
 }  }
   

Legend:
Removed from v.1.55  
changed lines
  Added in v.1.56