david/ipxe
Archived
1
0

[settings] Add support for navigation keys in "config" user interface

Add support for page up, page down, home and end keys, matching the
navigation logic used in the menu user interface.

Originally-implemented-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2013-07-15 11:59:13 +02:00
parent 4fabc0012a
commit 75bd5b54a8

View File

@ -508,13 +508,25 @@ static int main_loop ( struct settings *settings ) {
key = getkey ( 0 ); key = getkey ( 0 );
move = 0; move = 0;
switch ( key ) { switch ( key ) {
case KEY_DOWN:
if ( widget.current < ( widget.num_rows - 1 ) )
move = +1;
break;
case KEY_UP: case KEY_UP:
if ( widget.current > 0 ) move = -1;
move = -1; break;
case KEY_DOWN:
move = +1;
break;
case KEY_PPAGE:
move = ( widget.first_visible -
widget.current - 1 );
break;
case KEY_NPAGE:
move = ( widget.first_visible - widget.current
+ SETTINGS_LIST_ROWS );
break;
case KEY_HOME:
move = -widget.num_rows;
break;
case KEY_END:
move = +widget.num_rows;
break; break;
case CTRL_D: case CTRL_D:
if ( ! widget.row.setting ) if ( ! widget.row.setting )
@ -545,10 +557,16 @@ static int main_loop ( struct settings *settings ) {
} }
if ( move ) { if ( move ) {
next = ( widget.current + move ); next = ( widget.current + move );
draw_setting_row ( &widget ); if ( ( int ) next < 0 )
redraw = 1; next = 0;
reveal_setting_row ( &widget, next ); if ( next >= widget.num_rows )
select_setting_row ( &widget, next ); next = ( widget.num_rows - 1 );
if ( next != widget.current ) {
draw_setting_row ( &widget );
redraw = 1;
reveal_setting_row ( &widget, next );
select_setting_row ( &widget, next );
}
} }
} }
} }