Changes in uspace/lib/clui/tinput.c [be61b8f:9be9c4d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/clui/tinput.c
rbe61b8f r9be9c4d 591 591 } 592 592 593 /* Print a list of completions */594 static void tinput_show_completions(tinput_t *ti, char **compl, size_t cnum)595 {596 unsigned int i;597 /* Determine the maximum length of the completion in chars */598 size_t max_length = 0;599 for (i = 0; i < cnum; i++)600 max_length = max(max_length, str_length(compl[i]));601 602 unsigned int cols = max(1, (ti->con_cols + 1) / (max_length + 1));603 unsigned int col_width = ti->con_cols / cols;604 unsigned int rows = cnum / cols + ((cnum % cols) != 0);605 606 unsigned int row, col;607 608 for (row = 0; row < rows; row++) {609 bool wlc = false;610 for (col = 0; col < cols; col++) {611 size_t compl_idx = col * rows + row;612 if (compl_idx >= cnum)613 break;614 if (col)615 printf(" ");616 printf("%s", compl[compl_idx]);617 size_t compl_len = str_length(compl[compl_idx]);618 if (col == cols -1) {619 wlc = (compl_len == max_length);620 }621 else {622 for (i = compl_len; i < col_width; i++) {623 printf(" ");624 }625 }626 }627 if (!wlc) printf("\n");628 }629 }630 631 632 593 static void tinput_text_complete(tinput_t *ti) 633 594 { … … 715 676 716 677 tinput_jump_after(ti); 717 tinput_show_completions(ti, compl, cnum); 678 for (i = 0; i < cnum; i++) 679 printf("%s\n", compl[i]); 718 680 tinput_display(ti); 719 681 }
Note:
See TracChangeset
for help on using the changeset viewer.