diff options
author | Michael Brown <mcb30@ipxe.org> | 2024-06-14 11:47:55 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2024-06-18 14:46:31 -0700 |
commit | bb4a10696fb6541fdcfc2c057cf698de37fa5eba (patch) | |
tree | e568749785a510b8cbebfcbe714183dcfea1e2f3 /src/hci | |
parent | e965f179e1654103eca33feed7a9cc4c51d91be6 (diff) | |
download | ipxe-bb4a10696fb6541fdcfc2c057cf698de37fa5eba.zip ipxe-bb4a10696fb6541fdcfc2c057cf698de37fa5eba.tar.gz ipxe-bb4a10696fb6541fdcfc2c057cf698de37fa5eba.tar.bz2 |
[hci] Draw all widgets on the standard screen
The curses concept of a window has been supported but never actively
used in iPXE since the mucurses library was first implemented in 2006.
Simplify the code by removing the ability to place a widget set in a
specified window, and instead use the standard screen for all drawing
operations.
This simplification allows the widget set parameter to be omitted for
the draw_widget() and edit_widget() operations, since the only reason
for its inclusion was to provide access to the specified window.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci')
-rw-r--r-- | src/hci/mucurses/widgets/editbox.c | 11 | ||||
-rw-r--r-- | src/hci/mucurses/widgets/label.c | 9 | ||||
-rw-r--r-- | src/hci/tui/login_ui.c | 2 | ||||
-rw-r--r-- | src/hci/tui/settings_ui.c | 6 | ||||
-rw-r--r-- | src/hci/tui/widget_ui.c | 6 |
5 files changed, 14 insertions, 20 deletions
diff --git a/src/hci/mucurses/widgets/editbox.c b/src/hci/mucurses/widgets/editbox.c index 79e7cdd..c024688 100644 --- a/src/hci/mucurses/widgets/editbox.c +++ b/src/hci/mucurses/widgets/editbox.c @@ -39,10 +39,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** * Draw text box widget * - * @v widgets Text widget set * @v widget Text widget */ -static void draw_editbox ( struct widgets *widgets, struct widget *widget ) { +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; @@ -79,21 +78,19 @@ static void draw_editbox ( struct widgets *widgets, struct widget *widget ) { /* Print box content and move cursor */ color_set ( CPAIR_EDIT, NULL ); - mvwprintw ( widgets->win, widget->row, widget->col, "%s", buf ); - wmove ( widgets->win, widget->row, ( widget->col + cursor_offset ) ); + mvprintw ( widget->row, widget->col, "%s", buf ); + move ( widget->row, ( widget->col + cursor_offset ) ); color_set ( CPAIR_NORMAL, NULL ); } /** * Edit text box widget * - * @v widgets Text widget set * @v widget Text widget * @v key Key pressed by user * @ret key Key returned to application, or zero */ -static int edit_editbox ( struct widgets *widgets __unused, - struct widget *widget, int key ) { +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 ); diff --git a/src/hci/mucurses/widgets/label.c b/src/hci/mucurses/widgets/label.c index 29645a6..29057f0 100644 --- a/src/hci/mucurses/widgets/label.c +++ b/src/hci/mucurses/widgets/label.c @@ -36,10 +36,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** * Draw text label widget * - * @v widgets Text widget set * @v widget Text widget */ -static void draw_label ( struct widgets *widgets, struct widget *widget ) { +static void draw_label ( struct widget *widget ) { struct label *label = container_of ( widget, struct label, widget ); unsigned int width = widget->width; unsigned int col = widget->col; @@ -51,20 +50,18 @@ static void draw_label ( struct widgets *widgets, struct widget *widget ) { /* Print label content */ attron ( A_BOLD ); - mvwprintw ( widgets->win, widget->row, col, "%s", text ); + mvprintw ( widget->row, col, "%s", text ); attroff ( A_BOLD ); } /** * Edit text label widget * - * @v widgets Text widget set * @v widget Text widget * @v key Key pressed by user * @ret key Key returned to application, or zero */ -static int edit_label ( struct widgets *widgets __unused, - struct widget *widget __unused, int key ) { +static int edit_label ( struct widget *widget __unused, int key ) { /* Cannot be edited */ return key; diff --git a/src/hci/tui/login_ui.c b/src/hci/tui/login_ui.c index b76afb9..9c51488 100644 --- a/src/hci/tui/login_ui.c +++ b/src/hci/tui/login_ui.c @@ -67,7 +67,7 @@ int login_ui ( void ) { /* Construct user interface */ memset ( &widgets, 0, sizeof ( widgets ) ); - init_widgets ( &widgets.widgets, NULL ); + init_widgets ( &widgets.widgets ); init_label ( &widgets.username_label, USERNAME_LABEL_ROW, WIDGET_COL, WIDGET_WIDTH, "Username" ); init_label ( &widgets.password_label, PASSWORD_LABEL_ROW, WIDGET_COL, diff --git a/src/hci/tui/settings_ui.c b/src/hci/tui/settings_ui.c index 53bf24d..045d978 100644 --- a/src/hci/tui/settings_ui.c +++ b/src/hci/tui/settings_ui.c @@ -253,7 +253,7 @@ static void draw_setting_row ( struct settings_ui *ui ) { static int edit_setting ( struct settings_ui *ui, int key ) { assert ( ui->row.setting.name != NULL ); ui->row.editing = 1; - return edit_widget ( &ui->widgets, &ui->row.editbox.widget, key ); + return edit_widget ( &ui->row.editbox.widget, key ); } /** @@ -457,7 +457,7 @@ static int main_loop ( struct settings *settings ) { /* Print initial screen content */ color_set ( CPAIR_NORMAL, NULL ); memset ( &ui, 0, sizeof ( ui ) ); - init_widgets ( &ui.widgets, NULL ); + init_widgets ( &ui.widgets ); select_settings ( &ui, settings ); while ( 1 ) { @@ -481,7 +481,7 @@ static int main_loop ( struct settings *settings ) { assert ( ui.row.setting.name != NULL ); /* Redraw edit box */ - draw_widget ( &ui.widgets, &ui.row.editbox.widget ); + draw_widget ( &ui.row.editbox.widget ); /* Process keypress */ key = edit_setting ( &ui, getkey ( 0 ) ); diff --git a/src/hci/tui/widget_ui.c b/src/hci/tui/widget_ui.c index 5079eef..961545c 100644 --- a/src/hci/tui/widget_ui.c +++ b/src/hci/tui/widget_ui.c @@ -68,7 +68,7 @@ static int widget_ui_loop ( struct widgets *widgets ) { /* Draw all widgets */ list_for_each_entry ( widget, &widgets->list, list ) - draw_widget ( widgets, widget ); + draw_widget ( widget ); /* Count editable widgets */ count = 0; @@ -85,10 +85,10 @@ static int widget_ui_loop ( struct widgets *widgets ) { return -ENOENT; /* Redraw current widget */ - draw_widget ( widgets, widget ); + draw_widget ( widget ); /* Process keypress */ - key = edit_widget ( widgets, widget, getkey ( 0 ) ); + key = edit_widget ( widget, getkey ( 0 ) ); switch ( key ) { case KEY_UP: if ( current > 0 ) |