mirror of
https://github.com/ipxe/ipxe
synced 2025-12-21 12:30:20 +03:00
[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>
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 ) );
|
||||
|
||||
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user