rl_insert_text(): new readline compat fn

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2017-12-02 21:13:39 +01:00
parent a9824655ee
commit 29a71a53d0
2 changed files with 11 additions and 0 deletions

View File

@ -95,6 +95,7 @@ extern void rl_prep_terminal (int meta_flag);
extern void rl_deprep_terminal (void); extern void rl_deprep_terminal (void);
extern int rl_getc(void); extern int rl_getc(void);
extern int rl_insert_text (const char *text);
extern char *readline (const char *prompt); extern char *readline (const char *prompt);

View File

@ -514,6 +514,16 @@ static el_status_t insert_string(const char *p)
return rl_point == rl_end ? CSstay : CSmove; return rl_point == rl_end ? CSstay : CSmove;
} }
int rl_insert_text(const char *text)
{
int mark = rl_point;
insert_string(text);
ceol();
return rl_point - mark;
}
static el_status_t redisplay(void) static el_status_t redisplay(void)
{ {
/* XXX: Use "\r\e[K" to get really neat effect on ANSI capable terminals. */ /* XXX: Use "\r\e[K" to get really neat effect on ANSI capable terminals. */