Sfoglia il codice sorgente

[readline] Add replace_string()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 anni fa
parent
commit
d6f2408f2c
2 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 11
    0
      src/hci/editstring.c
  2. 2
    0
      src/include/ipxe/editstring.h

+ 11
- 0
src/hci/editstring.c Vedi File

@@ -117,6 +117,17 @@ static void kill_eol ( struct edit_string *string ) {
117 117
 	insert_delete ( string, ~( ( size_t ) 0 ), NULL );
118 118
 }
119 119
 
120
+/**
121
+ * Replace editable string
122
+ *
123
+ * @v string		Editable string
124
+ * @v replacement	Replacement string
125
+ */
126
+void replace_string ( struct edit_string *string, const char *replacement ) {
127
+	string->cursor = 0;
128
+	insert_delete ( string, ~( ( size_t ) 0 ), replacement );
129
+}
130
+
120 131
 /**
121 132
  * Edit editable string
122 133
  *

+ 2
- 0
src/include/ipxe/editstring.h Vedi File

@@ -41,6 +41,8 @@ static inline void init_editstring ( struct edit_string *string, char *buf,
41 41
 	string->len = len;
42 42
 }
43 43
 
44
+extern void replace_string ( struct edit_string *string,
45
+			     const char *replacement ) __nonnull;
44 46
 extern int edit_string ( struct edit_string *string, int key ) __nonnull;
45 47
 
46 48
 #endif /* _IPXE_EDITSTRING_H */

Loading…
Annulla
Salva