mirror of
https://github.com/troglobit/editline.git
synced 2025-05-06 04:21:24 +08:00
Fix and make sure to use rl_set_prompt() API
Fixes #51 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
parent
2c0313a3b5
commit
d1ea173949
@ -115,7 +115,7 @@ static const char *old_prompt = NULL;
|
|||||||
static rl_vcpfunc_t *line_handler = NULL;
|
static rl_vcpfunc_t *line_handler = NULL;
|
||||||
static char *line_up = "\x1b[A";
|
static char *line_up = "\x1b[A";
|
||||||
static char *line_down = "\x1b[B";
|
static char *line_down = "\x1b[B";
|
||||||
int prompt_len = 0;
|
static int prompt_len = 0;
|
||||||
|
|
||||||
int el_no_echo = 0; /* e.g., under Emacs */
|
int el_no_echo = 0; /* e.g., under Emacs */
|
||||||
int el_no_hist = 0;
|
int el_no_hist = 0;
|
||||||
@ -125,6 +125,7 @@ int rl_end;
|
|||||||
int rl_meta_chars = 0; /* Display 8-bit chars as the actual char(0) or as `M-x'(1)? */
|
int rl_meta_chars = 0; /* Display 8-bit chars as the actual char(0) or as `M-x'(1)? */
|
||||||
int rl_inhibit_complete = 0;
|
int rl_inhibit_complete = 0;
|
||||||
char *rl_line_buffer = NULL;
|
char *rl_line_buffer = NULL;
|
||||||
|
static const char *rl_saved_prompt = NULL;
|
||||||
const char *rl_prompt = NULL;
|
const char *rl_prompt = NULL;
|
||||||
const char *rl_readline_name = NULL; /* Set by calling program, for conditional parsing of ~/.inputrc - Not supported yet! */
|
const char *rl_readline_name = NULL; /* Set by calling program, for conditional parsing of ~/.inputrc - Not supported yet! */
|
||||||
FILE *rl_instream = NULL; /* The stdio stream from which input is read. Defaults to stdin if NULL */
|
FILE *rl_instream = NULL; /* The stdio stream from which input is read. Defaults to stdin if NULL */
|
||||||
@ -772,7 +773,7 @@ static const char *search_hist(const char *search, const char *(*move)(void))
|
|||||||
|
|
||||||
static el_status_t h_search_end(const char *p)
|
static el_status_t h_search_end(const char *p)
|
||||||
{
|
{
|
||||||
rl_prompt = old_prompt;
|
rl_set_prompt(old_prompt);
|
||||||
Searching = 0;
|
Searching = 0;
|
||||||
|
|
||||||
if (el_intr_pending > 0) {
|
if (el_intr_pending > 0) {
|
||||||
@ -799,8 +800,8 @@ static el_status_t h_search(void)
|
|||||||
|
|
||||||
clear_line();
|
clear_line();
|
||||||
old_prompt = rl_prompt;
|
old_prompt = rl_prompt;
|
||||||
rl_prompt = "Search: ";
|
rl_set_prompt("Search: ");
|
||||||
tty_puts(rl_prompt);
|
reposition(EOF);
|
||||||
|
|
||||||
search_move = Repeat == NO_ARG ? el_prev_hist : el_next_hist;
|
search_move = Repeat == NO_ARG ? el_prev_hist : el_next_hist;
|
||||||
if (line_handler) {
|
if (line_handler) {
|
||||||
@ -1363,10 +1364,28 @@ void rl_reset_terminal(const char *terminal_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rl_set_prompt(const char *prompt)
|
||||||
|
{
|
||||||
|
if (prompt)
|
||||||
|
rl_prompt = prompt;
|
||||||
|
prompt_len = strlen(rl_prompt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rl_save_prompt(void)
|
||||||
|
{
|
||||||
|
rl_saved_prompt = rl_prompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rl_restore_prompt(void)
|
||||||
|
{
|
||||||
|
if (rl_saved_prompt)
|
||||||
|
rl_set_prompt(rl_saved_prompt);
|
||||||
|
}
|
||||||
|
|
||||||
void rl_initialize(void)
|
void rl_initialize(void)
|
||||||
{
|
{
|
||||||
if (!rl_prompt)
|
if (!rl_prompt)
|
||||||
rl_prompt = "? ";
|
rl_set_prompt("? ");
|
||||||
|
|
||||||
hist_alloc();
|
hist_alloc();
|
||||||
|
|
||||||
@ -1407,23 +1426,6 @@ void rl_uninitialize(void)
|
|||||||
Length = 0;
|
Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *rl_saved_prompt = NULL;
|
|
||||||
void rl_save_prompt(void)
|
|
||||||
{
|
|
||||||
rl_saved_prompt = rl_prompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void rl_restore_prompt(void)
|
|
||||||
{
|
|
||||||
if (rl_saved_prompt)
|
|
||||||
rl_prompt = rl_saved_prompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void rl_set_prompt(const char *prompt)
|
|
||||||
{
|
|
||||||
rl_prompt = prompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void rl_clear_message(void)
|
void rl_clear_message(void)
|
||||||
{
|
{
|
||||||
/* Nothing to do atm. */
|
/* Nothing to do atm. */
|
||||||
@ -1454,9 +1456,7 @@ static int el_prep(const char *prompt)
|
|||||||
if (!Screen)
|
if (!Screen)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (prompt)
|
rl_set_prompt(prompt);
|
||||||
rl_prompt = prompt;
|
|
||||||
prompt_len = strlen(rl_prompt);
|
|
||||||
|
|
||||||
if (el_no_echo) {
|
if (el_no_echo) {
|
||||||
int old = el_no_echo;
|
int old = el_no_echo;
|
||||||
|
Loading…
Reference in New Issue
Block a user