Changeset 925a21e in mainline for uspace/lib/clui/tinput.c
- Timestamp:
- 2011-09-24T14:20:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5bf76c1
- Parents:
- 867e2555 (diff), 1ab4aca (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/clui/tinput.c
r867e2555 r925a21e 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 593 632 static void tinput_text_complete(tinput_t *ti) 594 633 { … … 676 715 677 716 tinput_jump_after(ti); 678 for (i = 0; i < cnum; i++) 679 printf("%s\n", compl[i]); 717 tinput_show_completions(ti, compl, cnum); 680 718 tinput_display(ti); 681 719 }
Note:
See TracChangeset
for help on using the changeset viewer.