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

📄 bind.c

📁 在非GUI环境下
💻 C
📖 第 1 页 / 共 4 页
字号:
#if defined (VI_MODE)  { "vi", vi_movement_keymap },  { "vi-move", vi_movement_keymap },  { "vi-command", vi_movement_keymap },  { "vi-insert", vi_insertion_keymap },#endif /* VI_MODE */  { (char *)0x0, (Keymap)0x0 }};Keymaprl_get_keymap_by_name (name)     const char *name;{  register int i;  for (i = 0; keymap_names[i].name; i++)    if (_rl_stricmp (name, keymap_names[i].name) == 0)      return (keymap_names[i].map);  return ((Keymap) NULL);}char *rl_get_keymap_name (map)     Keymap map;{  register int i;  for (i = 0; keymap_names[i].name; i++)    if (map == keymap_names[i].map)      return ((char *)keymap_names[i].name);  return ((char *)NULL);}  voidrl_set_keymap (map)     Keymap map;{  if (map)    _rl_keymap = map;}Keymaprl_get_keymap (){  return (_rl_keymap);}voidrl_set_keymap_from_edit_mode (){  if (rl_editing_mode == emacs_mode)    _rl_keymap = emacs_standard_keymap;#if defined (VI_MODE)  else if (rl_editing_mode == vi_mode)    _rl_keymap = vi_insertion_keymap;#endif /* VI_MODE */}char *rl_get_keymap_name_from_edit_mode (){  if (rl_editing_mode == emacs_mode)    return "emacs";#if defined (VI_MODE)  else if (rl_editing_mode == vi_mode)    return "vi";#endif /* VI_MODE */  else    return "none";}/* **************************************************************** *//*								    *//*		  Key Binding and Function Information		    *//*								    *//* **************************************************************** *//* Each of the following functions produces information about the   state of keybindings and functions known to Readline.  The info   is always printed to rl_outstream, and in such a way that it can   be read back in (i.e., passed to rl_parse_and_bind ()). *//* Print the names of functions known to Readline. */voidrl_list_funmap_names (){  register int i;  const char **funmap_names;  funmap_names = rl_funmap_names ();  if (!funmap_names)    return;  for (i = 0; funmap_names[i]; i++)    fprintf (rl_outstream, "%s\n", funmap_names[i]);  free (funmap_names);}static char *_rl_get_keyname (key)     int key;{  char *keyname;  int i, c;  keyname = (char *)xmalloc (8);  c = key;  /* Since this is going to be used to write out keysequence-function     pairs for possible inclusion in an inputrc file, we don't want to     do any special meta processing on KEY. */#if 1  /* XXX - Experimental */  /* We might want to do this, but the old version of the code did not. */  /* If this is an escape character, we don't want to do any more processing.     Just add the special ESC key sequence and return. */  if (c == ESC)    {      keyname[0] = '\\';      keyname[1] = 'e';      keyname[2] = '\0';      return keyname;    }#endif  /* RUBOUT is translated directly into \C-? */  if (key == RUBOUT)    {      keyname[0] = '\\';      keyname[1] = 'C';      keyname[2] = '-';      keyname[3] = '?';      keyname[4] = '\0';      return keyname;    }  i = 0;  /* Now add special prefixes needed for control characters.  This can     potentially change C. */  if (CTRL_CHAR (c))    {      keyname[i++] = '\\';      keyname[i++] = 'C';      keyname[i++] = '-';      c = _rl_to_lower (UNCTRL (c));    }  /* XXX experimental code.  Turn the characters that are not ASCII or     ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237).     This changes C. */  if (c >= 128 && c <= 159)    {      keyname[i++] = '\\';      keyname[i++] = '2';      c -= 128;      keyname[i++] = (c / 8) + '0';      c = (c % 8) + '0';    }  /* Now, if the character needs to be quoted with a backslash, do that. */  if (c == '\\' || c == '"')    keyname[i++] = '\\';  /* Now add the key, terminate the string, and return it. */  keyname[i++] = (char) c;  keyname[i] = '\0';  return keyname;}/* Return a NULL terminated array of strings which represent the key   sequences that are used to invoke FUNCTION in MAP. */char **rl_invoking_keyseqs_in_map (function, map)     rl_command_func_t *function;     Keymap map;{  register int key;  char **result;  int result_index, result_size;  result = (char **)NULL;  result_index = result_size = 0;  for (key = 0; key < KEYMAP_SIZE; key++)    {      switch (map[key].type)	{	case ISMACR:	  /* Macros match, if, and only if, the pointers are identical.	     Thus, they are treated exactly like functions in here. */	case ISFUNC:	  /* If the function in the keymap is the one we are looking for,	     then add the current KEY to the list of invoking keys. */	  if (map[key].function == function)	    {	      char *keyname;	      keyname = _rl_get_keyname (key);	      if (result_index + 2 > result_size)	        {	          result_size += 10;		  result = (char **)xrealloc (result, result_size * sizeof (char *));	        }	      result[result_index++] = keyname;	      result[result_index] = (char *)NULL;	    }	  break;	case ISKMAP:	  {	    char **seqs;	    register int i;	    /* Find the list of keyseqs in this map which have FUNCTION as	       their target.  Add the key sequences found to RESULT. */	    if (map[key].function)	      seqs =	        rl_invoking_keyseqs_in_map (function, FUNCTION_TO_KEYMAP (map, key));	    else	      break;	    if (seqs == 0)	      break;	    for (i = 0; seqs[i]; i++)	      {		char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));		if (key == ESC)#if 0		  sprintf (keyname, "\\e");#else		/* XXX - experimental */		  sprintf (keyname, "\\M-");#endif		else if (CTRL_CHAR (key))		  sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));		else if (key == RUBOUT)		  sprintf (keyname, "\\C-?");		else if (key == '\\' || key == '"')		  {		    keyname[0] = '\\';		    keyname[1] = (char) key;		    keyname[2] = '\0';		  }		else		  {		    keyname[0] = (char) key;		    keyname[1] = '\0';		  }				strcat (keyname, seqs[i]);		free (seqs[i]);		if (result_index + 2 > result_size)		  {		    result_size += 10;		    result = (char **)xrealloc (result, result_size * sizeof (char *));		  }		result[result_index++] = keyname;		result[result_index] = (char *)NULL;	      }	    free (seqs);	  }	  break;	}    }  return (result);}/* Return a NULL terminated array of strings which represent the key   sequences that can be used to invoke FUNCTION using the current keymap. */char **rl_invoking_keyseqs (function)     rl_command_func_t *function;{  return (rl_invoking_keyseqs_in_map (function, _rl_keymap));}/* Print all of the functions and their bindings to rl_outstream.  If   PRINT_READABLY is non-zero, then print the output in such a way   that it can be read back in. */voidrl_function_dumper (print_readably)     int print_readably;{  register int i;  const char **names;  const char *name;  names = rl_funmap_names ();  fprintf (rl_outstream, "\n");  for (i = 0; name = names[i]; i++)    {      rl_command_func_t *function;      char **invokers;      function = rl_named_function (name);      invokers = rl_invoking_keyseqs_in_map (function, _rl_keymap);      if (print_readably)	{	  if (!invokers)	    fprintf (rl_outstream, "# %s (not bound)\n", name);	  else	    {	      register int j;	      for (j = 0; invokers[j]; j++)		{		  fprintf (rl_outstream, "\"%s\": %s\n",			   invokers[j], name);		  free (invokers[j]);		}	      free (invokers);	    }	}      else	{	  if (!invokers)	    fprintf (rl_outstream, "%s is not bound to any keys\n",		     name);	  else	    {	      register int j;	      fprintf (rl_outstream, "%s can be found on ", name);	      for (j = 0; invokers[j] && j < 5; j++)		{		  fprintf (rl_outstream, "\"%s\"%s", invokers[j],			   invokers[j + 1] ? ", " : ".\n");		}	      if (j == 5 && invokers[j])		fprintf (rl_outstream, "...\n");	      for (j = 0; invokers[j]; j++)		free (invokers[j]);	      free (invokers);	    }	}    }}/* Print all of the current functions and their bindings to   rl_outstream.  If an explicit argument is given, then print   the output in such a way that it can be read back in. */intrl_dump_functions (count, key)     int count, key;{  if (rl_dispatching)    fprintf (rl_outstream, "\r\n");  rl_function_dumper (rl_explicit_arg);  rl_on_new_line ();  return (0);}static void_rl_macro_dumper_internal (print_readably, map, prefix)     int print_readably;     Keymap map;     char *prefix;{  register int key;  char *keyname, *out;  int prefix_len;  for (key = 0; key < KEYMAP_SIZE; key++)    {      switch (map[key].type)	{	case ISMACR:	  keyname = _rl_get_keyname (key);	  out = _rl_untranslate_macro_value ((char *)map[key].function);	  if (print_readably)	    fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "",						         keyname,						         out ? out : "");	  else	    fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "",							keyname,							out ? out : "");	  free (keyname);	  free (out);	  break;	case ISFUNC:	  break;	case ISKMAP:	  prefix_len = prefix ? strlen (prefix) : 0;	  if (key == ESC)	    {	      keyname = (char *)xmalloc (3 + prefix_len);	      if (prefix)		strcpy (keyname, prefix);	      keyname[prefix_len] = '\\';	      keyname[prefix_len + 1] = 'e';	      keyname[prefix_len + 2] = '\0';	    }	  else	    {	      keyname = _rl_get_keyname (key);	      if (prefix)		{		  out = (char *)xmalloc (strlen (keyname) + prefix_len + 1);		  strcpy (out, prefix);		  strcpy (out + prefix_len, keyname);		  free (keyname);		  keyname = out;		}	    }	  _rl_macro_dumper_internal (print_readably, FUNCTION_TO_KEYMAP (map, key), keyname);	  free (keyname);	  break;	}    }}voidrl_macro_dumper (print_readably)     int print_readably;{  _rl_macro_dumper_internal (print_readably, _rl_keymap, (char *)NULL);}intrl_dump_macros (count, key)     int count, key;{  if (rl_dispatching)    fprintf (rl_outstream, "\r\n");  rl_macro_dumper (rl_explicit_arg);  rl_on_new_line ();  return (0);}voidrl_variable_dumper (print_readably)     int print_readably;{  int i;  const char *kname;  for (i = 0; boolean_varlist[i].name; i++)    {      if (print_readably)        fprintf (rl_outstream, "set %s %s\n", boolean_varlist[i].name,			       *boolean_varlist[i].value ? "on" : "off");      else        fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name,			       *boolean_varlist[i].value ? "on" : "off");    }  /* bell-style */  switch (_rl_bell_preference)    {    case NO_BELL:      kname = "none"; break;    case VISIBLE_BELL:      kname = "visible"; break;    case AUDIBLE_BELL:    default:      kname = "audible"; break;    }  if (print_readably)    fprintf (rl_outstream, "set bell-style %s\n", kname);  else    fprintf (rl_outstream, "bell-style is set to `%s'\n", kname);  /* comment-begin */  if (print_readably)    fprintf (rl_outstream, "set comment-begin %s\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);  else    fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);  /* completion-query-items */  if (print_readably)    fprintf (rl_outstream, "set completion-query-items %d\n", rl_completion_query_items);  else    fprintf (rl_outstream, "completion-query-items is set to `%d'\n", rl_completion_query_items);  /* editing-mode */  if (print_readably)    fprintf (rl_outstream, "set editing-mode %s\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi");  else    fprintf (rl_outstream, "editing-mode is set to `%s'\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi");  /* isearch-terminators */  if (_rl_isearch_terminators)    {      char *disp;      disp = _rl_untranslate_macro_value (_rl_isearch_terminators);      if (print_readably)	fprintf (rl_outstream, "set isearch-terminators \"%s\"\n", disp);      else	fprintf (rl_outstream, "isearch-terminators is set to \"%s\"\n", disp);      free (disp);    }  /* keymap */  kname = rl_get_keymap_name (_rl_keymap);  if (kname == 0)    kname = rl_get_keymap_name_from_edit_mode ();  if (print_readably)    fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none");  else    fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none");}/* Print all of the current variables and their values to   rl_outstream.  If an explicit argument is given, then print   the output in such a way that it can be read back in. */intrl_dump_variables (count, key)     int count, key;{  if (rl_dispatching)    fprintf (rl_outstream, "\r\n");  rl_variable_dumper (rl_explicit_arg);  rl_on_new_line ();  return (0);}/* Return non-zero if any members of ARRAY are a substring in STRING. */static intsubstring_member_of_array (string, array)     char *string;     const char **array;{  while (*array)    {      if (_rl_strindex (string, *array))	return (1);      array++;    }  return (0);}

⌨️ 快捷键说明

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