version 1.140, 2017/01/09 03:09:05 |
version 1.146, 2018/01/01 22:32:46 |
Line 122 int readline_echoing_p = 1; |
|
Line 122 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; |
Function *rl_startup_hook = NULL; |
Function *rl_startup_hook = NULL; |
|
int rl_did_startup_hook = 0; |
VFunction *rl_completion_display_matches_hook = NULL; |
VFunction *rl_completion_display_matches_hook = NULL; |
VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal; |
VFunction *rl_prep_term_function = (VFunction *)rl_prep_terminal; |
VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal; |
VFunction *rl_deprep_term_function = (VFunction *)rl_deprep_terminal; |
Line 289 rl_initialize(void) |
|
Line 290 rl_initialize(void) |
|
if (tcgetattr(fileno(rl_instream), &t) != -1 && (t.c_lflag & ECHO) == 0) |
if (tcgetattr(fileno(rl_instream), &t) != -1 && (t.c_lflag & ECHO) == 0) |
editmode = 0; |
editmode = 0; |
|
|
e = el_init(rl_readline_name, rl_instream, rl_outstream, stderr); |
e = el_init_internal(rl_readline_name, rl_instream, rl_outstream, |
|
stderr, fileno(rl_instream), fileno(rl_outstream), fileno(stderr), |
|
NO_RESET); |
|
|
if (!editmode) |
if (!editmode) |
el_set(e, EL_EDITMODE, 0); |
el_set(e, EL_EDITMODE, 0); |
Line 385 rl_initialize(void) |
|
Line 388 rl_initialize(void) |
|
_resize_fun(e, &rl_line_buffer); |
_resize_fun(e, &rl_line_buffer); |
_rl_update_pos(); |
_rl_update_pos(); |
|
|
if (rl_startup_hook) |
tty_end(e, TCSADRAIN); |
(*rl_startup_hook)(NULL, 0); |
|
|
|
return 0; |
return 0; |
} |
} |
Line 408 readline(const char *p) |
|
Line 410 readline(const char *p) |
|
|
|
if (e == NULL || h == NULL) |
if (e == NULL || h == NULL) |
rl_initialize(); |
rl_initialize(); |
|
if (rl_did_startup_hook == 0 && rl_startup_hook) { |
|
rl_did_startup_hook = 1; |
|
(*rl_startup_hook)(NULL, 0); |
|
} |
|
tty_init(e); |
|
|
|
|
rl_done = 0; |
rl_done = 0; |
|
|
(void)setjmp(topbuf); |
(void)setjmp(topbuf); |
|
buf = NULL; |
|
|
/* update prompt accordingly to what has been passed */ |
/* update prompt accordingly to what has been passed */ |
if (rl_set_prompt(prompt) == -1) |
if (rl_set_prompt(prompt) == -1) |
return NULL; |
goto out; |
|
|
if (rl_pre_input_hook) |
if (rl_pre_input_hook) |
(*rl_pre_input_hook)(NULL, 0); |
(*rl_pre_input_hook)(NULL, 0); |
Line 440 readline(const char *p) |
|
Line 449 readline(const char *p) |
|
|
|
buf = strdup(ret); |
buf = strdup(ret); |
if (buf == NULL) |
if (buf == NULL) |
return NULL; |
goto out; |
lastidx = count - 1; |
lastidx = count - 1; |
if (buf[lastidx] == '\n') |
if (buf[lastidx] == '\n') |
buf[lastidx] = '\0'; |
buf[lastidx] = '\0'; |
Line 450 readline(const char *p) |
|
Line 459 readline(const char *p) |
|
history(h, &ev, H_GETSIZE); |
history(h, &ev, H_GETSIZE); |
history_length = ev.num; |
history_length = ev.num; |
|
|
|
out: |
|
tty_end(e, TCSADRAIN); |
return buf; |
return buf; |
} |
} |
|
|
Line 1344 read_history(const char *filename) |
|
Line 1355 read_history(const char *filename) |
|
rl_initialize(); |
rl_initialize(); |
if (filename == NULL && (filename = _default_history_file()) == NULL) |
if (filename == NULL && (filename = _default_history_file()) == NULL) |
return errno; |
return errno; |
return history(h, &ev, H_LOAD, filename) == -1 ? |
errno = 0; |
(errno ? errno : EINVAL) : 0; |
if (history(h, &ev, H_LOAD, filename) == -1) |
|
return errno ? errno : EINVAL; |
|
if (history(h, &ev, H_GETSIZE) == 0) |
|
history_length = ev.num; |
|
if (history_length < 0) |
|
return EINVAL; |
|
return 0; |
} |
} |
|
|
|
|
Line 1365 write_history(const char *filename) |
|
Line 1382 write_history(const char *filename) |
|
(errno ? errno : EINVAL) : 0; |
(errno ? errno : EINVAL) : 0; |
} |
} |
|
|
|
int |
|
append_history(int n, const char *filename) |
|
{ |
|
HistEvent ev; |
|
FILE *fp; |
|
|
|
if (h == NULL || e == NULL) |
|
rl_initialize(); |
|
if (filename == NULL && (filename = _default_history_file()) == NULL) |
|
return errno; |
|
|
|
if ((fp = fopen(filename, "a")) == NULL) |
|
return errno; |
|
|
|
if (history(h, &ev, H_NSAVE_FP, (size_t)n, fp) == -1) { |
|
int serrno = errno ? errno : EINVAL; |
|
fclose(fp); |
|
return serrno; |
|
} |
|
fclose(fp); |
|
return 0; |
|
} |
|
|
/* |
/* |
* returns history ``num''th event |
* returns history ``num''th event |
Line 1812 _el_rl_tstp(EditLine *el __attribute__(( |
|
Line 1851 _el_rl_tstp(EditLine *el __attribute__(( |
|
return CC_NORM; |
return CC_NORM; |
} |
} |
|
|
/* |
|
* Display list of strings in columnar format on readline's output stream. |
|
* 'matches' is list of strings, 'len' is number of strings in 'matches', |
|
* 'max' is maximum length of string in 'matches'. |
|
*/ |
|
void |
|
rl_display_match_list(char **matches, int len, int max) |
|
{ |
|
|
|
fn_display_match_list(e, matches, (size_t)len, (size_t)max); |
|
} |
|
|
|
static const char * |
static const char * |
/*ARGSUSED*/ |
/*ARGSUSED*/ |
_rl_completion_append_character_function(const char *dummy |
_rl_completion_append_character_function(const char *dummy |
Line 1837 _rl_completion_append_character_function |
|
Line 1864 _rl_completion_append_character_function |
|
|
|
|
|
/* |
/* |
|
* Display list of strings in columnar format on readline's output stream. |
|
* 'matches' is list of strings, 'len' is number of strings in 'matches', |
|
* 'max' is maximum length of string in 'matches'. |
|
*/ |
|
void |
|
rl_display_match_list(char **matches, int len, int max) |
|
{ |
|
|
|
fn_display_match_list(e, matches, (size_t)len, (size_t)max, |
|
_rl_completion_append_character_function); |
|
} |
|
|
|
/* |
* complete word at current point |
* complete word at current point |
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
Line 2039 rl_callback_read_char(void) |
|
Line 2079 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); |
if (!rl_already_prompted) { |
|
el_set(e, EL_UNBUFFERED, 1); |
|
rl_already_prompted = 1; |
|
} |
} |
} |
} |
} |
|
|
Line 2057 rl_callback_handler_install(const char * |
|
Line 2100 rl_callback_handler_install(const char * |
|
void |
void |
rl_callback_handler_remove(void) |
rl_callback_handler_remove(void) |
{ |
{ |
el_set(e, EL_UNBUFFERED, 0); |
|
rl_linefunc = NULL; |
rl_linefunc = NULL; |
|
el_end(e); |
|
e = NULL; |
} |
} |
|
|
void |
void |
Line 2368 rl_set_keyboard_input_timeout(int u __at |
|
Line 2412 rl_set_keyboard_input_timeout(int u __at |
|
{ |
{ |
return 0; |
return 0; |
} |
} |
|
|
|
void |
|
rl_resize_terminal(void) |
|
{ |
|
el_resize(e); |
|
} |