version 1.107, 2013/01/13 15:46:57 |
version 1.115, 2015/04/01 15:23:15 |
Line 84 VFunction *rl_event_hook = NULL; |
|
Line 84 VFunction *rl_event_hook = NULL; |
|
KEYMAP_ENTRY_ARRAY emacs_standard_keymap, |
KEYMAP_ENTRY_ARRAY emacs_standard_keymap, |
emacs_meta_keymap, |
emacs_meta_keymap, |
emacs_ctlx_keymap; |
emacs_ctlx_keymap; |
|
/* |
|
* The following is not implemented; we always catch signals in the |
|
* libedit fashion: set handlers on entry to el_gets() and clear them |
|
* on the way out. This simplistic approach works for most cases; if |
|
* it does not work for your application, please let us know. |
|
*/ |
|
int rl_catch_signals = 1; |
|
int rl_catch_sigwinch = 1; |
|
|
int history_base = 1; /* probably never subject to change */ |
int history_base = 1; /* probably never subject to change */ |
int history_length = 0; |
int history_length = 0; |
Line 109 char *rl_terminal_name = NULL; |
|
Line 117 char *rl_terminal_name = NULL; |
|
int rl_already_prompted = 0; |
int rl_already_prompted = 0; |
int rl_filename_completion_desired = 0; |
int rl_filename_completion_desired = 0; |
int rl_ignore_completion_duplicates = 0; |
int rl_ignore_completion_duplicates = 0; |
int rl_catch_signals = 1; |
|
int readline_echoing_p = 1; |
int readline_echoing_p = 1; |
int _rl_print_completions_horizontally = 0; |
int _rl_print_completions_horizontally = 0; |
VFunction *rl_redisplay_function = NULL; |
VFunction *rl_redisplay_function = NULL; |
Line 229 static const char * |
|
Line 236 static const char * |
|
_default_history_file(void) |
_default_history_file(void) |
{ |
{ |
struct passwd *p; |
struct passwd *p; |
static char path[PATH_MAX]; |
static char *path; |
|
size_t len; |
|
|
if (*path) |
if (path) |
return path; |
return path; |
|
|
if ((p = getpwuid(getuid())) == NULL) |
if ((p = getpwuid(getuid())) == NULL) |
return NULL; |
return NULL; |
(void)snprintf(path, sizeof(path), "%s/.history", p->pw_dir); |
|
|
len = strlen(p->pw_dir) + sizeof("/.history"); |
|
if ((path = malloc(len)) == NULL) |
|
return NULL; |
|
|
|
(void)snprintf(path, len, "%s/.history", p->pw_dir); |
return path; |
return path; |
} |
} |
|
|
Line 324 rl_initialize(void) |
|
Line 338 rl_initialize(void) |
|
el_set(e, EL_SIGNAL, rl_catch_signals); |
el_set(e, EL_SIGNAL, rl_catch_signals); |
|
|
/* set default mode to "emacs"-style and read setting afterwards */ |
/* set default mode to "emacs"-style and read setting afterwards */ |
/* so this can be overriden */ |
/* so this can be overridden */ |
el_set(e, EL_EDITOR, "emacs"); |
el_set(e, EL_EDITOR, "emacs"); |
if (rl_terminal_name != NULL) |
if (rl_terminal_name != NULL) |
el_set(e, EL_TERMINAL, rl_terminal_name); |
el_set(e, EL_TERMINAL, rl_terminal_name); |
Line 348 rl_initialize(void) |
|
Line 362 rl_initialize(void) |
|
_el_rl_tstp); |
_el_rl_tstp); |
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL); |
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL); |
|
|
|
/* |
|
* Set some readline compatible key-bindings. |
|
*/ |
|
el_set(e, EL_BIND, "^R", "em-inc-search-prev", NULL); |
|
|
|
/* |
|
* Allow the use of Home/End keys. |
|
*/ |
|
el_set(e, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL); |
|
el_set(e, EL_BIND, "\\e[4~", "ed-move-to-end", NULL); |
|
el_set(e, EL_BIND, "\\e[7~", "ed-move-to-beg", NULL); |
|
el_set(e, EL_BIND, "\\e[8~", "ed-move-to-end", NULL); |
|
el_set(e, EL_BIND, "\\e[H", "ed-move-to-beg", NULL); |
|
el_set(e, EL_BIND, "\\e[F", "ed-move-to-end", NULL); |
|
|
|
/* |
|
* Allow the use of the Delete/Insert keys. |
|
*/ |
|
el_set(e, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL); |
|
el_set(e, EL_BIND, "\\e[2~", "ed-quoted-insert", NULL); |
|
|
|
/* |
|
* Ctrl-left-arrow and Ctrl-right-arrow for word moving. |
|
*/ |
|
el_set(e, EL_BIND, "\\e[1;5C", "em-next-word", NULL); |
|
el_set(e, EL_BIND, "\\e[1;5D", "ed-prev-word", NULL); |
|
el_set(e, EL_BIND, "\\e[5C", "em-next-word", NULL); |
|
el_set(e, EL_BIND, "\\e[5D", "ed-prev-word", NULL); |
|
el_set(e, EL_BIND, "\\e\\e[C", "em-next-word", NULL); |
|
el_set(e, EL_BIND, "\\e\\e[D", "ed-prev-word", NULL); |
|
|
/* read settings from configuration file */ |
/* read settings from configuration file */ |
el_source(e, NULL); |
el_source(e, NULL); |
|
|
Line 620 get_history_event(const char *cmd, int * |
|
Line 665 get_history_event(const char *cmd, int * |
|
* returns 0 if data was not modified, 1 if it was and 2 if the string |
* returns 0 if data was not modified, 1 if it was and 2 if the string |
* should be only printed and not executed; in case of error, |
* should be only printed and not executed; in case of error, |
* returns -1 and *result points to NULL |
* returns -1 and *result points to NULL |
* it's callers responsibility to free() string returned in *result |
* it's the caller's responsibility to free() the string returned in *result |
*/ |
*/ |
static int |
static int |
_history_expand_command(const char *command, size_t offs, size_t cmdlen, |
_history_expand_command(const char *command, size_t offs, size_t cmdlen, |
|
|
for (; str[j]; j++) { |
for (; str[j]; j++) { |
if (str[j] == '\\' && |
if (str[j] == '\\' && |
str[j + 1] == history_expansion_char) { |
str[j + 1] == history_expansion_char) { |
(void)strcpy(&str[j], &str[j + 1]); |
len = strlen(&str[j + 1]) + 1; |
|
memmove(&str[j], &str[j + 1], len); |
continue; |
continue; |
} |
} |
if (!loop_again) { |
if (!loop_again) { |
Line 1468 clear_history(void) |
|
Line 1514 clear_history(void) |
|
{ |
{ |
HistEvent ev; |
HistEvent ev; |
|
|
|
if (h == NULL || e == NULL) |
|
rl_initialize(); |
|
|
(void)history(h, &ev, H_CLEAR); |
(void)history(h, &ev, H_CLEAR); |
history_length = 0; |
history_length = 0; |
} |
} |
Line 1677 filename_completion_function(const char |
|
Line 1726 filename_completion_function(const char |
|
* which starts with supplied text |
* which starts with supplied text |
* text contains a partial username preceded by random character |
* text contains a partial username preceded by random character |
* (usually '~'); state resets search from start (??? should we do that anyway) |
* (usually '~'); state resets search from start (??? should we do that anyway) |
* it's callers responsibility to free returned value |
* it's the caller's responsibility to free the returned value |
*/ |
*/ |
char * |
char * |
username_completion_function(const char *text, int state) |
username_completion_function(const char *text, int state) |
Line 1953 rl_callback_read_char(void) |
|
Line 2002 rl_callback_read_char(void) |
|
} else |
} else |
wbuf = NULL; |
wbuf = NULL; |
(*(void (*)(const char *))rl_linefunc)(wbuf); |
(*(void (*)(const char *))rl_linefunc)(wbuf); |
//el_set(e, EL_UNBUFFERED, 1); |
el_set(e, EL_UNBUFFERED, 1); |
} |
} |
} |
} |
|
|