diff --git a/include/editline.h b/include/editline.h index 6fc7d56..c726ed1 100644 --- a/include/editline.h +++ b/include/editline.h @@ -95,6 +95,7 @@ extern void rl_prep_terminal (int meta_flag); extern void rl_deprep_terminal (void); extern int rl_getc(void); +extern int rl_insert_text (const char *text); extern char *readline (const char *prompt); diff --git a/src/editline.c b/src/editline.c index da3e234..84bd3d6 100644 --- a/src/editline.c +++ b/src/editline.c @@ -514,6 +514,16 @@ static el_status_t insert_string(const char *p) 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) { /* XXX: Use "\r\e[K" to get really neat effect on ANSI capable terminals. */