hi
........this patch will provide auto-completion on command-line. please
give me suggestion on this patch.
Thanks
Vikas
Garg (vikaspec)
Your Mail works best with the New Yahoo Optimized IE8. Get it NOW!
http://downloads.yahoo.com/in/internetexplorer/diff -crB gpxe-1.0.0/src/hci/readline.c gpxe-1.0.0.new/src/hci/readline.c
*** gpxe-1.0.0/src/hci/readline.c 2010-02-02 21:42:44.000000000 +0530
--- gpxe-1.0.0.new/src/hci/readline.c 2010-04-06 19:55:23.000000000 +0530
***************
*** 25,30 ****
--- 25,31 ----
#include <gpxe/keys.h>
#include <gpxe/editstring.h>
#include <readline/readline.h>
+ #include <gpxe/command.h>
/** @file
*
***************
*** 86,93 ****
char * readline ( const char *prompt ) {
char buf[READLINE_MAX];
struct edit_string string;
! int key;
char *line;
if ( prompt )
printf ( "%s", prompt );
--- 87,98 ----
char * readline ( const char *prompt ) {
char buf[READLINE_MAX];
struct edit_string string;
! int key,tempkey;
char *line;
+ int counter=0;
+ char *cmd=NULL;
+ struct command *command;
+ unsigned int hpos = 0,ref=0;
if ( prompt )
printf ( "%s", prompt );
***************
*** 98,104 ****
buf[0] = '\0';
while ( 1 ) {
! key = edit_string ( &string, getkey() );
sync_console ( &string );
switch ( key ) {
case CR:
--- 103,153 ----
buf[0] = '\0';
while ( 1 ) {
! tempkey=getkey();
! if(tempkey==TAB)
! {
!
! counter=0;
! for_each_table_entry ( command, COMMANDS )
! if(!strncmp(string.buf,command->name,strlen(string.buf))){
! counter+=1;
! if(cmd!=NULL)
! free(cmd);
! cmd=(char*)malloc(sizeof(command->name)+1);
! strcpy(cmd,command->name);}
!
! if(counter==1 && cmd!=NULL)
! {
! for(ref=strlen(string.buf);ref<strlen(cmd);ref++)
! {
! edit_string ( &string,cmd[ref]);
! sync_console ( &string );
! }
! }
! else{
! printf("\n");
! for_each_table_entry ( command, COMMANDS ) {
! if(!strncmp(string.buf,command->name,strlen(string.buf)))
! hpos += printf ( " %s", command->name );
!
! if ( hpos > ( 16 * 4 ) ) {
! printf ( "\n" );
! hpos = 0;}
! else {
! while ( hpos % 16 ) {
! printf ( " " );
! hpos++;
! }
! }
! }
! printf("\n");
! printf ( "%s%s", prompt,string.buf);
!
! }
! continue;
! }
!
! key = edit_string ( &string, tempkey);
sync_console ( &string );
switch ( key ) {
case CR:
_______________________________________________
gPXE-devel mailing list
[email protected]
http://etherboot.org/mailman/listinfo/gpxe-devel