summaryrefslogtreecommitdiff
path: root/ihe.c
diff options
context:
space:
mode:
Diffstat (limited to 'ihe.c')
-rw-r--r--ihe.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/ihe.c b/ihe.c
index 00f654e..f24dc77 100644
--- a/ihe.c
+++ b/ihe.c
@@ -34,20 +34,26 @@ int cmd_buf_print( cmd_in_buf_t *buf, int type )
{
int i;
//printf("sz:%d\n",buf->cur_sz);
- for (i=0;(i<buf->cur_sz)&&(i<CMD_IN_BUF_SIZE);i++)
+ for (i=0;(i<CMD_IN_BUF_SIZE);i++)
{
- if (type == 1)
+ if ( i < buf->cur_sz )
{
- if (isprint(buf->buf[i]))
+ if (type == 1)
{
- printf("%c",(char)(buf->buf[i]&0xff));
- } else
+ if (isprint(buf->buf[i]))
+ {
+ printf("%c",(char)(buf->buf[i]&0xff));
+ } else
+ {
+ printf(".");
+ }
+ } else if (type == 2)
{
- printf(".");
+ printf("%02x ", (unsigned char)(buf->buf[i]&0xff) );
}
- } else if (type == 2)
+ } else
{
- printf("%02x ", (unsigned char)(buf->buf[i]&0xff) );
+ printf(" ");
}
}
fflush(stdout);
@@ -122,7 +128,7 @@ int cmd_tab_autocomplete( char *in_buf )
cmd_tok_t tl, *ptr = &tl, *iter = NULL;
struct cmd_acq_t *iter_sugg = NULL;
memset( &tl, 0, sizeof( cmd_tok_t ));
- //int i;
+ int i;
//printf("[%s]\n", in_buf);
if ( parse_cmd( ptr, in_buf) == -1)
@@ -134,12 +140,12 @@ int cmd_tab_autocomplete( char *in_buf )
iter = ptr->next;
args = cmd_arg_create( iter );
- /*
+
for (i=0; i<args->argc; i++)
{
printf("ARG:%d TYPE:%d %s\n", i, args->type[i], args->argv[i]);
}
- */
+
//printf("Unkn command\n");
//if command not found offer auto complete options
@@ -472,12 +478,18 @@ int main( int argc, char **argv )
//auto complete advice
if (CMK_KEYMAP1(9))
{
+ if ( cmd_in.cur_sz == 0 )
+ {
+ continue;
+ }
//cmd_buf_print( &cmd_in, 2 );
cmd_in.buf[cmd_in.cur_sz] = '\n';
cmd_in.buf[cmd_in.cur_sz+1] = 0;
cmd_tab_autocomplete( cmd_in.buf );
+ //cmd_buf_print( &cmd_in, 2 );
write(1,"$",1);
cmd_buf_print( &cmd_in, 1 );
+ term_cur_set_c( &ts, cmd_in.cur_sz+2 );
continue;
}
@@ -494,6 +506,7 @@ int main( int argc, char **argv )
term_cur_set_c( &ts, 0);
write(1,"$",1);
cmd_buf_print( &cmd_in, 1 );
+ term_cur_set_c( &ts, cmd_in.cur_sz+2 );
continue;
}