]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[hci] Remove the generalised widget user interface abstraction
authorMichael Brown <mcb30@ipxe.org>
Thu, 20 Jun 2024 22:48:59 +0000 (15:48 -0700)
committerMichael Brown <mcb30@ipxe.org>
Fri, 21 Jun 2024 16:57:03 +0000 (09:57 -0700)
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>
src/hci/mucurses/widgets/label.c [deleted file]
src/hci/tui/settings_ui.c
src/hci/tui/widget_ui.c [deleted file]
src/include/ipxe/widget.h

diff --git a/src/hci/mucurses/widgets/label.c b/src/hci/mucurses/widgets/label.c
deleted file mode 100644 (file)
index 29057f0..0000000
+++ /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,
-};
index bc08750a05ec452be6a7914d5bfbff20611939b0..57ff9e9a085c421c20695ceb1a25de994b4b7caa 100644 (file)
@@ -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 (file)
index 961545c..0000000
+++ /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;
-}
index 0d8af1030d99bdb391e7b7e36c6f3641451aecca..945b4672aefd0c3e04ba0a4767b0180347a2ba56 100644 (file)
 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;
 
@@ -65,17 +56,6 @@ struct widget_operations {
        int ( * edit ) ( struct widget *widget, int key );
 };
 
-/**
- * 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
  *
@@ -97,18 +77,6 @@ init_widget ( struct widget *widget, struct widget_operations *op,
        widget->flags = flags;
 }
 
-/**
- * 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
  *
@@ -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 */