#include "config_readline.h"
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include "ansi_stdlib.h"
#include <errno.h>
#include "posixstat.h"
#include "rldefs.h"
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
Go to the source code of this file.
Data Structures | |
| struct | assoc_list |
Defines | |
| #define | READLINE_LIBRARY |
| #define | V_BELLSTYLE 0 |
| #define | V_COMBEGIN 1 |
| #define | V_EDITMODE 2 |
| #define | V_INT 2 |
| #define | V_ISRCHTERM 3 |
| #define | V_KEYMAP 4 |
| #define | V_SPECIAL 0x1 |
| #define | V_STRING 1 |
Typedefs | |
| typedef int _rl_parser_func_t | PARAMS ((char *)) |
Functions | |
| void | _rl_bind_if_unbound (char *keyseq, rl_command_func_t *default_func) const |
| static char * | _rl_get_keyname (int key) |
| static void | _rl_init_file_error (char *msg) const |
| static void | _rl_macro_dumper_internal (int print_readably, Keymap map, char *prefix) |
| static char * | _rl_read_file (char *filename, size_t *sizep) |
| static int | _rl_read_init_file (char *filename, int include_level) const |
| static char * | _rl_untranslate_macro_value (char *seq) |
| static int | bool_to_int (char *value) |
| static int | find_boolean_var (char *name) const |
| static int | find_string_var (char *name) const |
| static int | glean_key_from_name (char *name) |
| static void | hack_special_boolean_var (int i) |
| static int | handle_parser_directive (char *statement) |
| static int | parser_else (args) |
| static int | parser_endif (args) |
| static int | parser_if (char *args) |
| static int | parser_include (char *args) |
| int | rl_add_defun (char *name, rl_command_func_t *function, int key) const |
| int | rl_bind_key (int key, rl_command_func_t *function) |
| int | rl_bind_key_in_map (int key, rl_command_func_t *function, Keymap map) |
| int | rl_dump_functions (count, key) |
| int | rl_dump_macros (count, key) |
| int | rl_dump_variables (count, key) |
| void | rl_function_dumper (int print_readably) |
| rl_command_func_t * | rl_function_of_keyseq (char *keyseq, Keymap map, int *type) const |
| int | rl_generic_bind (int type, const char *keyseq, char *data, Keymap map) |
| Keymap | rl_get_keymap () |
| Keymap | rl_get_keymap_by_name (char *name) const |
| char * | rl_get_keymap_name (Keymap map) |
| const char * | rl_get_keymap_name_from_edit_mode () |
| char ** | rl_invoking_keyseqs (rl_command_func_t *function) |
| char ** | rl_invoking_keyseqs_in_map (rl_command_func_t *function, Keymap map) |
| void | rl_list_funmap_names () |
| int | rl_macro_bind (char *keyseq, char *macro, Keymap map) const |
| void | rl_macro_dumper (int print_readably) |
| rl_command_func_t * | rl_named_function (char *string) const |
| int | rl_parse_and_bind (char *string) |
| int | rl_re_read_init_file (count, ignore) |
| int | rl_read_init_file (char *filename) const |
| int | rl_set_key (char *keyseq, rl_command_func_t *function, Keymap map) const |
| void | rl_set_keymap (Keymap map) |
| void | rl_set_keymap_from_edit_mode () |
| int | rl_translate_keyseq (char *seq, char *array, int *len) const |
| int | rl_unbind_command_in_map (char *command, Keymap map) const |
| int | rl_unbind_function_in_map (rl_command_func_t *func, Keymap map) |
| int | rl_unbind_key (int key) |
| int | rl_unbind_key_in_map (int key, Keymap map) |
| char * | rl_untranslate_keyseq (int seq) |
| int | rl_variable_bind (char *name, char *value) const |
| void | rl_variable_dumper (int print_readably) |
| char * | strchr () |
| char ** | strrchr () |
| static int | substring_member_of_array (char *string, const char **array) |
| static int | sv_bell_style (char *value) const |
| static int | sv_combegin (char *value) const |
| static int | sv_compquery (char *value) const |
| static int | sv_editmode (char *value) const |
| static int | sv_isrchterm (char *value) const |
| static int | sv_keymap (char *value) const |
Variables | |
| const char * | _rl_possible_control_prefixes [] |
| const char * | _rl_possible_meta_prefixes [] |
| static int | _rl_prefer_visible_bell = 1 |
| struct { | |
| int flags | |
| const char * name | |
| int * value | |
| } | boolean_varlist |
| static const char * | current_readline_init_file |
| static int | current_readline_init_include_level |
| static int | current_readline_init_lineno |
| static int | currently_reading_init_file |
| int | errno |
| static unsigned char * | if_stack = (unsigned char *)NULL |
| static int | if_stack_depth |
| static int | if_stack_size |
| struct { | |
| Keymap map | |
| const char * name | |
| } | keymap_names [] |
| static char * | last_readline_init_file = (char *)NULL |
| static assoc_list | name_key_alist [] |
| struct { | |
| const char * f0 | |
| const char * f2 | |
| int(* func )(EditLine *, int, const char **) | |
| _rl_parser_func_t * function | |
| int m_bug | |
| int(* m_test )() | |
| const char * name | |
| const char * name | |
| u_int32_t power | |
| u_int32_t prime | |
| } | parser_directives |
| Keymap | rl_binding_keymap |
| const char * | rl_readline_name = "other" |
| struct { | |
| int flags | |
| const char * name | |
| _rl_sv_func_t * set_func | |
| } | string_varlist [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1255 of file bind.c. Referenced by rl_variable_bind(). |
|
|
|
|
|
|
|
||||||||||||
|
Definition at line 2118 of file bind.c. References _rl_keymap, func, NULL, rl_do_lowercase_version(), rl_function_of_keyseq(), rl_set_key(), and rl_vi_movement_mode(). Referenced by bind_arrow_keys_internal(), and bind_termcap_arrow_keys(). 02121 { 02122 rl_command_func_t *func; 02123 02124 if (keyseq) 02125 { 02126 func = rl_function_of_keyseq (keyseq, _rl_keymap, (int *)NULL); 02127 #if defined (VI_MODE) 02128 if (!func || func == rl_do_lowercase_version || func == rl_vi_movement_mode) 02129 #else 02130 if (!func || func == rl_do_lowercase_version) 02131 #endif 02132 rl_set_key (keyseq, default_func, _rl_keymap); 02133 } 02134 }
|
|
|
Definition at line 1673 of file bind.c. References _rl_to_lower, CTRL_CHAR, ESC, RUBOUT, UNCTRL, and xmalloc(). Referenced by _rl_macro_dumper_internal(), and rl_invoking_keyseqs_in_map(). 01675 { 01676 char *keyname; 01677 int i, c; 01678 01679 keyname = (char *)xmalloc (8); 01680 01681 c = key; 01682 /* Since this is going to be used to write out keysequence-function 01683 pairs for possible inclusion in an inputrc file, we don't want to 01684 do any special meta processing on KEY. */ 01685 01686 #if 1 01687 /* XXX - Experimental */ 01688 /* We might want to do this, but the old version of the code did not. */ 01689 01690 /* If this is an escape character, we don't want to do any more processing. 01691 Just add the special ESC key sequence and return. */ 01692 if (c == ESC) 01693 { 01694 keyname[0] = '\\'; 01695 keyname[1] = 'e'; 01696 keyname[2] = '\0'; 01697 return keyname; 01698 } 01699 #endif 01700 01701 /* RUBOUT is translated directly into \C-? */ 01702 if (key == RUBOUT) 01703 { 01704 keyname[0] = '\\'; 01705 keyname[1] = 'C'; 01706 keyname[2] = '-'; 01707 keyname[3] = '?'; 01708 keyname[4] = '\0'; 01709 return keyname; 01710 } 01711 01712 i = 0; 01713 /* Now add special prefixes needed for control characters. This can 01714 potentially change C. */ 01715 if (CTRL_CHAR (c)) 01716 { 01717 keyname[i++] = '\\'; 01718 keyname[i++] = 'C'; 01719 keyname[i++] = '-'; 01720 c = _rl_to_lower (UNCTRL (c)); 01721 } 01722 01723 /* XXX experimental code. Turn the characters that are not ASCII or 01724 ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237). 01725 This changes C. */ 01726 if (c >= 128 && c <= 159) 01727 { 01728 keyname[i++] = '\\'; 01729 keyname[i++] = '2'; 01730 c -= 128; 01731 keyname[i++] = (c / 8) + '0'; 01732 c = (c % 8) + '0'; 01733 } 01734 01735 /* Now, if the character needs to be quoted with a backslash, do that. */ 01736 if (c == '\\' || c == '"') 01737 keyname[i++] = '\\'; 01738 01739 /* Now add the key, terminate the string, and return it. */ 01740 keyname[i++] = (char) c; 01741 keyname[i] = '\0'; 01742 01743 return keyname; 01744 }
|
|
|
Definition at line 789 of file bind.c. Referenced by handle_parser_directive(), parser_else(), parser_endif(), and rl_parse_and_bind(). 00791 { 00792 if (currently_reading_init_file) 00793 fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file, 00794 current_readline_init_lineno, msg); 00795 else 00796 fprintf (stderr, "readline: %s\n", msg); 00797 }
|
|
||||||||||||||||
|
Definition at line 1945 of file bind.c. References _rl_get_keyname(), _rl_untranslate_macro_value(), ESC, free, function, FUNCTION_TO_KEYMAP, ISFUNC, ISKMAP, ISMACR, key, KEYMAP_SIZE, rl_outstream, and xmalloc(). Referenced by rl_macro_dumper(). 01949 { 01950 register int key; 01951 char *keyname, *out; 01952 int prefix_len; 01953 01954 for (key = 0; key < KEYMAP_SIZE; key++) 01955 { 01956 switch (map[key].type) 01957 { 01958 case ISMACR: 01959 keyname = _rl_get_keyname (key); 01960 out = _rl_untranslate_macro_value ((char *)map[key].function); 01961 01962 if (print_readably) 01963 fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "", 01964 keyname, 01965 out ? out : ""); 01966 else 01967 fprintf (rl_outstream, "%s%s outputs %s\n", prefix ? prefix : "", 01968 keyname, 01969 out ? out : ""); 01970 free (keyname); 01971 free (out); 01972 break; 01973 case ISFUNC: 01974 break; 01975 case ISKMAP: 01976 prefix_len = prefix ? strlen (prefix) : 0; 01977 if (key == ESC) 01978 { 01979 keyname = (char *)xmalloc (3 + prefix_len); 01980 if (prefix) 01981 strcpy (keyname, prefix); 01982 keyname[prefix_len] = '\\'; 01983 keyname[prefix_len + 1] = 'e'; 01984 keyname[prefix_len + 2] = '\0'; 01985 } 01986 else 01987 { 01988 keyname = _rl_get_keyname (key); 01989 if (prefix) 01990 { 01991 out = (char *)xmalloc (strlen (keyname) + prefix_len + 1); 01992 strcpy (out, prefix); 01993 strcpy (out + prefix_len, keyname); 01994 free (keyname); 01995 keyname = out; 01996 } 01997 } 01998 01999 _rl_macro_dumper_internal (print_readably, FUNCTION_TO_KEYMAP (map, key), keyname); 02000 free (keyname); 02001 break; 02002 } 02003 } 02004 }
|
|
||||||||||||
|
Definition at line 635 of file bind.c. References buffer, close(), EFBIG, errno, file, free, NULL, open(), read(), and xmalloc(). Referenced by _rl_read_init_file(). 00638 { 00639 struct stat finfo; 00640 size_t file_size; 00641 char *buffer; 00642 int i, file; 00643 00644 if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0) 00645 return ((char *)NULL); 00646 00647 file_size = (size_t)finfo.st_size; 00648 00649 /* check for overflow on very large files */ 00650 if (file_size != finfo.st_size || file_size + 1 < file_size) 00651 { 00652 if (file >= 0) 00653 close (file); 00654 #if defined (EFBIG) 00655 errno = EFBIG; 00656 #endif 00657 return ((char *)NULL); 00658 } 00659 00660 /* Read the file into BUFFER. */ 00661 buffer = (char *)xmalloc (file_size + 1); 00662 i = read (file, buffer, file_size); 00663 close (file); 00664 00665 if (i < 0) 00666 { 00667 free (buffer); 00668 return ((char *)NULL); 00669 } 00670 00671 buffer[i] = '\0'; 00672 if (sizep) 00673 *sizep = i; 00674 00675 return (buffer); 00676 }
|
|
||||||||||||
|
Definition at line 722 of file bind.c. References _rl_read_file(), buffer, errno, FREE, free, line, rl_parse_and_bind(), savestring, tilde_expand(), and whitespace. Referenced by parser_include(), and rl_read_init_file(). 00725 { 00726 register int i; 00727 char *buffer, *openname, *line, *end; 00728 size_t file_size; 00729 00730 current_readline_init_file = filename; 00731 current_readline_init_include_level = include_level; 00732 00733 openname = tilde_expand (filename); 00734 buffer = _rl_read_file (openname, &file_size); 00735 free (openname); 00736 00737 if (buffer == 0) 00738 return (errno); 00739 00740 if (include_level == 0 && filename != last_readline_init_file) 00741 { 00742 FREE (last_readline_init_file); 00743 last_readline_init_file = savestring (filename); 00744 } 00745 00746 currently_reading_init_file = 1; 00747 00748 /* Loop over the lines in the file. Lines that start with `#' are 00749 comments; all other lines are commands for readline initialization. */ 00750 current_readline_init_lineno = 1; 00751 line = buffer; 00752 end = buffer + file_size; 00753 while (line < end) 00754 { 00755 /* Find the end of this line. */ 00756 for (i = 0; line + i != end && line[i] != '\n'; i++); 00757 00758 #if defined (__CYGWIN__) 00759 /* ``Be liberal in what you accept.'' */ 00760 if (line[i] == '\n' && line[i-1] == '\r') 00761 line[i - 1] = '\0'; 00762 #endif 00763 00764 /* Mark end of line. */ 00765 line[i] = '\0'; 00766 00767 /* Skip leading whitespace. */ 00768 while (*line && whitespace (*line)) 00769 { 00770 line++; 00771 i--; 00772 } 00773 00774 /* If the line is not a comment, then parse it. */ 00775 if (*line && *line != '#') 00776 rl_parse_and_bind (line); 00777 00778 /* Move to the next line. */ 00779 line += i + 1; 00780 current_readline_init_lineno++; 00781 } 00782 00783 free (buffer); 00784 currently_reading_init_file = 0; 00785 return (0); 00786 }
|
|
|
Definition at line 499 of file bind.c. References _rl_to_lower, CTRL_CHAR, ESC, META_CHAR, RUBOUT, UNCTRL, UNMETA, and xmalloc(). Referenced by _rl_macro_dumper_internal(), and rl_variable_dumper(). 00501 { 00502 char *ret, *r, *s; 00503 int c; 00504 00505 r = ret = (char *)xmalloc (7 * strlen (seq) + 1); 00506 for (s = seq; *s; s++) 00507 { 00508 c = *s; 00509 if (META_CHAR (c)) 00510 { 00511 *r++ = '\\'; 00512 *r++ = 'M'; 00513 *r++ = '-'; 00514 c = UNMETA (c); 00515 } 00516 else if (CTRL_CHAR (c) && c != ESC) 00517 { 00518 *r++ = '\\'; 00519 *r++ = 'C'; 00520 *r++ = '-'; 00521 c = _rl_to_lower (UNCTRL (c)); 00522 } 00523 else if (c == RUBOUT) 00524 { 00525 *r++ = '\\'; 00526 *r++ = 'C'; 00527 *r++ = '-'; 00528 c = '?'; 00529 } 00530 00531 if (c == ESC) 00532 { 00533 *r++ = '\\'; 00534 c = 'e'; 00535 } 00536 else if (c == '\\' || c == '"') 00537 *r++ = '\\'; 00538 00539 *r++ = (unsigned char)c; 00540 } 00541 *r = '\0'; 00542 return ret; 00543 }
|
|
|
Definition at line 1373 of file bind.c. References _rl_stricmp(). Referenced by rl_variable_bind(). 01375 { 01376 return (value == 0 || *value == '\0' || 01377 (_rl_stricmp (value, "on") == 0) || 01378 (value[0] == '1' && value[1] == '\0')); 01379 }
|
|
|
Definition at line 1289 of file bind.c. References _rl_stricmp(), and boolean_varlist. Referenced by rl_variable_bind(). 01291 { 01292 register int i; 01293 01294 for (i = 0; boolean_varlist[i].name; i++) 01295 if (_rl_stricmp (name, boolean_varlist[i].name) == 0) 01296 return i; 01297 return -1; 01298 }
|
|
|
Definition at line 1358 of file bind.c. References _rl_stricmp(), and string_varlist. Referenced by rl_variable_bind(). 01360 { 01361 register int i; 01362 01363 for (i = 0; string_varlist[i].name; i++) 01364 if (_rl_stricmp (name, string_varlist[i].name) == 0) 01365 return i; 01366 return -1; 01367 }
|
|
|
Definition at line 1551 of file bind.c. References _rl_stricmp(), and value. Referenced by rl_parse_and_bind(). 01553 { 01554 register int i; 01555 01556 for (i = 0; name_key_alist[i].name; i++) 01557 if (_rl_stricmp (name, name_key_alist[i].name) == 0) 01558 return (name_key_alist[i].value); 01559 01560 return (*(unsigned char *)name); /* XXX was return (*name) */ 01561 }
|
|
|
Definition at line 1304 of file bind.c. References _rl_bell_preference, _rl_enable_paren_matching(), _rl_stricmp(), AUDIBLE_BELL, boolean_varlist, name, rl_blink_matching_paren, and VISIBLE_BELL. Referenced by rl_variable_bind(). 01306 { 01307 const char *name; 01308 01309 name = boolean_varlist[i].name; 01310 01311 if (_rl_stricmp (name, "blink-matching-paren") == 0) 01312 _rl_enable_paren_matching (rl_blink_matching_paren); 01313 else if (_rl_stricmp (name, "prefer-visible-bell") == 0) 01314 { 01315 if (_rl_prefer_visible_bell) 01316 _rl_bell_preference = VISIBLE_BELL; 01317 else 01318 _rl_bell_preference = AUDIBLE_BELL; 01319 } 01320 }
|
|
|
Definition at line 979 of file bind.c. References _rl_init_file_error(), _rl_stricmp(), args, name, parser_directives, and whitespace. Referenced by rl_parse_and_bind(). 00981 { 00982 register int i; 00983 char *directive, *args; 00984 00985 /* Isolate the actual directive. */ 00986 00987 /* Skip whitespace. */ 00988 for (i = 0; whitespace (statement[i]); i++); 00989 00990 directive = &statement[i]; 00991 00992 for (; statement[i] && !whitespace (statement[i]); i++); 00993 00994 if (statement[i]) 00995 statement[i++] = '\0'; 00996 00997 for (; statement[i] && whitespace (statement[i]); i++); 00998 00999 args = &statement[i]; 01000 01001 /* Lookup the command, and act on it. */ 01002 for (i = 0; parser_directives[i].name; i++) 01003 if (_rl_stricmp (directive, parser_directives[i].name) == 0) 01004 { 01005 (*parser_directives[i].function) (args); 01006 return (0); 01007 } 01008 01009 /* display an error message about the unknown parser directive */ 01010 _rl_init_file_error ("unknown parser directive"); 01011 return (1); 01012 }
|
|
|
Definition at line 902 of file bind.c. References _rl_init_file_error(), and _rl_parsing_conditionalized_out. 00904 { 00905 register int i; 00906 00907 if (if_stack_depth == 0) 00908 { 00909 _rl_init_file_error ("$else found without matching $if"); 00910 return 0; 00911 } 00912 00913 /* Check the previous (n - 1) levels of the stack to make sure that 00914 we haven't previously turned off parsing. */ 00915 for (i = 0; i < if_stack_depth - 1; i++) 00916 if (if_stack[i] == 1) 00917 return 0; 00918 00919 /* Invert the state of parsing if at top level. */ 00920 _rl_parsing_conditionalized_out = !_rl_parsing_conditionalized_out; 00921 return 0; 00922 }
|
|
|
Definition at line 927 of file bind.c. References _rl_init_file_error(), and _rl_parsing_conditionalized_out. 00929 { 00930 if (if_stack_depth) 00931 _rl_parsing_conditionalized_out = if_stack[--if_stack_depth]; 00932 else 00933 _rl_init_file_error ("$endif without matching $if"); 00934 return 0; 00935 }
|
|
|
Definition at line 829 of file bind.c. References _rl_parsing_conditionalized_out, _rl_stricmp(), _rl_strnicmp(), emacs_mode, free, no_mode, rl_editing_mode, rl_terminal_name, savestring, strchr(), vi_mode, whitespace, xmalloc(), and xrealloc(). 00831 { 00832 register int i; 00833 00834 /* Push parser state. */ 00835 if (if_stack_depth + 1 >= if_stack_size) 00836 { 00837 if (!if_stack) 00838 if_stack = (unsigned char *)xmalloc (if_stack_size = 20); 00839 else 00840 if_stack = (unsigned char *)xrealloc (if_stack, if_stack_size += 20); 00841 } 00842 if_stack[if_stack_depth++] = _rl_parsing_conditionalized_out; 00843 00844 /* If parsing is turned off, then nothing can turn it back on except 00845 for finding the matching endif. In that case, return right now. */ 00846 if (_rl_parsing_conditionalized_out) 00847 return 0; 00848 00849 /* Isolate first argument. */ 00850 for (i = 0; args[i] && !whitespace (args[i]); i++); 00851 00852 if (args[i]) 00853 args[i++] = '\0'; 00854 00855 /* Handle "$if term=foo" and "$if mode=emacs" constructs. If this 00856 isn't term=foo, or mode=emacs, then check to see if the first 00857 word in ARGS is the same as the value stored in rl_readline_name. */ 00858 if (rl_terminal_name && _rl_strnicmp (args, "term=", 5) == 0) 00859 { 00860 char *tem, *tname; 00861 00862 /* Terminals like "aaa-60" are equivalent to "aaa". */ 00863 tname = savestring (rl_terminal_name); 00864 tem = strchr (tname, '-'); 00865 if (tem) 00866 *tem = '\0'; 00867 00868 /* Test the `long' and `short' forms of the terminal name so that 00869 if someone has a `sun-cmd' and does not want to have bindings 00870 that will be executed if the terminal is a `sun', they can put 00871 `$if term=sun-cmd' into their .inputrc. */ 00872 _rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) && 00873 _rl_stricmp (args + 5, rl_terminal_name); 00874 free (tname); 00875 } 00876 #if defined (VI_MODE) 00877 else if (_rl_strnicmp (args, "mode=", 5) == 0) 00878 { 00879 int mode; 00880 00881 if (_rl_stricmp (args + 5, "emacs") == 0) 00882 mode = emacs_mode; 00883 else if (_rl_stricmp (args + 5, "vi") == 0) 00884 mode = vi_mode; 00885 else 00886 mode = no_mode; 00887 00888 _rl_parsing_conditionalized_out = mode != rl_editing_mode; 00889 } 00890 #endif /* VI_MODE */ 00891 /* Check to see if the first word in ARGS is the same as the 00892 value stored in rl_readline_name. */ 00893 else if (_rl_stricmp (args, rl_readline_name) == 0) 00894 _rl_parsing_conditionalized_out = 0; 00895 else 00896 _rl_parsing_conditionalized_out = 1; 00897 return 0; 00898 }
|
|
|
Definition at line 938 of file bind.c. References _rl_parsing_conditionalized_out, _rl_read_init_file(), e, and strchr(). 00940 { 00941 const char *old_init_file; 00942 char *e; 00943 int old_line_number, old_include_level, r; 00944 00945 if (_rl_parsing_conditionalized_out) 00946 return (0); 00947 00948 old_init_file = current_readline_init_file; 00949 old_line_number = current_readline_init_lineno; 00950 old_include_level = current_readline_init_include_level; 00951 00952 e = strchr (args, '\n'); 00953 if (e) 00954 *e = '\0'; 00955 r = _rl_read_init_file ((const char *)args, old_include_level + 1); 00956 00957 current_readline_init_file = old_init_file; 00958 current_readline_init_lineno = old_line_number; 00959 current_readline_init_include_level = old_include_level; 00960 00961 return r; 00962 }
|
|
||||||||||||||||
|
Definition at line 90 of file bind.c. References rl_add_funmap_entry(), and rl_bind_key(). 00094 { 00095 if (key != -1) 00096 rl_bind_key (key, function); 00097 rl_add_funmap_entry (name, function); 00098 return 0; 00099 }
|
|
||||||||||||
|
Definition at line 103 of file bind.c. References _rl_convert_meta_chars_to_ascii, _rl_keymap, ESC, _keymap_entry::function, FUNCTION_TO_KEYMAP, ISFUNC, ISKMAP, META_CHAR, _keymap_entry::type, and UNMETA. 00106 { 00107 if (key < 0) 00108 return (key); 00109 00110 if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii) 00111 { 00112 if (_rl_keymap[ESC].type == ISKMAP) 00113 { 00114 Keymap escmap; 00115 00116 escmap = FUNCTION_TO_KEYMAP (_rl_keymap, ESC); 00117 key = UNMETA (key); 00118 escmap[key].type = ISFUNC; 00119 escmap[key].function = function; 00120 return (0); 00121 } 00122 return (key); 00123 } 00124 00125 _rl_keymap[key].type = ISFUNC; 00126 _rl_keymap[key].function = function; 00127 rl_binding_keymap = _rl_keymap; 00128 return (0); 00129 }
|
|
||||||||||||||||
|
Definition at line 134 of file bind.c. References _rl_keymap, and rl_bind_key(). 00138 { 00139 int result; 00140 Keymap oldmap; 00141 00142 oldmap = _rl_keymap; 00143 _rl_keymap = map; 00144 result = rl_bind_key (key, function); 00145 _rl_keymap = oldmap; 00146 return (result); 00147 }
|
|
||||||||||||
|
Definition at line 1934 of file bind.c. References rl_dispatching, rl_explicit_arg, rl_function_dumper(), rl_on_new_line(), and rl_outstream. 01936 { 01937 if (rl_dispatching) 01938 fprintf (rl_outstream, "\r\n"); 01939 rl_function_dumper (rl_explicit_arg); 01940 rl_on_new_line (); 01941 return (0); 01942 }
|
|
||||||||||||
|
Definition at line 2014 of file bind.c. References rl_dispatching, rl_explicit_arg, rl_macro_dumper(), rl_on_new_line(), and rl_outstream. 02016 { 02017 if (rl_dispatching) 02018 fprintf (rl_outstream, "\r\n"); 02019 rl_macro_dumper (rl_explicit_arg); 02020 rl_on_new_line (); 02021 return (0); 02022 }
|
|
||||||||||||
|
Definition at line 2104 of file bind.c. References rl_dispatching, rl_explicit_arg, rl_on_new_line(), rl_outstream, and rl_variable_dumper(). 02106 { 02107 if (rl_dispatching) 02108 fprintf (rl_outstream, "\r\n"); 02109 rl_variable_dumper (rl_explicit_arg); 02110 rl_on_new_line (); 02111 return (0); 02112 }
|
|
|
Definition at line 1864 of file bind.c. References _rl_keymap, free, function, name, rl_funmap_names(), rl_invoking_keyseqs_in_map(), rl_named_function(), and rl_outstream. Referenced by rl_dump_functions(). 01866 { 01867 register int i; 01868 const char **names; 01869 const char *name; 01870 01871 names = rl_funmap_names (); 01872 01873 fprintf (rl_outstream, "\n"); 01874 01875 for (i = 0; (name = names[i]); i++) 01876 { 01877 rl_command_func_t *function; 01878 char **invokers; 01879 01880 function = rl_named_function (name); 01881 invokers = rl_invoking_keyseqs_in_map (function, _rl_keymap); 01882 01883 if (print_readably) 01884 { 01885 if (!invokers) 01886 fprintf (rl_outstream, "# %s (not bound)\n", name); 01887 else 01888 { 01889 register int j; 01890 01891 for (j = 0; invokers[j]; j++) 01892 { 01893 fprintf (rl_outstream, "\"%s\": %s\n", 01894 invokers[j], name); 01895 free (invokers[j]); 01896 } 01897 01898 free (invokers); 01899 } 01900 } 01901 else 01902 { 01903 if (!invokers) 01904 fprintf (rl_outstream, "%s is not bound to any keys\n", 01905 name); 01906 else 01907 { 01908 register int j; 01909 01910 fprintf (rl_outstream, "%s can be found on ", name); 01911 01912 for (j = 0; invokers[j] && j < 5; j++) 01913 { 01914 fprintf (rl_outstream, "\"%s\"%s", invokers[j], 01915 invokers[j + 1] ? ", " : ".\n"); 01916 } 01917 01918 if (j == 5 && invokers[j]) 01919 fprintf (rl_outstream, "...\n"); 01920 01921 for (j = 0; invokers[j]; j++) 01922 free (invokers[j]); 01923 01924 free (invokers); 01925 } 01926 } 01927 } 01928 }
|
|
||||||||||||||||
|
Definition at line 568 of file bind.c. References _rl_convert_meta_chars_to_ascii, _rl_keymap, ESC, function, FUNCTION_TO_KEYMAP, ISKMAP, META_CHAR, NULL, _keymap_entry::type, and UNMETA. Referenced by _rl_bind_if_unbound(). 00572 { 00573 register int i; 00574 00575 if (!map) 00576 map = _rl_keymap; 00577 00578 for (i = 0; keyseq && keyseq[i]; i++) 00579 { 00580 unsigned char ic = keyseq[i]; 00581 00582 if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) 00583 { 00584 if (map[ESC].type != ISKMAP) 00585 { 00586 if (type) 00587 *type = map[ESC].type; 00588 00589 return (map[ESC].function); 00590 } 00591 else 00592 { 00593 map = FUNCTION_TO_KEYMAP (map, ESC); 00594 ic = UNMETA (ic); 00595 } 00596 } 00597 00598 if (map[ic].type == ISKMAP) 00599 { 00600 /* If this is the last key in the key sequence, return the 00601 map. */ 00602 if (!keyseq[i + 1]) 00603 { 00604 if (type) 00605 *type = ISKMAP; 00606 00607 return (map[ic].function); 00608 } 00609 else 00610 map = FUNCTION_TO_KEYMAP (map, ic); 00611 } 00612 else 00613 { 00614 if (type) 00615 *type = map[ic].type; 00616 00617 return (map[ic].function); 00618 } 00619 } 00620 return ((rl_command_func_t *) NULL); 00621 }
|
|
||||||||||||||||||||
|
Definition at line 240 of file bind.c. References _rl_convert_meta_chars_to_ascii, ANYOTHERKEY, ESC, free, function, _keymap_entry::function, FUNCTION_TO_KEYMAP, ISFUNC, ISKMAP, ISMACR, KEYMAP_SIZE, KEYMAP_TO_FUNCTION, keys, META_CHAR, rl_do_lowercase_version(), rl_make_bare_keymap(), rl_translate_keyseq(), _keymap_entry::type, UNMETA, and xmalloc(). 00245 { 00246 char *keys; 00247 int keys_len; 00248 register int i; 00249 KEYMAP_ENTRY k; 00250 00251 k.function = 0; 00252 00253 /* If no keys to bind to, exit right away. */ 00254 if (!keyseq || !*keyseq) 00255 { 00256 if (type == ISMACR) 00257 free (data); 00258 return -1; 00259 } 00260 00261 keys = (char *)xmalloc (1 + (2 * strlen (keyseq))); 00262 00263 /* Translate the ASCII representation of KEYSEQ into an array of 00264 characters. Stuff the characters into KEYS, and the length of 00265 KEYS into KEYS_LEN. */ 00266 if (rl_translate_keyseq (keyseq, keys, &keys_len)) 00267 { 00268 free (keys); 00269 return -1; 00270 } 00271 00272 /* Bind keys, making new keymaps as necessary. */ 00273 for (i = 0; i < keys_len; i++) 00274 { 00275 unsigned char uc = keys[i]; 00276 int ic; 00277 00278 ic = uc; 00279 if (ic < 0 || ic >= KEYMAP_SIZE) 00280 return -1; 00281 00282 if (_rl_convert_meta_chars_to_ascii && META_CHAR (ic)) 00283 { 00284 ic = UNMETA (ic); 00285 if (map[ESC].type == ISKMAP) 00286 map = FUNCTION_TO_KEYMAP (map, ESC); 00287 } 00288 00289 if ((i + 1) < keys_len) 00290 { 00291 if (map[ic].type != ISKMAP) 00292 { 00293 /* We allow subsequences of keys. If a keymap is being 00294 created that will `shadow' an existing function or macro 00295 key binding, we save that keybinding into the ANYOTHERKEY 00296 index in the new map. The dispatch code will look there 00297 to find the function to execute if the subsequence is not 00298 matched. ANYOTHERKEY was chosen to be greater than 00299 UCHAR_MAX. */ 00300 k = map[ic]; 00301 00302 map[ic].type = ISKMAP; 00303 map[ic].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap()); 00304 } 00305 map = FUNCTION_TO_KEYMAP (map, ic); 00306 /* The dispatch code will return this function if no matching 00307 key sequence is found in the keymap. This (with a little 00308 help from the dispatch code in readline.c) allows `a' to be 00309 mapped to something, `abc' to be mapped to something else, 00310 and the function bound to `a' to be executed when the user 00311 types `abx', leaving `bx' in the input queue. */ 00312 if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR)) 00313 { 00314 map[ANYOTHERKEY] = k; 00315 k.function = 0; 00316 } 00317 } 00318 else 00319 { 00320 if (map[ic].type == ISMACR) 00321 free ((char *)map[ic].function); 00322 else if (map[ic].type == ISKMAP) 00323 { 00324 map = FUNCTION_TO_KEYMAP (map, ic); 00325 ic = ANYOTHERKEY; 00326 } 00327 00328 map[ic].function = KEYMAP_TO_FUNCTION (data); 00329 map[ic].type = type; 00330 } 00331 00332 rl_binding_keymap = map; 00333 } 00334 free (keys); 00335 return 0; 00336 }
|
|
|
Definition at line 1613 of file bind.c. References _rl_keymap. 01614 { 01615 return (_rl_keymap); 01616 }
|
|
|
Definition at line 1582 of file bind.c. References _rl_stricmp(), keymap_names, map, and NULL. Referenced by sv_keymap(). 01584 { 01585 register int i; 01586 01587 for (i = 0; keymap_names[i].name; i++) 01588 if (_rl_stricmp (name, keymap_names[i].name) == 0) 01589 return (keymap_names[i].map); 01590 return ((Keymap) NULL); 01591 }
|
|
|
Definition at line 1594 of file bind.c. References keymap_names, name, and NULL. Referenced by rl_variable_dumper(). 01596 { 01597 register int i; 01598 for (i = 0; keymap_names[i].name; i++) 01599 if (map == keymap_names[i].map) 01600 return ((char *)keymap_names[i].name); 01601 return ((char *)NULL); 01602 }
|
|
|
Definition at line 1631 of file bind.c. References emacs_mode, rl_editing_mode, and vi_mode. Referenced by rl_variable_dumper(). 01632 { 01633 if (rl_editing_mode == emacs_mode) 01634 return "emacs"; 01635 #if defined (VI_MODE) 01636 else if (rl_editing_mode == vi_mode) 01637 return "vi"; 01638 #endif /* VI_MODE */ 01639 else 01640 return "nope"; 01641 }
|
|
|
Definition at line 1854 of file bind.c. References _rl_keymap, and rl_invoking_keyseqs_in_map(). 01856 { 01857 return (rl_invoking_keyseqs_in_map (function, _rl_keymap)); 01858 }
|
|
||||||||||||
|
Definition at line 1749 of file bind.c. References _rl_get_keyname(), _rl_to_lower, CTRL_CHAR, ESC, free, FUNCTION_TO_KEYMAP, ISFUNC, ISKMAP, ISMACR, key, KEYMAP_SIZE, NULL, RUBOUT, UNCTRL, xmalloc(), and xrealloc(). Referenced by rl_function_dumper(), and rl_invoking_keyseqs(). 01752 { 01753 register int key; 01754 char **result; 01755 int result_index, result_size; 01756 01757 result = (char **)NULL; 01758 result_index = result_size = 0; 01759 01760 for (key = 0; key < KEYMAP_SIZE; key++) 01761 { 01762 switch (map[key].type) 01763 { 01764 case ISMACR: 01765 /* Macros match, if, and only if, the pointers are identical. 01766 Thus, they are treated exactly like functions in here. */ 01767 case ISFUNC: 01768 /* If the function in the keymap is the one we are looking for, 01769 then add the current KEY to the list of invoking keys. */ 01770 if (map[key].function == function) 01771 { 01772 char *keyname; 01773 01774 keyname = _rl_get_keyname (key); 01775 01776 if (result_index + 2 > result_size) 01777 { 01778 result_size += 10; 01779 result = (char **)xrealloc (result, result_size * sizeof (char *)); 01780 } 01781 01782 result[result_index++] = keyname; 01783 result[result_index] = (char *)NULL; 01784 } 01785 break; 01786 01787 case ISKMAP: 01788 { 01789 char **seqs; 01790 register int i; 01791 01792 /* Find the list of keyseqs in this map which have FUNCTION as 01793 their target. Add the key sequences found to RESULT. */ 01794 if (map[key].function) 01795 seqs = 01796 rl_invoking_keyseqs_in_map (function, FUNCTION_TO_KEYMAP (map, key)); 01797 else 01798 break; 01799 01800 if (seqs == 0) 01801 break; 01802 01803 for (i = 0; seqs[i]; i++) 01804 { 01805 char *keyname = (char *)xmalloc (6 + strlen (seqs[i])); 01806 01807 if (key == ESC) 01808 #if 0 01809 sprintf (keyname, "\\e"); 01810 #else 01811 /* XXX - experimental */ 01812 sprintf (keyname, "\\M-"); 01813 #endif 01814 else if (CTRL_CHAR (key)) 01815 sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key))); 01816 else if (key == RUBOUT) 01817 sprintf (keyname, "\\C-?"); 01818 else if (key == '\\' || key == '"') 01819 { 01820 keyname[0] = '\\'; 01821 keyname[1] = (char) key; 01822 keyname[2] = '\0'; 01823 } 01824 else 01825 { 01826 keyname[0] = (char) key; 01827 keyname[1] = '\0'; 01828 } 01829 01830 strcat (keyname, seqs[i]); 01831 free (seqs[i]); 01832 01833 if (result_index + 2 > result_size) 01834 { 01835 result_size += 10; 01836 result = (char **)xrealloc (result, result_size * sizeof (char *)); 01837 } 01838 01839 result[result_index++] = keyname; 01840 result[result_index] = (char *)NULL; 01841 } 01842 01843 free (seqs); 01844 } 01845 break; 01846 } 01847 } 01848 return (result); 01849 }
|
|
|
Definition at line 1656 of file bind.c. References free, rl_funmap_names(), and rl_outstream. 01657 { 01658 register int i; 01659 const char **funmap_names; 01660 01661 funmap_names = rl_funmap_names (); 01662 01663 if (!funmap_names) 01664 return; 01665 01666 for (i = 0; funmap_names[i]; i++) 01667 fprintf (rl_outstream, "%s\n", funmap_names[i]); 01668 01669 free (funmap_names); 01670 }
|
|
||||||||||||||||
|
Definition at line 216 of file bind.c. References free, ISMACR, rl_generic_bind(), rl_translate_keyseq(), and xmalloc(). Referenced by rl_parse_and_bind(). 00219 { 00220 char *macro_keys; 00221 int macro_keys_len; 00222 00223 macro_keys = (char *)xmalloc ((2 * strlen (macro)) + 1); 00224 00225 if (rl_translate_keyseq (macro, macro_keys, ¯o_keys_len)) 00226 { 00227 free (macro_keys); 00228 return -1; 00229 } 00230 rl_generic_bind (ISMACR, keyseq, macro_keys, map); 00231 return 0; 00232 }
|
|
|
Definition at line 2007 of file bind.c. References _rl_keymap, _rl_macro_dumper_internal(), and NULL. Referenced by rl_dump_macros(). 02009 { 02010 _rl_macro_dumper_internal (print_readably, _rl_keymap, (char *)NULL); 02011 }
|
|
|
Definition at line 549 of file bind.c. References _rl_stricmp(), function, funmap, name, NULL, and rl_initialize_funmap(). Referenced by rl_function_dumper(), rl_parse_and_bind(), and rl_unbind_command_in_map(). 00551 { 00552 register int i; 00553 00554 rl_initialize_funmap (); 00555 00556 for (i = 0; funmap[i]; i++) 00557 if (_rl_stricmp (funmap[i]->name, string) == 0) 00558 return (funmap[i]->function); 00559 return ((rl_command_func_t *)NULL); 00560 }
|
|
|
Definition at line 1019 of file bind.c. References _rl_init_file_error(), _rl_keymap, _rl_parsing_conditionalized_out, _rl_stricmp(), _rl_to_upper, CTRL, delimiter, emacs_meta_keymap, free, glean_key_from_name(), handle_parser_directive(), ISKMAP, key, META, rl_bind_key(), rl_generic_bind(), rl_macro_bind(), rl_named_function(), rl_set_key(), rl_variable_bind(), strrchr(), substring_member_of_array(), value, whitespace, and xmalloc(). 01021 { 01022 char *funname, *kname; 01023 register int c, i; 01024 int key, equivalency; 01025 01026 while (string && whitespace (*string)) 01027 string++; 01028 01029 if (!string || !*string || *string == '#') 01030 return 0; 01031 01032 /* If this is a parser directive, act on it. */ 01033 if (*string == '$') 01034 { 01035 handle_parser_directive (&string[1]); 01036 return 0; 01037 } 01038 01039 /* If we aren't supposed to be parsing right now, then we're done. */ 01040 if (_rl_parsing_conditionalized_out) 01041 return 0; 01042 01043 i = 0; 01044 /* If this keyname is a complex key expression surrounded by quotes, 01045 advance to after the matching close quote. This code allows the 01046 backslash to quote characters in the key expression. */ 01047 if (*string == '"') 01048 { 01049 int passc = 0; 01050 01051 for (i = 1; (c = string[i]); i++) 01052 { 01053 if (passc) 01054 { 01055 passc = 0; 01056 continue; 01057 } 01058 01059 if (c == '\\') 01060 { 01061 passc++; 01062 continue; 01063 } 01064 01065 if (c == '"') 01066 break; 01067 } 01068 /* If we didn't find a closing quote, abort the line. */ 01069 if (string[i] == '\0') 01070 { 01071 _rl_init_file_error ("no closing `\"' in key binding"); 01072 return 1; 01073 } 01074 } 01075 01076 /* Advance to the colon (:) or whitespace which separates the two objects. */ 01077 for (; (c = string[i]) && c != ':' && c != ' ' && c != '\t'; i++ ); 01078 01079 equivalency = (c == ':' && string[i + 1] == '='); 01080 01081 /* Mark the end of the command (or keyname). */ 01082 if (string[i]) 01083 string[i++] = '\0'; 01084 01085 /* If doing assignment, skip the '=' sign as well. */ 01086 if (equivalency) 01087 string[i++] = '\0'; 01088 01089 /* If this is a command to set a variable, then do that. */ 01090 if (_rl_stricmp (string, "set") == 0) 01091 { 01092 char *var = string + i; 01093 char *value; 01094 01095 /* Make VAR point to start of variable name. */ 01096 while (*var && whitespace (*var)) var++; 01097 01098 /* Make VALUE point to start of value string. */ 01099 value = var; 01100 while (*value && !whitespace (*value)) value++; 01101 if (*value) 01102 *value++ = '\0'; 01103 while (*value && whitespace (*value)) value++; 01104 01105 rl_variable_bind (var, value); 01106 return 0; 01107 } 01108 01109 /* Skip any whitespace between keyname and funname. */ 01110 for (; string[i] && whitespace (string[i]); i++); 01111 funname = &string[i]; 01112 01113 /* Now isolate funname. 01114 For straight function names just look for whitespace, since 01115 that will signify the end of the string. But this could be a 01116 macro definition. In that case, the string is quoted, so skip 01117 to the matching delimiter. We allow the backslash to quote the 01118 delimiter characters in the macro body. */ 01119 /* This code exists to allow whitespace in macro expansions, which 01120 would otherwise be gobbled up by the next `for' loop.*/ 01121 /* XXX - it may be desirable to allow backslash quoting only if " is 01122 the quoted string delimiter, like the shell. */ 01123 if (*funname == '\'' || *funname == '"') 01124 { 01125 int delimiter = string[i++], passc; 01126 01127 for (passc = 0; (c = string[i]); i++) 01128 { 01129 if (passc) 01130 { 01131 passc = 0; 01132 continue; 01133 } 01134 01135 if (c == '\\') 01136 { 01137 passc = 1; 01138 continue; 01139 } 01140 01141 if (c == delimiter) 01142 break; 01143 } 01144 if (c) 01145 i++; 01146 } 01147 01148 /* Advance to the end of the string. */ 01149 for (; string[i] && !whitespace (string[i]); i++); 01150 01151 /* No extra whitespace at the end of the string. */ 01152 string[i] = '\0'; 01153 01154 /* Handle equivalency bindings here. Make the left-hand side be exactly 01155 whatever the right-hand evaluates to, including keymaps. */ 01156 if (equivalency) 01157 { 01158 return 0; 01159 } 01160 01161 /* If this is a new-style key-binding, then do the binding with 01162 rl_set_key (). Otherwise, let the older code deal with it. */ 01163 if (*string == '"') 01164 { 01165 char *seq; 01166 register int j, k, passc; 01167 01168 seq = (char *)xmalloc (1 + strlen (string)); 01169 for (j = 1, k = passc = 0; string[j]; j++) 01170 { 01171 /* Allow backslash to quote characters, but leave them in place. 01172 This allows a string to end with a backslash quoting another 01173 backslash, or with a backslash quoting a double quote. The 01174 backslashes are left in place for rl_translate_keyseq (). */ 01175 if (passc || (string[j] == '\\')) 01176 { 01177 seq[k++] = string[j]; 01178 passc = !passc; 01179 continue; 01180 } 01181 01182 if (string[j] == '"') 01183 break; 01184 01185 seq[k++] = string[j]; 01186 } 01187 seq[k] = '\0'; 01188 01189 /* Binding macro? */ 01190 if (*funname == '\'' || *funname == '"') 01191 { 01192 j = strlen (funname); 01193 01194 /* Remove the delimiting quotes from each end of FUNNAME. */ 01195 if (j && funname[j - 1] == *funname) 01196 funname[j - 1] = '\0'; 01197 01198 rl_macro_bind (seq, &funname[1], _rl_keymap); 01199 } 01200 else 01201 rl_set_key (seq, rl_named_function (funname), _rl_keymap); 01202 01203 free (seq); 01204 return 0; 01205 } 01206 01207 /* Get the actual character we want to deal with. */ 01208 kname = strrchr (string, '-'); 01209 if (!kname) 01210 kname = string; 01211 else 01212 kname++; 01213 01214 key = glean_key_from_name (kname); 01215 01216 /* Add in control and meta bits. */ 01217 if (substring_member_of_array (string, _rl_possible_control_prefixes)) 01218 key = CTRL (_rl_to_upper (key)); 01219 01220 if (substring_member_of_array (string, _rl_possible_meta_prefixes)) 01221 key = META (key); 01222 01223 /* Temporary. Handle old-style keyname with macro-binding. */ 01224 if (*funname == '\'' || *funname == '"') 01225 { 01226 char useq[2]; 01227 int fl = strlen (funname); 01228 01229 useq[0] = key; useq[1] = '\0'; 01230 if (fl && funname[fl - 1] == *funname) 01231 funname[fl - 1] = '\0'; 01232 01233 rl_macro_bind (useq, &funname[1], _rl_keymap); 01234 } 01235 #if defined (PREFIX_META_HACK) 01236 /* Ugly, but working hack to keep prefix-meta around. */ 01237 else if (_rl_stricmp (funname, "prefix-meta") == 0) 01238 { 01239 char seq[2]; 01240 01241 seq[0] = key; 01242 seq[1] = '\0'; 01243 rl_generic_bind (ISKMAP, seq, (char *)emacs_meta_keymap, _rl_keymap); 01244 } 01245 #endif /* PREFIX_META_HACK */ 01246 else 01247 rl_bind_key (key, rl_named_function (funname)); 01248 return 0; 01249 }
|
|
||||||||||||
|
Definition at line 680 of file bind.c. References NULL, rl_read_init_file(), and rl_set_keymap_from_edit_mode(). 00682 { 00683 int r; 00684 r = rl_read_init_file ((const char *)NULL); 00685 rl_set_keymap_from_edit_mode (); 00686 return r; 00687 }
|
|
|
Definition at line 697 of file bind.c. References _rl_read_init_file(), DEFAULT_INPUTRC, and sh_get_env_value(). 00699 { 00700 /* Default the filename. */ 00701 if (filename == 0) 00702 { 00703 filename = last_readline_init_file; 00704 if (filename == 0) 00705 filename = sh_get_env_value ("INPUTRC"); 00706 if (filename == 0) 00707 filename = DEFAULT_INPUTRC; 00708 } 00709 00710 if (*filename == 0) 00711 filename = DEFAULT_INPUTRC; 00712 00713 #if defined (__MSDOS__) 00714 if (_rl_read_init_file (filename, 0) == 0) 00715 return 0; 00716 filename = "~/_inputrc"; 00717 #endif 00718 return (_rl_read_init_file (filename, 0)); 00719 }
|
|
||||||||||||||||
|
Definition at line 204 of file bind.c. References ISFUNC, and rl_generic_bind(). Referenced by _rl_bind_if_unbound(), and rl_parse_and_bind(). 00208 { 00209 return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map)); 00210 }
|
|
|
Definition at line 1605 of file bind.c. References _rl_keymap. Referenced by sv_keymap(). 01607 { 01608 if (map) 01609 _rl_keymap = map; 01610 }
|
|
|
Definition at line 1619 of file bind.c. References _rl_keymap, emacs_mode, emacs_standard_keymap, rl_editing_mode, vi_insertion_keymap, and vi_mode. Referenced by readline_initialize_everything(), and rl_re_read_init_file(). 01620 { 01621 if (rl_editing_mode == emacs_mode) 01622 _rl_keymap = emacs_standard_keymap; 01623 #if defined (VI_MODE) 01624 else if (rl_editing_mode == vi_mode) 01625 _rl_keymap = vi_insertion_keymap; 01626 #endif /* VI_MODE */ 01627 }
|
|
||||||||||||||||
|
Definition at line 342 of file bind.c. References _rl_to_upper, CTRL, ESC, HEXVALUE, ISOCTAL, ISXDIGIT, largest_char, NEWLINE, OCTVALUE, RETURN, RUBOUT, and TAB. Referenced by rl_generic_bind(), rl_macro_bind(), and sv_isrchterm(). 00346 { 00347 register int i, c, l, temp; 00348 00349 for (i = l = 0; (c = seq[i]); i++) 00350 { 00351 if (c == '\\') 00352 { 00353 c = seq[++i]; 00354 00355 if (c == 0) 00356 break; 00357 00358 /* Handle \C- and \M- prefixes. */ 00359 if ((c == 'C' || c == 'M') && seq[i + 1] == '-') 00360 { 00361 /* Handle special case of backwards define. */ 00362 if (strncmp (&seq[i], "C-\\M-", 5) == 0) 00363 { 00364 array[l++] = ESC; /* ESC is meta-prefix */ 00365 i += 5; 00366 array[l++] = CTRL (_rl_to_upper (seq[i])); 00367 if (seq[i] == '\0') 00368 i--; 00369 } 00370 else if (c == 'M') 00371 { 00372 i++; 00373 array[l++] = ESC; /* ESC is meta-prefix */ 00374 } 00375 else if (c == 'C') 00376 { 00377 i += 2; 00378 /* Special hack for C-?... */ 00379 array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i])); 00380 } 00381 continue; 00382 } 00383 00384 /* Translate other backslash-escaped characters. These are the 00385 same escape sequences that bash's `echo' and `printf' builtins 00386 handle, with the addition of \d -> RUBOUT. A backslash 00387 preceding a character that is not special is stripped. */ 00388 switch (c) 00389 { 00390 case 'a': 00391 array[l++] = '\007'; 00392 break; 00393 case 'b': 00394 array[l++] = '\b'; 00395 break; 00396 case 'd': 00397 array[l++] = RUBOUT; /* readline-specific */ 00398 break; 00399 case 'e': 00400 array[l++] = ESC; 00401 break; 00402 case 'f': 00403 array[l++] = '\f'; 00404 break; 00405 case 'n': 00406 array[l++] = NEWLINE; 00407 break; 00408 case 'r': 00409 array[l++] = RETURN; 00410 break; 00411 case 't': 00412 array[l++] = TAB; 00413 break; 00414 case 'v': 00415 array[l++] = 0x0B; 00416 break; 00417 case '\\': 00418 array[l++] = '\\'; 00419 break; 00420 case '0': case '1': case '2': case '3': 00421 case '4': case '5': case '6': case '7': 00422 i++; 00423 for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++) 00424 c = (c * 8) + OCTVALUE (seq[i]); 00425 i--; /* auto-increment in for loop */ 00426 array[l++] = c & largest_char; 00427 break; 00428 case 'x': 00429 i++; 00430 for (temp = 2, c = 0; ISXDIGIT ((unsigned char)seq[i]) && temp--; i++) 00431 c = (c * 16) + HEXVALUE (seq[i]); 00432 if (temp == 2) 00433 c = 'x'; 00434 i--; /* auto-increment in for loop */ 00435 array[l++] = c & largest_char; 00436 break; 00437 default: /* backslashes before non-special chars just add the char */ 00438 array[l++] = c; 00439 break; /* the backslash is stripped */ 00440 } 00441 continue; 00442 } 00443 00444 array[l++] = c; 00445 } 00446 00447 *len = l; 00448 array[l] = '\0'; 00449 return (0); 00450 }
|
|
||||||||||||
|
Definition at line 188 of file bind.c. References func, rl_named_function(), and rl_unbind_function_in_map(). 00191 { 00192 rl_command_func_t *func; 00193 00194 func = rl_named_function (command); 00195 if (func == 0) 00196 return 0; 00197 return (rl_unbind_function_in_map (func, map)); 00198 }
|
|
||||||||||||
|
Definition at line 170 of file bind.c. References _keymap_entry::function, function, ISFUNC, KEYMAP_SIZE, and NULL. Referenced by rl_unbind_command_in_map(). 00173 { 00174 register int i, rval; 00175 00176 for (i = rval = 0; i < KEYMAP_SIZE; i++) 00177 { 00178 if (map[i].type == ISFUNC && map[i].function == func) 00179 { 00180 map[i].function = (rl_command_func_t *)NULL; 00181 rval = 1; 00182 } 00183 } 00184 return rval; 00185 }
|
|
|
Definition at line 152 of file bind.c. References NULL, and rl_bind_key(). 00154 { 00155 return (rl_bind_key (key, (rl_command_func_t *)NULL)); 00156 }
|
|
||||||||||||
|
Definition at line 161 of file bind.c. References NULL, and rl_bind_key_in_map(). 00164 { 00165 return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map)); 00166 }
|
|
|
Definition at line 453 of file bind.c. References _rl_to_lower, CTRL_CHAR, ESC, META_CHAR, RUBOUT, UNCTRL, and UNMETA. 00455 { 00456 static char kseq[16]; 00457 int i, c; 00458 00459 i = 0; 00460 c = seq; 00461 if (META_CHAR (c)) 00462 { 00463 kseq[i++] = '\\'; 00464 kseq[i++] = 'M'; 00465 kseq[i++] = '-'; 00466 c = UNMETA (c); 00467 } 00468 else if (CTRL_CHAR (c)) 00469 { 00470 kseq[i++] = '\\'; 00471 kseq[i++] = 'C'; 00472 kseq[i++] = '-'; 00473 c = _rl_to_lower (UNCTRL (c)); 00474 } 00475 else if (c == RUBOUT) 00476 { 00477 kseq[i++] = '\\'; 00478 kseq[i++] = 'C'; 00479 kseq[i++] = '-'; 00480 c = '?'; 00481 } 00482 00483 if (c == ESC) 00484 { 00485 kseq[i++] = '\\'; 00486 c = 'e'; 00487 } 00488 else if (c == '\\' || c == '"') 00489 { 00490 kseq[i++] = '\\'; 00491 } 00492 00493 kseq[i++] = (unsigned char) c; 00494 kseq[i] = '\0'; 00495 return kseq; 00496 }
|
|
||||||||||||
|
Definition at line 1382 of file bind.c. References bool_to_int(), boolean_varlist, find_boolean_var(), find_string_var(), flags, hack_special_boolean_var(), set_func, string_varlist, and V_SPECIAL. Referenced by rl_parse_and_bind(). 01384 { 01385 register int i; 01386 int v; 01387 01388 /* Check for simple variables first. */ 01389 i = find_boolean_var (name); 01390 if (i >= 0) 01391 { 01392 *boolean_varlist[i].value = bool_to_int (value); 01393 if (boolean_varlist[i].flags & V_SPECIAL) 01394 hack_special_boolean_var (i); 01395 return 0; 01396 } 01397 01398 i = find_string_var (name); 01399 01400 /* For the time being, unknown variable names or string names without a 01401 handler function are simply ignored. */ 01402 if (i < 0 || string_varlist[i].set_func == 0) 01403 return 0; 01404 01405 v = (*string_varlist[i].set_func) (value); 01406 return v; 01407 }
|
|
|
Definition at line 2025 of file bind.c. References _rl_bell_preference, _rl_comment_begin, _rl_isearch_terminators, _rl_keymap, _rl_untranslate_macro_value(), AUDIBLE_BELL, boolean_varlist, emacs_mode, free, name, NO_BELL, RL_COMMENT_BEGIN_DEFAULT, rl_completion_query_items, rl_editing_mode, rl_get_keymap_name(), rl_get_keymap_name_from_edit_mode(), rl_outstream, value, and VISIBLE_BELL. Referenced by rl_dump_variables(). 02027 { 02028 int i; 02029 const char *kname; 02030 02031 for (i = 0; boolean_varlist[i].name; i++) 02032 { 02033 if (print_readably) 02034 fprintf (rl_outstream, "set %s %s\n", boolean_varlist[i].name, 02035 *boolean_varlist[i].value ? "on" : "off"); 02036 else 02037 fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name, 02038 *boolean_varlist[i].value ? "on" : "off"); 02039 } 02040 02041 /* bell-style */ 02042 switch (_rl_bell_preference) 02043 { 02044 case NO_BELL: 02045 kname = "none"; break; 02046 case VISIBLE_BELL: 02047 kname = "visible"; break; 02048 case AUDIBLE_BELL: 02049 default: 02050 kname = "audible"; break; 02051 } 02052 if (print_readably) 02053 fprintf (rl_outstream, "set bell-style %s\n", kname); 02054 else 02055 fprintf (rl_outstream, "bell-style is set to `%s'\n", kname); 02056 02057 /* comment-begin */ 02058 if (print_readably) 02059 fprintf (rl_outstream, "set comment-begin %s\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT); 02060 else 02061 fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT); 02062 02063 /* completion-query-items */ 02064 if (print_readably) 02065 fprintf (rl_outstream, "set completion-query-items %d\n", rl_completion_query_items); 02066 else 02067 fprintf (rl_outstream, "completion-query-items is set to `%d'\n", rl_completion_query_items); 02068 02069 /* editing-mode */ 02070 if (print_readably) 02071 fprintf (rl_outstream, "set editing-mode %s\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi"); 02072 else 02073 fprintf (rl_outstream, "editing-mode is set to `%s'\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi"); 02074 02075 /* isearch-terminators */ 02076 if (_rl_isearch_terminators) 02077 { 02078 char *disp; 02079 02080 disp = _rl_untranslate_macro_value (_rl_isearch_terminators); 02081 02082 if (print_readably) 02083 fprintf (rl_outstream, "set isearch-terminators \"%s\"\n", disp); 02084 else 02085 fprintf (rl_outstream, "isearch-terminators is set to \"%s\"\n", disp); 02086 02087 free (disp); 02088 } 02089 02090 /* keymap */ 02091 kname = rl_get_keymap_name (_rl_keymap); 02092 if (kname == 0) 02093 kname = rl_get_keymap_name_from_edit_mode (); 02094 if (print_readably) 02095 fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none"); 02096 else 02097 fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none"); 02098 }
|
|
|
|
||||||||||||
|
Definition at line 2138 of file bind.c. References _rl_strindex(). Referenced by rl_parse_and_bind(). 02141 { 02142 while (*array) 02143 { 02144 if (_rl_strindex (string, *array)) 02145 return (1); 02146 array++; 02147 } 02148 return (0); 02149 }
|
|
|
Definition at line 1475 of file bind.c. References _rl_bell_preference, _rl_stricmp(), AUDIBLE_BELL, NO_BELL, and VISIBLE_BELL. 01477 { 01478 if (value == 0 || *value == '\0') 01479 _rl_bell_preference = AUDIBLE_BELL; 01480 else if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0) 01481 _rl_bell_preference = NO_BELL; 01482 else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0) 01483 _rl_bell_preference = AUDIBLE_BELL; 01484 else if (_rl_stricmp (value, "visible") == 0) 01485 _rl_bell_preference = VISIBLE_BELL; 01486 else 01487 return 1; 01488 return 0; 01489 }
|
|
|
Definition at line 1431 of file bind.c. References _rl_comment_begin, FREE, and savestring. 01433 { 01434 if (value && *value) 01435 { 01436 FREE (_rl_comment_begin); 01437 _rl_comment_begin = savestring (value); 01438 return 0; 01439 } 01440 return 1; 01441 }
|
|
|
Definition at line 1444 of file bind.c. References atoi(), and rl_completion_query_items. 01446 { 01447 int nval = 100; 01448 01449 if (value && *value) 01450 { 01451 nval = atoi (value); 01452 if (nval < 0) 01453 nval = 0; 01454 } 01455 rl_completion_query_items = nval; 01456 return 0; 01457 }
|
|
|
Definition at line 1410 of file bind.c. References _rl_keymap, _rl_strnicmp(), emacs_mode, emacs_standard_keymap, rl_editing_mode, vi_insertion_keymap, and vi_mode. 01412 { 01413 if (_rl_strnicmp (value, "vi", 2) == 0) 01414 { 01415 #if defined (VI_MODE) 01416 _rl_keymap = vi_insertion_keymap; 01417 rl_editing_mode = vi_mode; 01418 #endif /* VI_MODE */ 01419 return 0; 01420 } 01421 else if (_rl_strnicmp (value, "emacs", 5) == 0) 01422 { 01423 _rl_keymap = emacs_standard_keymap; 01424 rl_editing_mode = emacs_mode; 01425 return 0; 01426 } 01427 return 1; 01428 }
|
|
|
Definition at line 1492 of file bind.c. References _rl_isearch_terminators, free, FREE, rl_translate_keyseq(), savestring, whitespace, and xmalloc(). 01494 { 01495 int beg, end, delim; 01496 char *v; 01497 01498 if (value == 0) 01499 return 1; 01500 01501 /* Isolate the value and translate it into a character string. */ 01502 v = savestring (value); 01503 FREE (_rl_isearch_terminators); 01504 if (v[0] == '"' || v[0] == '\'') 01505 { 01506 delim = v[0]; 01507 for (beg = end = 1; v[end] && v[end] != delim; end++) 01508 ; 01509 } 01510 else 01511 { 01512 for (beg = end = 0; whitespace (v[end]) == 0; end++) 01513 ; 01514 } 01515 01516 v[end] = '\0'; 01517 01518 /* The value starts at v + beg. Translate it into a character string. */ 01519 _rl_isearch_terminators = (char *)xmalloc (2 * strlen (v) + 1); 01520 rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end); 01521 _rl_isearch_terminators[end] = '\0'; 01522 01523 free (v); 01524 return 0; 01525 }
|
|
|
Definition at line 1460 of file bind.c. References rl_get_keymap_by_name(), and rl_set_keymap(). 01462 { 01463 Keymap kmap; 01464 01465 kmap = rl_get_keymap_by_name (value); 01466 if (kmap) 01467 { 01468 rl_set_keymap (kmap); 01469 return 0; 01470 } 01471 return 1; 01472 }
|
|
|
Initial value: {
"Control-", "C-", "CTRL-", (const char *)NULL
}
|
|
|
Initial value: {
"Meta", "M-", (const char *)NULL
}
|
|
|
|
|
|
Referenced by find_boolean_var(), hack_special_boolean_var(), rl_variable_bind(), and rl_variable_dumper(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Referenced by rl_get_keymap_by_name(), and rl_get_keymap_name(). |
|
|
|
|
|
|
|
|
|
|
|
Initial value: {
{ "DEL", 0x7f },
{ "ESC", '\033' },
{ "Escape", '\033' },
{ "LFD", '\n' },
{ "Newline", '\n' },
{ "RET", '\r' },
{ "Return", '\r' },
{ "Rubout", 0x7f },
{ "SPC", ' ' },
{ "Space", ' ' },
{ "Tab", 0x09 },
{ (char *)0x0, 0 }
}
|
|
|
Referenced by handle_parser_directive(). |
|
|
|
|
|
|
|
|
Definition at line 1346 of file bind.c. Referenced by rl_variable_bind(). |
|
|
Referenced by find_string_var(), and rl_variable_bind(). |
|
1.4.3