@ -96,6 +96,37 @@ detach_from_event_loop (ply_boot_splash_plugin_t *plugin)
ply_trace ( " detaching from event loop " ) ;
}
void
on_keyboard_input ( ply_boot_splash_plugin_t * plugin ,
const char * keyboard_input ,
size_t character_size )
{
if ( plugin - > keyboard_input_is_hidden )
write ( STDOUT_FILENO , " • " , strlen ( " • " ) ) ;
else
write ( STDOUT_FILENO , keyboard_input , character_size ) ;
}
void
on_backspace ( ply_boot_splash_plugin_t * plugin )
{
write ( STDOUT_FILENO , BACKSPACE , strlen ( BACKSPACE ) ) ;
}
void
on_enter ( ply_boot_splash_plugin_t * plugin ,
const char * line )
{
if ( plugin - > password_answer_handler ! = NULL )
{
plugin - > password_answer_handler ( plugin - > password_answer_data ,
line ) ;
plugin - > keyboard_input_is_hidden = false ;
plugin - > password_answer_handler = NULL ;
write ( STDOUT_FILENO , CLEAR_LINE_SEQUENCE , strlen ( CLEAR_LINE_SEQUENCE ) ) ;
}
}
bool
show_splash_screen ( ply_boot_splash_plugin_t * plugin ,
ply_event_loop_t * loop ,
@ -106,6 +137,16 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
assert ( plugin ! = NULL ) ;
ply_window_set_keyboard_input_handler ( window ,
( ply_window_keyboard_input_handler_t )
on_keyboard_input , plugin ) ;
ply_window_set_backspace_handler ( window ,
( ply_window_backspace_handler_t )
on_backspace , plugin ) ;
ply_window_set_enter_handler ( window ,
( ply_window_enter_handler_t )
on_enter , plugin ) ;
plugin - > loop = loop ;
ply_event_loop_watch_for_exit ( loop , ( ply_event_loop_exit_handler_t )
@ -149,6 +190,10 @@ hide_splash_screen (ply_boot_splash_plugin_t *plugin,
ply_trace ( " hiding splash screen " ) ;
ply_window_set_keyboard_input_handler ( window , NULL , NULL ) ;
ply_window_set_backspace_handler ( window , NULL , NULL ) ;
ply_window_set_enter_handler ( window , NULL , NULL ) ;
ply_event_loop_stop_watching_for_exit ( plugin - > loop ,
( ply_event_loop_exit_handler_t )
detach_from_event_loop ,
@ -168,38 +213,6 @@ ask_for_password (ply_boot_splash_plugin_t *plugin,
plugin - > keyboard_input_is_hidden = true ;
}
void
on_keyboard_input ( ply_boot_splash_plugin_t * plugin ,
const char * keyboard_input ,
size_t character_size )
{
if ( plugin - > keyboard_input_is_hidden )
write ( STDOUT_FILENO , " • " , strlen ( " • " ) ) ;
else
write ( STDOUT_FILENO , keyboard_input , character_size ) ;
}
void
on_backspace ( ply_boot_splash_plugin_t * plugin )
{
write ( STDOUT_FILENO , BACKSPACE , strlen ( BACKSPACE ) ) ;
}
void
on_enter ( ply_boot_splash_plugin_t * plugin ,
const char * line )
{
if ( plugin - > password_answer_handler ! = NULL )
{
plugin - > password_answer_handler ( plugin - > password_answer_data ,
line ) ;
plugin - > keyboard_input_is_hidden = false ;
plugin - > password_answer_handler = NULL ;
write ( STDOUT_FILENO , CLEAR_LINE_SEQUENCE , strlen ( CLEAR_LINE_SEQUENCE ) ) ;
}
}
ply_boot_splash_plugin_interface_t *
ply_boot_splash_plugin_get_interface ( void )
{
@ -212,9 +225,6 @@ ply_boot_splash_plugin_get_interface (void)
. on_boot_output = on_boot_output ,
. hide_splash_screen = hide_splash_screen ,
. ask_for_password = ask_for_password ,
. on_keyboard_input = on_keyboard_input ,
. on_backspace = on_backspace ,
. on_enter = on_enter
} ;
return & plugin_interface ;