bind.c File Reference

#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 []


Define Documentation

#define READLINE_LIBRARY
 

Definition at line 22 of file bind.c.

#define V_BELLSTYLE   0
 

Definition at line 1326 of file bind.c.

#define V_COMBEGIN   1
 

Definition at line 1327 of file bind.c.

#define V_EDITMODE   2
 

Definition at line 1328 of file bind.c.

#define V_INT   2
 

Definition at line 1333 of file bind.c.

#define V_ISRCHTERM   3
 

Definition at line 1329 of file bind.c.

#define V_KEYMAP   4
 

Definition at line 1330 of file bind.c.

#define V_SPECIAL   0x1
 

Definition at line 1255 of file bind.c.

Referenced by rl_variable_bind().

#define V_STRING   1
 

Definition at line 1332 of file bind.c.


Typedef Documentation

static boolean stab_demangle_fund_type PARAMS
 

Definition at line 805 of file bind.c.


Function Documentation

void _rl_bind_if_unbound char *  keyseq,
rl_command_func_t *  default_func
const
 

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 }

static char* _rl_get_keyname int  key  )  [static]
 

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 }

static void _rl_init_file_error char *  msg  )  const [static]
 

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 }

static void _rl_macro_dumper_internal int  print_readably,
Keymap  map,
char *  prefix
[static]
 

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 }

static char* _rl_read_file char *  filename,
size_t sizep
[static]
 

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 }

static int _rl_read_init_file char *  filename,
int  include_level
const [static]
 

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 }

static char* _rl_untranslate_macro_value char *  seq  )  [static]
 

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 }

static int bool_to_int char *  value  )  [static]
 

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 }

static int find_boolean_var char *  name  )  const [static]
 

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 }

static int find_string_var char *  name  )  const [static]
 

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 }

static int glean_key_from_name char *  name  )  [static]
 

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 }

static void hack_special_boolean_var int  i  )  [static]
 

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 }

static int handle_parser_directive char *  statement  )  [static]
 

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 }

static int parser_else args   )  [static]
 

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 }

static int parser_endif args   )  [static]
 

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 }

static int parser_if char *  args  )  [static]
 

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 }

static int parser_include char *  args  )  [static]
 

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 }

int rl_add_defun char *  name,
rl_command_func_t *  function,
int  key
const
 

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 }

int rl_bind_key int  key,
rl_command_func_t *  function
 

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 }

int rl_bind_key_in_map int  key,
rl_command_func_t *  function,
Keymap  map
 

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 }

int rl_dump_functions count  ,
key 
 

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 }

int rl_dump_macros count  ,
key 
 

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 }

int rl_dump_variables count  ,
key 
 

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 }

void rl_function_dumper int  print_readably  ) 
 

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