summaryrefslogtreecommitdiffstats
path: root/src/hci/tui
diff options
context:
space:
mode:
Diffstat (limited to 'src/hci/tui')
-rw-r--r--src/hci/tui/login_ui.c22
-rw-r--r--src/hci/tui/menu_ui.c13
2 files changed, 28 insertions, 7 deletions
diff --git a/src/hci/tui/login_ui.c b/src/hci/tui/login_ui.c
index 3c55325d..56fc2fa9 100644
--- a/src/hci/tui/login_ui.c
+++ b/src/hci/tui/login_ui.c
@@ -48,12 +48,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define EDITBOX_COL ( ( COLS / 2U ) - 10U )
#define EDITBOX_WIDTH 20U
-int login_ui ( void ) {
+int login_ui ( int nouser ) {
char username[64];
char password[64];
struct edit_box username_box;
struct edit_box password_box;
- struct edit_box *current_box = &username_box;
+ struct edit_box *current_box = nouser ? &password_box : &username_box;
int key;
int rc = -EINPROGRESS;
@@ -76,11 +76,15 @@ int login_ui ( void ) {
color_set ( CPAIR_NORMAL, NULL );
erase();
attron ( A_BOLD );
- mvprintw ( USERNAME_LABEL_ROW, LABEL_COL, "Username:" );
+ if ( ! nouser ) {
+ mvprintw ( USERNAME_LABEL_ROW, LABEL_COL, "Username:" );
+ }
mvprintw ( PASSWORD_LABEL_ROW, LABEL_COL, "Password:" );
attroff ( A_BOLD );
color_set ( CPAIR_EDIT, NULL );
- draw_editbox ( &username_box );
+ if ( ! nouser ) {
+ draw_editbox ( &username_box );
+ }
draw_editbox ( &password_box );
/* Main loop */
@@ -94,11 +98,15 @@ int login_ui ( void ) {
current_box = &password_box;
break;
case KEY_UP:
- current_box = &username_box;
+ if ( ! nouser ) {
+ current_box = &username_box;
+ }
break;
case TAB:
- current_box = ( ( current_box == &username_box ) ?
- &password_box : &username_box );
+ if ( ! nouser ) {
+ current_box = ( ( current_box == &username_box ) ?
+ &password_box : &username_box );
+ }
break;
case KEY_ENTER:
if ( current_box == &username_box ) {
diff --git a/src/hci/tui/menu_ui.c b/src/hci/tui/menu_ui.c
index f9dd9d10..cb4edbbc 100644
--- a/src/hci/tui/menu_ui.c
+++ b/src/hci/tui/menu_ui.c
@@ -217,6 +217,8 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
break;
default:
i = 0;
+
+ /* Check for shortcut. Visible items */
list_for_each_entry ( item, &ui->menu->items,
list ) {
if ( ! ( item->shortcut &&
@@ -231,6 +233,16 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
move = +1;
}
}
+
+ /* Hidden items */
+ list_for_each_entry ( item, &ui->menu->hidden_items,
+ list ) {
+ if ( item->shortcut &&
+ ( item->shortcut == key ) ) {
+ *selected = item;
+ goto hidden_entry_selected;
+ }
+ }
break;
}
}
@@ -259,6 +271,7 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
} while ( ( rc == 0 ) && ! chosen );
+ hidden_entry_selected:
return rc;
}