mirror of https://github.com/ipxe/ipxe.git
[readline] Add init_editstring() wrapper function
Standardise on using init_editstring() to initialise an embedded editable string, to match the coding style used by other embedded objects. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/1/head
parent
293e347a2e
commit
6a6dd5c452
|
@ -46,8 +46,7 @@ void init_editbox ( struct edit_box *box, char *buf, size_t len,
|
|||
WINDOW *win, unsigned int row, unsigned int col,
|
||||
unsigned int width, unsigned int flags ) {
|
||||
memset ( box, 0, sizeof ( *box ) );
|
||||
box->string.buf = buf;
|
||||
box->string.len = len;
|
||||
init_editstring ( &box->string, buf, len );
|
||||
box->string.cursor = strlen ( buf );
|
||||
box->win = ( win ? win : stdscr );
|
||||
box->row = row;
|
||||
|
|
|
@ -93,8 +93,7 @@ char * readline ( const char *prompt ) {
|
|||
printf ( "%s", prompt );
|
||||
|
||||
memset ( &string, 0, sizeof ( string ) );
|
||||
string.buf = buf;
|
||||
string.len = sizeof ( buf );
|
||||
init_editstring ( &string, buf, sizeof ( buf ) );
|
||||
buf[0] = '\0';
|
||||
|
||||
while ( 1 ) {
|
||||
|
|
|
@ -28,6 +28,19 @@ struct edit_string {
|
|||
unsigned int mod_end;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise editable string
|
||||
*
|
||||
* @v string Editable string
|
||||
* @v buf Buffer for string
|
||||
* @v len Length of buffer
|
||||
*/
|
||||
static inline void init_editstring ( struct edit_string *string, char *buf,
|
||||
size_t len ) {
|
||||
string->buf = buf;
|
||||
string->len = len;
|
||||
}
|
||||
|
||||
extern int edit_string ( struct edit_string *string, int key ) __nonnull;
|
||||
|
||||
#endif /* _IPXE_EDITSTRING_H */
|
||||
|
|
Loading…
Reference in New Issue