diff options
| author | Michael Brown | 2011-03-29 17:40:23 +0200 |
|---|---|---|
| committer | Michael Brown | 2011-03-30 20:26:48 +0200 |
| commit | d6f2408f2cf8abce51bb70f5ff2a2989818f0025 (patch) | |
| tree | 5bda6666db176cce440ea4cb64be8f8252e22f68 | |
| parent | [readline] Add init_editstring() wrapper function (diff) | |
| download | ipxe-d6f2408f2cf8abce51bb70f5ff2a2989818f0025.tar.gz ipxe-d6f2408f2cf8abce51bb70f5ff2a2989818f0025.tar.xz ipxe-d6f2408f2cf8abce51bb70f5ff2a2989818f0025.zip | |
[readline] Add replace_string()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
| -rw-r--r-- | src/hci/editstring.c | 11 | ||||
| -rw-r--r-- | src/include/ipxe/editstring.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/hci/editstring.c b/src/hci/editstring.c index 9207e58a7..996528ff5 100644 --- a/src/hci/editstring.c +++ b/src/hci/editstring.c @@ -118,6 +118,17 @@ static void kill_eol ( struct edit_string *string ) { } /** + * Replace editable string + * + * @v string Editable string + * @v replacement Replacement string + */ +void replace_string ( struct edit_string *string, const char *replacement ) { + string->cursor = 0; + insert_delete ( string, ~( ( size_t ) 0 ), replacement ); +} + +/** * Edit editable string * * @v string Editable string diff --git a/src/include/ipxe/editstring.h b/src/include/ipxe/editstring.h index 26cb434cf..2ef546a63 100644 --- a/src/include/ipxe/editstring.h +++ b/src/include/ipxe/editstring.h @@ -41,6 +41,8 @@ static inline void init_editstring ( struct edit_string *string, char *buf, string->len = len; } +extern void replace_string ( struct edit_string *string, + const char *replacement ) __nonnull; extern int edit_string ( struct edit_string *string, int key ) __nonnull; #endif /* _IPXE_EDITSTRING_H */ |
