aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2024-06-20 15:48:59 -0700
committerMichael Brown <mcb30@ipxe.org>2024-06-21 09:57:03 -0700
commit821bb326f87fbc000376fdc5371e9e53f666267a (patch)
tree90567dcdf2f2db8008779d570f189a2a731263b3
parent162cc51b6db2caa888e2fb834511d7e4af7e0bfe (diff)
downloadipxe-master.zip
ipxe-master.tar.gz
ipxe-master.tar.bz2
[hci] Remove the generalised widget user interface abstractionHEADmaster
Remove the now-unused generalised text widget user interface, along with the associated concept of a widget set and the implementation of a read-only label widget. Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/hci/mucurses/widgets/label.c74
-rw-r--r--src/hci/tui/settings_ui.c3
-rw-r--r--src/hci/tui/widget_ui.c143
-rw-r--r--src/include/ipxe/widget.h34
4 files changed, 0 insertions, 254 deletions
diff --git a/src/hci/mucurses/widgets/label.c b/src/hci/mucurses/widgets/label.c
deleted file mode 100644
index 29057f0..0000000
--- a/src/hci/mucurses/widgets/label.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * You can also choose to distribute this program under the terms of
- * the Unmodified Binary Distribution Licence (as given in the file
- * COPYING.UBDL), provided that you have satisfied its requirements.
- */
-
-FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
-
-#include <string.h>
-#include <assert.h>
-#include <ipxe/label.h>
-
-/** @file
- *
- * Text label widget
- *
- */
-
-/**
- * Draw text label widget
- *
- * @v widget Text 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;
- const char *text = label->text;
-
- /* Centre label if width is non-zero */
- if ( width )
- col += ( ( width - strlen ( text ) ) / 2 );
-
- /* Print label content */
- attron ( A_BOLD );
- mvprintw ( widget->row, col, "%s", text );
- attroff ( A_BOLD );
-}
-
-/**
- * Edit text label widget
- *
- * @v widget Text widget
- * @v key Key pressed by user
- * @ret key Key returned to application, or zero
- */
-static int edit_label ( struct widget *widget __unused, int key ) {
-
- /* Cannot be edited */
- return key;
-}
-
-/** Text label widget operations */
-struct widget_operations label_operations = {
- .draw = draw_label,
- .edit = edit_label,
-};
diff --git a/src/hci/tui/settings_ui.c b/src/hci/tui/settings_ui.c
index bc08750..57ff9e9 100644
--- a/src/hci/tui/settings_ui.c
+++ b/src/hci/tui/settings_ui.c
@@ -109,8 +109,6 @@ struct settings_ui {
struct jump_scroller scroll;
/** Current row */
struct settings_ui_row row;
- /** Widget set used for editing setting */
- struct widgets widgets;
};
/**
@@ -389,7 +387,6 @@ 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 );
select_settings ( &ui, settings );
while ( 1 ) {
diff --git a/src/hci/tui/widget_ui.c b/src/hci/tui/widget_ui.c
deleted file mode 100644
index 961545c..0000000
--- a/src/hci/tui/widget_ui.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- * You can also choose to distribute this program under the terms of
- * the Unmodified Binary Distribution Licence (as given in the file
- * COPYING.UBDL), provided that you have satisfied its requirements.
- */
-
-FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
-
-/** @file
- *
- * Text widget UI
- *
- */
-
-#include <errno.h>
-#include <curses.h>
-#include <ipxe/ansicol.h>
-#include <ipxe/widget.h>
-
-/**
- * Find editable widget in widget set
- *
- * @v widgets Text widget set
- * @v index Editable widget index
- * @ret widget Editable widget, or NULL
- */
-static struct widget * find_widget ( struct widgets *widgets,
- unsigned int index ) {
- struct widget *widget;
-
- list_for_each_entry ( widget, &widgets->list, list ) {
- if ( ! ( widget->flags & WIDGET_EDITABLE ) )
- continue;
- if ( index-- == 0 )
- return widget;
- }
- return NULL;
-}
-
-/**
- * Text widget user interface main loop
- *
- * @v widgets Text widget set
- * @ret rc Return status code
- */
-static int widget_ui_loop ( struct widgets *widgets ) {
- struct widget *widget;
- unsigned int current;
- unsigned int count;
- int key;
-
- /* Draw all widgets */
- list_for_each_entry ( widget, &widgets->list, list )
- draw_widget ( widget );
-
- /* Count editable widgets */
- count = 0;
- while ( find_widget ( widgets, count ) != NULL )
- count++;
-
- /* Main loop */
- current = 0;
- while ( 1 ) {
-
- /* Identify current widget */
- widget = find_widget ( widgets, current );
- if ( ! widget )
- return -ENOENT;
-
- /* Redraw current widget */
- draw_widget ( widget );
-
- /* Process keypress */
- key = edit_widget ( widget, getkey ( 0 ) );
- switch ( key ) {
- case KEY_UP:
- if ( current > 0 )
- current--;
- break;
- case KEY_DOWN:
- if ( ++current == count )
- current--;
- break;
- case TAB:
- if ( ++current == count )
- current = 0;
- break;
- case KEY_ENTER:
- current++;
- if ( current >= count )
- return 0;
- break;
- case CTRL_C:
- case ESC:
- return -ECANCELED;
- default:
- /* Do nothing for unrecognised keys or edit errors */
- break;
- }
- }
-}
-
-/**
- * Present text widget user interface
- *
- * @v widgets Text widget set
- * @ret rc Return status code
- */
-int widget_ui ( struct widgets *widgets ) {
- int rc;
-
- /* Initialise UI */
- initscr();
- start_color();
- color_set ( CPAIR_NORMAL, NULL );
- erase();
-
- /* Run main loop */
- rc = widget_ui_loop ( widgets );
-
- /* Terminate UI */
- color_set ( CPAIR_NORMAL, NULL );
- endwin();
-
- return rc;
-}
diff --git a/src/include/ipxe/widget.h b/src/include/ipxe/widget.h
index 0d8af10..945b467 100644
--- a/src/include/ipxe/widget.h
+++ b/src/include/ipxe/widget.h
@@ -10,18 +10,9 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <curses.h>
-#include <ipxe/list.h>
-
-/** A text widget set */
-struct widgets {
- /** List of widgets (in tab order) */
- struct list_head list;
-};
/** A text widget */
struct widget {
- /** List of widgets (in tab order) */
- struct list_head list;
/** Widget operations */
struct widget_operations *op;
@@ -66,17 +57,6 @@ struct widget_operations {
};
/**
- * Initialise text widget set
- *
- * @v widgets Text widget set
- */
-static inline __attribute__ (( always_inline )) void
-init_widgets ( struct widgets *widgets ) {
-
- INIT_LIST_HEAD ( &widgets->list );
-}
-
-/**
* Initialise text widget
*
* @v widget Text widget
@@ -98,18 +78,6 @@ init_widget ( struct widget *widget, struct widget_operations *op,
}
/**
- * Append text widget
- *
- * @v widgets Text widget set
- * @v widget Text widget
- */
-static inline __attribute__ (( always_inline )) void
-add_widget ( struct widgets *widgets, struct widget *widget ) {
-
- list_add_tail ( &widget->list, &widgets->list );
-}
-
-/**
* Draw text widget
*
* @v widget Text widget
@@ -137,6 +105,4 @@ edit_widget ( struct widget *widget, int key ) {
return widget->op->edit ( widget, key );
}
-extern int widget_ui ( struct widgets *widgets );
-
#endif /* _IPXE_WIDGET_H */