diff options
Diffstat (limited to 'src/hci/mucurses')
| -rw-r--r-- | src/hci/mucurses/ansi_screen.c | 1 | ||||
| -rw-r--r-- | src/hci/mucurses/clear.c | 1 | ||||
| -rw-r--r-- | src/hci/mucurses/cursor.h | 1 | ||||
| -rw-r--r-- | src/hci/mucurses/mucurses.c | 1 | ||||
| -rw-r--r-- | src/hci/mucurses/mucurses.h | 1 | ||||
| -rw-r--r-- | src/hci/mucurses/print.c | 1 | ||||
| -rw-r--r-- | src/hci/mucurses/widgets/editbox.c | 69 | ||||
| -rw-r--r-- | src/hci/mucurses/winattrs.c | 1 | ||||
| -rw-r--r-- | src/hci/mucurses/wininit.c | 1 |
9 files changed, 41 insertions, 36 deletions
diff --git a/src/hci/mucurses/ansi_screen.c b/src/hci/mucurses/ansi_screen.c index 1cf3309dd..7c607b5cc 100644 --- a/src/hci/mucurses/ansi_screen.c +++ b/src/hci/mucurses/ansi_screen.c @@ -4,6 +4,7 @@ #include <ipxe/console.h> FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); static void ansiscr_reset(struct _curses_screen *scr) __nonnull; static void ansiscr_movetoyx(struct _curses_screen *scr, diff --git a/src/hci/mucurses/clear.c b/src/hci/mucurses/clear.c index 2054f72cc..d93e9630e 100644 --- a/src/hci/mucurses/clear.c +++ b/src/hci/mucurses/clear.c @@ -9,6 +9,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Clear a window to the bottom from current cursor position diff --git a/src/hci/mucurses/cursor.h b/src/hci/mucurses/cursor.h index 2e0c896a6..6f47becae 100644 --- a/src/hci/mucurses/cursor.h +++ b/src/hci/mucurses/cursor.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); struct cursor_pos { unsigned int y, x; diff --git a/src/hci/mucurses/mucurses.c b/src/hci/mucurses/mucurses.c index 98a8a2c59..7f1779e8f 100644 --- a/src/hci/mucurses/mucurses.c +++ b/src/hci/mucurses/mucurses.c @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); static void _wupdcurs ( WINDOW *win ) __nonnull; void _wputch ( WINDOW *win, chtype ch, int wrap ) __nonnull; diff --git a/src/hci/mucurses/mucurses.h b/src/hci/mucurses/mucurses.h index 270394787..dc6187741 100644 --- a/src/hci/mucurses/mucurses.h +++ b/src/hci/mucurses/mucurses.h @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #define WRAP 0 #define NOWRAP 1 diff --git a/src/hci/mucurses/print.c b/src/hci/mucurses/print.c index e8831c58f..f7e0c8483 100644 --- a/src/hci/mucurses/print.c +++ b/src/hci/mucurses/print.c @@ -11,6 +11,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Add a single-byte character and rendition to a window and advance diff --git a/src/hci/mucurses/widgets/editbox.c b/src/hci/mucurses/widgets/editbox.c index 210de4481..5dab3ac5c 100644 --- a/src/hci/mucurses/widgets/editbox.c +++ b/src/hci/mucurses/widgets/editbox.c @@ -22,9 +22,11 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); #include <string.h> #include <assert.h> +#include <ipxe/ansicol.h> #include <ipxe/editbox.h> /** @file @@ -36,38 +38,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define EDITBOX_MIN_CHARS 3 /** - * Initialise text box widget - * - * @v box Editable text box widget - * @v buf Text buffer - * @v len Size of text buffer - * @v win Containing window - * @v row Row - * @v col Starting column - * @v width Width - * @v flags Flags - */ -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 ) ); - init_editstring ( &box->string, buf, len ); - box->string.cursor = strlen ( buf ); - box->win = ( win ? win : stdscr ); - box->row = row; - box->col = col; - box->width = width; - box->flags = flags; -} - -/** * Draw text box widget * - * @v box Editable text box widget - * + * @v widget Text widget */ -void draw_editbox ( struct edit_box *box ) { - size_t width = box->width; +static void draw_editbox ( struct widget *widget ) { + struct edit_box *box = container_of ( widget, struct edit_box, widget ); + const char *content = *(box->string.buf); + size_t width = widget->width; char buf[ width + 1 ]; signed int cursor_offset, underflow, overflow, first; size_t len; @@ -90,18 +68,37 @@ void draw_editbox ( struct edit_box *box ) { /* Construct underscore-padded string portion */ memset ( buf, '_', width ); buf[width] = '\0'; - len = ( strlen ( box->string.buf ) - first ); + len = ( content ? ( strlen ( content ) - first ) : 0 ); if ( len > width ) len = width; - if ( box->flags & EDITBOX_STARS ) { + if ( widget->flags & WIDGET_SECRET ) { memset ( buf, '*', len ); } else { - memcpy ( buf, ( box->string.buf + first ), len ); + memcpy ( buf, ( content + first ), len ); } /* Print box content and move cursor */ - if ( ! box->win ) - box->win = stdscr; - mvwprintw ( box->win, box->row, box->col, "%s", buf ); - wmove ( box->win, box->row, ( box->col + cursor_offset ) ); + color_set ( CPAIR_EDIT, NULL ); + mvprintw ( widget->row, widget->col, "%s", buf ); + move ( widget->row, ( widget->col + cursor_offset ) ); + color_set ( CPAIR_NORMAL, NULL ); } + +/** + * Edit text box widget + * + * @v widget Text widget + * @v key Key pressed by user + * @ret key Key returned to application, or zero + */ +static int edit_editbox ( struct widget *widget, int key ) { + struct edit_box *box = container_of ( widget, struct edit_box, widget ); + + return edit_string ( &box->string, key ); +} + +/** Text box widget operations */ +struct widget_operations editbox_operations = { + .draw = draw_editbox, + .edit = edit_editbox, +}; diff --git a/src/hci/mucurses/winattrs.c b/src/hci/mucurses/winattrs.c index 97a5a18b3..e78025543 100644 --- a/src/hci/mucurses/winattrs.c +++ b/src/hci/mucurses/winattrs.c @@ -7,6 +7,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Get the background rendition attributes for a window diff --git a/src/hci/mucurses/wininit.c b/src/hci/mucurses/wininit.c index dd84d2f1d..1b651123e 100644 --- a/src/hci/mucurses/wininit.c +++ b/src/hci/mucurses/wininit.c @@ -8,6 +8,7 @@ */ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +FILE_SECBOOT ( PERMITTED ); /** * Initialise console environment |
