pull/596/merge
Daniel Paziyski 2025-03-20 22:53:15 +13:00 committed by GitHub
commit 8f5673a274
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 33 additions and 0 deletions

View File

@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <ipxe/command.h>
#include <ipxe/console.h>
#include <ipxe/keys.h>
#include <ipxe/editstring.h>
@ -308,6 +309,38 @@ int readline_history ( const char *prompt, const char *prefill,
case KEY_DOWN:
move_by = -1;
break;
case TAB: {
int new_line_printed, matches_found;
struct command *cmd;
new_line_printed = matches_found = 0;
for_each_table_entry ( cmd, COMMANDS ) {
if ( strncmp ( buf, cmd->name, strlen ( buf ) ) == 0 ) {
if ( !new_line_printed) {
printf("\n");
new_line_printed = 1;
matches_found = 1;
}
printf ( "%s ", cmd->name );
}
}
if ( matches_found ) {
printf ( "\n" );
/* Printing the prompt and creating a new editstring to print
the already typed command */
if ( prompt )
printf ( "%s", prompt );
memset ( &string, 0, sizeof ( string ) );
init_editstring ( &string, buf, READLINE_MAX );
replace_string ( &string, buf );
sync_console ( &string );
}
continue;
}
default:
/* Do nothing for unrecognised keys or edit errors */
break;