summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-09-06 08:00:38 +0300
committerAvi Levin <avi.levin@samsung.com>2015-09-07 09:21:46 +0300
commitda37fe2944b8e27438a40fd0be3bf6c9b83e139b (patch)
treea922ab051c13dc8d53182401d9ad77ce91ac01e0
parent6c702f6b34e41c422a367c82d5fe95405a2604e9 (diff)
Print list if more than one autocomplete option.
-rw-r--r--src/bin/cli.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/bin/cli.c b/src/bin/cli.c
index 5778b11..fb2cea0 100644
--- a/src/bin/cli.c
+++ b/src/bin/cli.c
@@ -371,7 +371,6 @@ _char_consume(Lexer *l, char c)
371 { 371 {
372 const char *word = _last_word(l, NULL); 372 const char *word = _last_word(l, NULL);
373 373
374 char *buffer;
375 Eina_List *comps = NULL; 374 Eina_List *comps = NULL;
376 375
377 if(word) 376 if(word)
@@ -385,21 +384,43 @@ _char_consume(Lexer *l, char c)
385 } 384 }
386 } 385 }
387 386
388 printf("\r%*c\r", l->buf_end, ' ');
389
390 if(comps) 387 if(comps)
391 { 388 {
392 buffer = eina_list_nth(comps, 0); 389 char *comp;
390 if(eina_list_count(comps) > 1)
391 {
392 Eina_List *list;
393 int count = 0;
394 printf("\n");
395 EINA_LIST_FOREACH(comps, list, comp)
396 {
397 count++;
398 printf("%s%s", word, comp);
399 int num = 40 - strlen(comp) - strlen(word);
400 while(num--) putchar(' ');
401 if(count == 3){ count = 0; putchar('\n');}
402 }
403 if(count != 0)
404 printf("\n");
405 }
406 else
407 {
408
409 printf("\r%*c\r", l->buf_end, ' ');
410 comp = eina_list_nth(comps, 0);
393 411
394 strcpy(l->buffer+l->buf_end, buffer); 412 strcpy(l->buffer+l->buf_end, comp);
395 413
396 l->buf_end += strlen(buffer); 414 l->buf_end += strlen(comp);
415 }
416
417 EINA_LIST_FREE(comps, comp) free(comp);
397 418
398 free(buffer);
399 eina_list_free(comps);
400 } 419 }
401 else 420 else
402 { 421 {
422
423 printf("\r%*c\r", l->buf_end, ' ');
403 l->buffer[l->buf_end] = '\0'; 424 l->buffer[l->buf_end] = '\0';
404 } 425 }
405 printf("%s", l->buffer); 426 printf("%s", l->buffer);