⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complete.def

📁 android-w.song.android.widget
💻 DEF
📖 第 1 页 / 共 2 页
字号:
}static intremove_cmd_completions (list)     WORD_LIST *list;{  WORD_LIST *l;  int ret;  for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next)    {      if (progcomp_remove (l->word->word) == 0)	{	  builtin_error (_("%s: no completion specification"), l->word->word);	  ret = EXECUTION_FAILURE;	}    }  return ret;}#define SQPRINTARG(a, f) \  do { \    if (a) \      { \      	x = sh_single_quote (a); \	printf ("%s %s ", f, x); \	free (x); \      } \  } while (0)#define PRINTARG(a, f) \  do { \    if (a) \      printf ("%s %s ", f, a); \  } while (0)#define PRINTOPT(a, f) \  do { \    if (acts & a) \      printf ("%s ", f); \  } while (0)#define PRINTACT(a, f) \  do { \    if (acts & a) \      printf ("-A %s ", f); \  } while (0)#define PRINTCOMPOPT(a, f) \  do { \    if (copts & a) \      printf ("-o %s ", f); \  } while (0)#define XPRINTCOMPOPT(a, f) \  do { \    if (copts & a) \      printf ("-o %s ", f); \    else \      printf ("+o %s ", f); \  } while (0)static intprint_one_completion (cmd, cs)     char *cmd;     COMPSPEC *cs;{  unsigned long acts, copts;  char *x;  printf ("complete ");  copts = cs->options;  /* First, print the -o options. */  PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");  PRINTCOMPOPT (COPT_DEFAULT, "default");  PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");  PRINTCOMPOPT (COPT_FILENAMES, "filenames");  PRINTCOMPOPT (COPT_NOSPACE, "nospace");  PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");  acts = cs->actions;  /* simple flags next */  PRINTOPT (CA_ALIAS, "-a");  PRINTOPT (CA_BUILTIN, "-b");  PRINTOPT (CA_COMMAND, "-c");  PRINTOPT (CA_DIRECTORY, "-d");  PRINTOPT (CA_EXPORT, "-e");  PRINTOPT (CA_FILE, "-f");  PRINTOPT (CA_GROUP, "-g");  PRINTOPT (CA_JOB, "-j");  PRINTOPT (CA_KEYWORD, "-k");  PRINTOPT (CA_SERVICE, "-s");  PRINTOPT (CA_USER, "-u");  PRINTOPT (CA_VARIABLE, "-v");  /* now the rest of the actions */  PRINTACT (CA_ARRAYVAR, "arrayvar");  PRINTACT (CA_BINDING, "binding");  PRINTACT (CA_DISABLED, "disabled");  PRINTACT (CA_ENABLED, "enabled");  PRINTACT (CA_FUNCTION, "function");  PRINTACT (CA_HELPTOPIC, "helptopic");  PRINTACT (CA_HOSTNAME, "hostname");  PRINTACT (CA_RUNNING, "running");  PRINTACT (CA_SETOPT, "setopt");  PRINTACT (CA_SHOPT, "shopt");  PRINTACT (CA_SIGNAL, "signal");  PRINTACT (CA_STOPPED, "stopped");  /* now the rest of the arguments */  /* arguments that require quoting */  SQPRINTARG (cs->globpat, "-G");  SQPRINTARG (cs->words, "-W");  SQPRINTARG (cs->prefix, "-P");  SQPRINTARG (cs->suffix, "-S");  SQPRINTARG (cs->filterpat, "-X");  SQPRINTARG (cs->command, "-C");  /* simple arguments that don't require quoting */  PRINTARG (cs->funcname, "-F");  if (STREQ (cmd, EMPTYCMD))    printf ("-E\n");  else if (STREQ (cmd, DEFAULTCMD))    printf ("-D\n");  else    printf ("%s\n", cmd);  return (0);}static voidprint_compopts (cmd, cs, full)     const char *cmd;     COMPSPEC *cs;     int full;{  int copts;  printf ("compopt ");  copts = cs->options;  if (full)    {      XPRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");      XPRINTCOMPOPT (COPT_DEFAULT, "default");      XPRINTCOMPOPT (COPT_DIRNAMES, "dirnames");      XPRINTCOMPOPT (COPT_FILENAMES, "filenames");      XPRINTCOMPOPT (COPT_NOSPACE, "nospace");      XPRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");    }  else    {      PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault");      PRINTCOMPOPT (COPT_DEFAULT, "default");      PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");      PRINTCOMPOPT (COPT_FILENAMES, "filenames");      PRINTCOMPOPT (COPT_NOSPACE, "nospace");      PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");    }  if (STREQ (cmd, EMPTYCMD))    printf ("-E\n");  else if (STREQ (cmd, DEFAULTCMD))    printf ("-D\n");  else    printf ("%s\n", cmd);}static intprint_compitem (item)     BUCKET_CONTENTS *item;{  COMPSPEC *cs;  char *cmd;  cmd = item->key;  cs = (COMPSPEC *)item->data;  return (print_one_completion (cmd, cs));}static voidprint_all_completions (){  progcomp_walk (print_compitem);}static intprint_cmd_completions (list)     WORD_LIST *list;{  WORD_LIST *l;  COMPSPEC *cs;  int ret;  for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next)    {      cs = progcomp_search (l->word->word);      if (cs)	print_one_completion (l->word->word, cs);      else	{	  builtin_error (_("%s: no completion specification"), l->word->word);	  ret = EXECUTION_FAILURE;	}    }  return (sh_chkwrite (ret));}$BUILTIN compgen$DEPENDS_ON PROGRAMMABLE_COMPLETION$FUNCTION compgen_builtin$SHORT_DOC compgen [-abcdefgjksuv] [-o option]  [-A action] [-G globpat] [-W wordlist]  [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]Display possible completions depending on the options.Intended to be used from within a shell function generating possiblecompletions.  If the optional WORD argument is supplied, matches againstWORD are generated.Exit Status:Returns success unless an invalid option is supplied or an error occurs.$ENDintcompgen_builtin (list)     WORD_LIST *list;{  int rval;  unsigned long acts, copts;  COMPSPEC *cs;  STRINGLIST *sl;  char *word, **matches;  if (list == 0)    return (EXECUTION_SUCCESS);  acts = copts = (unsigned long)0L;  Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;  cs = (COMPSPEC *)NULL;  /* Build the actions from the arguments.  Also sets the [A-Z]arg variables     as a side effect if they are supplied as options. */  rval = build_actions (list, (struct _optflags *)NULL, &acts, &copts);  if (rval == EX_USAGE)    return (rval);  if (rval == EXECUTION_FAILURE)    return (EXECUTION_SUCCESS);  list = loptend;  word = (list && list->word) ? list->word->word : "";  if (Farg)    builtin_error (_("warning: -F option may not work as you expect"));  if (Carg)    builtin_error (_("warning: -C option may not work as you expect"));  /* If we get here, we need to build a compspec and evaluate it. */  cs = compspec_create ();  cs->actions = acts;  cs->options = copts;  cs->refcount = 1;  cs->globpat = STRDUP (Garg);  cs->words = STRDUP (Warg);  cs->prefix = STRDUP (Parg);  cs->suffix = STRDUP (Sarg);  cs->funcname = STRDUP (Farg);  cs->command = STRDUP (Carg);  cs->filterpat = STRDUP (Xarg);  rval = EXECUTION_FAILURE;  sl = gen_compspec_completions (cs, "compgen", word, 0, 0, 0);  /* If the compspec wants the bash default completions, temporarily     turn off programmable completion and call the bash completion code. */  if ((sl == 0 || sl->list_len == 0) && (copts & COPT_BASHDEFAULT))    {      matches = bash_default_completion (word, 0, 0, 0, 0);      sl = completions_to_stringlist (matches);      strvec_dispose (matches);    }  /* This isn't perfect, but it's the best we can do, given what readline     exports from its set of completion utility functions. */  if ((sl == 0 || sl->list_len == 0) && (copts & COPT_DEFAULT))    {      matches = rl_completion_matches (word, rl_filename_completion_function);      sl = completions_to_stringlist (matches);      strvec_dispose (matches);    }  if (sl)    {      if (sl->list && sl->list_len)	{	  rval = EXECUTION_SUCCESS;	  strlist_print (sl, (char *)NULL);	}      strlist_dispose (sl);    }  compspec_dispose (cs);  return (rval);}$BUILTIN compopt$DEPENDS_ON PROGRAMMABLE_COMPLETION$FUNCTION compopt_builtin$SHORT_DOC compopt [-o|+o option] [-DE] [name ...]Modify or display completion options.Modify the completion options for each NAME, or, if no NAMEs are supplied,the completion currently being executed.  If no OPTIONs are given, printthe completion options for each NAME or the current completion specification.Options:	-o option	Set completion option OPTION for each NAME	-D		Change options for the "default" command completion	-E		Change options for the "empty" command completionUsing `+o' instead of `-o' turns off the specified option.Arguments:Each NAME refers to a command for which a completion specification musthave previously been defined using the `complete' builtin.  If no NAMEsare supplied, compopt must be called by a function currently generatingcompletions, and the options for that currently-executing completiongenerator are modified.Exit Status:Returns success unless an invalid option is supplied or NAME does nothave a completion specification defined.$ENDintcompopt_builtin (list)     WORD_LIST *list;{  int opts_on, opts_off, *opts, opt, oind, ret, Dflag, Eflag;  WORD_LIST *l, *wl;  COMPSPEC *cs;  opts_on = opts_off = Eflag = Dflag = 0;  ret = EXECUTION_SUCCESS;  reset_internal_getopt ();  while ((opt = internal_getopt (list, "+o:DE")) != EOF)    {      opts = (list_opttype == '-') ? &opts_on : &opts_off;      switch (opt)	{	case 'o':	  oind = find_compopt (list_optarg);	  if (oind < 0)	    {	      sh_invalidoptname (list_optarg);	      return (EX_USAGE);	    }	  *opts |= compopts[oind].optflag;	  break;	case 'D':	  Dflag = 1;	  break;	case 'E':	  Eflag = 1;	  break;	default:	  builtin_usage ();	  return (EX_USAGE);	}    }  list = loptend;  wl = Dflag ? make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL)	     : (Eflag ? make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL) : 0);  if (list == 0 && wl == 0)    {      if (RL_ISSTATE (RL_STATE_COMPLETING) == 0 || pcomp_curcs == 0)	{	  builtin_error (_("not currently executing completion function"));	  return (EXECUTION_FAILURE);	}      cs = pcomp_curcs;      if (opts_on == 0 && opts_off == 0)	{	  print_compopts (pcomp_curcmd, cs, 1);          return (sh_chkwrite (ret));	}      /* Set the compspec options */      pcomp_set_compspec_options (cs, opts_on, 1);      pcomp_set_compspec_options (cs, opts_off, 0);      /* And change the readline variables the options control */      pcomp_set_readline_variables (opts_on, 1);      pcomp_set_readline_variables (opts_off, 0);      return (ret);    }  for (l = wl ? wl : list; l; l = l->next)    {      cs = progcomp_search (l->word->word);      if (cs == 0)	{	  builtin_error (_("%s: no completion specification"), l->word->word);	  ret = EXECUTION_FAILURE;	  continue;	}      if (opts_on == 0 && opts_off == 0)	{	  print_compopts (l->word->word, cs, 1);	  continue;			/* XXX -- fill in later */	}      /* Set the compspec options */      pcomp_set_compspec_options (cs, opts_on, 1);      pcomp_set_compspec_options (cs, opts_off, 0);    }  return (ret);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -