mirror of https://github.com/ipxe/ipxe.git
[editbox] Allow for password widgets that do not display their contents
parent
cff419148c
commit
67ee41ad6d
|
@ -38,11 +38,11 @@
|
||||||
* @v row Row
|
* @v row Row
|
||||||
* @v col Starting column
|
* @v col Starting column
|
||||||
* @v width Width
|
* @v width Width
|
||||||
*
|
* @v flags Flags
|
||||||
*/
|
*/
|
||||||
void init_editbox ( struct edit_box *box, char *buf, size_t len,
|
void init_editbox ( struct edit_box *box, char *buf, size_t len,
|
||||||
WINDOW *win, unsigned int row, unsigned int col,
|
WINDOW *win, unsigned int row, unsigned int col,
|
||||||
unsigned int width ) {
|
unsigned int width, unsigned int flags ) {
|
||||||
memset ( box, 0, sizeof ( *box ) );
|
memset ( box, 0, sizeof ( *box ) );
|
||||||
box->string.buf = buf;
|
box->string.buf = buf;
|
||||||
box->string.len = len;
|
box->string.len = len;
|
||||||
|
@ -51,6 +51,7 @@ void init_editbox ( struct edit_box *box, char *buf, size_t len,
|
||||||
box->row = row;
|
box->row = row;
|
||||||
box->col = col;
|
box->col = col;
|
||||||
box->width = width;
|
box->width = width;
|
||||||
|
box->flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +87,11 @@ void draw_editbox ( struct edit_box *box ) {
|
||||||
len = ( strlen ( box->string.buf ) - first );
|
len = ( strlen ( box->string.buf ) - first );
|
||||||
if ( len > width )
|
if ( len > width )
|
||||||
len = width;
|
len = width;
|
||||||
memcpy ( buf, ( box->string.buf + first ), len );
|
if ( box->flags & EDITBOX_STARS ) {
|
||||||
|
memset ( buf, '*', len );
|
||||||
|
} else {
|
||||||
|
memcpy ( buf, ( box->string.buf + first ), len );
|
||||||
|
}
|
||||||
|
|
||||||
/* Print box content and move cursor */
|
/* Print box content and move cursor */
|
||||||
if ( ! box->win )
|
if ( ! box->win )
|
||||||
|
|
|
@ -123,7 +123,7 @@ static void load_setting ( struct setting_widget *widget ) {
|
||||||
init_editbox ( &widget->editbox, widget->value,
|
init_editbox ( &widget->editbox, widget->value,
|
||||||
sizeof ( widget->value ), NULL, widget->row,
|
sizeof ( widget->value ), NULL, widget->row,
|
||||||
( widget->col + offsetof ( struct setting_row, value )),
|
( widget->col + offsetof ( struct setting_row, value )),
|
||||||
sizeof ( ( ( struct setting_row * ) NULL )->value ) );
|
sizeof ( ( ( struct setting_row * ) NULL )->value ), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,14 +24,22 @@ struct edit_box {
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
/** First displayed character */
|
/** First displayed character */
|
||||||
unsigned int first;
|
unsigned int first;
|
||||||
|
/** Flags */
|
||||||
|
unsigned int flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Editable text box widget flags */
|
||||||
|
enum edit_box_flags {
|
||||||
|
/** Show stars instead of contents (for password widgets) */
|
||||||
|
EDITBOX_STARS = 0x0001,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void init_editbox ( struct edit_box *box, char *buf, size_t len,
|
extern void init_editbox ( struct edit_box *box, char *buf, size_t len,
|
||||||
WINDOW *win, unsigned int row, unsigned int col,
|
WINDOW *win, unsigned int row, unsigned int col,
|
||||||
unsigned int width )
|
unsigned int width, unsigned int flags )
|
||||||
__attribute__ (( nonnull (1, 2) ));
|
__attribute__ (( nonnull (1, 2) ));
|
||||||
extern void draw_editbox ( struct edit_box *box ) __nonnull;
|
extern void draw_editbox ( struct edit_box *box ) __nonnull;
|
||||||
static inline int __pure edit_editbox ( struct edit_box *box, int key ) __nonnull;
|
static inline int edit_editbox ( struct edit_box *box, int key ) __nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit text box widget
|
* Edit text box widget
|
||||||
|
|
Loading…
Reference in New Issue