Changes in uspace/lib/clui/tinput.c [6d5e378:597b12e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/clui/tinput.c
r6d5e378 r597b12e 595 595 { 596 596 unsigned int i; 597 /* Determine the maximum width of the completion in chars */598 size_t max_ width = 0;597 /* Determine the maximum length of the completion in chars */ 598 size_t max_length = 0; 599 599 for (i = 0; i < cnum; i++) 600 max_ width = max(max_width, str_width(compl[i]));601 602 unsigned int cols = max(1, (ti->con_cols + 1) / (max_ width + 1));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 603 unsigned int padding = 0; 604 if ((cols * max_ width) + (cols - 1) < ti->con_cols) {605 padding = ti->con_cols - (cols * max_ width) - (cols - 1);606 } 607 unsigned int col_width = max_ width + padding / cols;604 if ((cols * max_length) + (cols - 1) < ti->con_cols) { 605 padding = ti->con_cols - (cols * max_length) - (cols - 1); 606 } 607 unsigned int col_width = max_length + padding / cols; 608 608 unsigned int rows = cnum / cols + ((cnum % cols) != 0); 609 609 … … 611 611 612 612 for (row = 0; row < rows; row++) { 613 unsigned int display_col = 0;613 bool wlc = false; 614 614 for (col = 0; col < cols; col++) { 615 615 size_t compl_idx = col * rows + row; 616 616 if (compl_idx >= cnum) 617 617 break; 618 if (col) {618 if (col) 619 619 printf(" "); 620 display_col++; 620 printf("%s", compl[compl_idx]); 621 size_t compl_len = str_length(compl[compl_idx]); 622 if (col == cols -1) { 623 wlc = (compl_len == max_length); 621 624 } 622 printf("%s", compl[compl_idx]); 623 size_t compl_width = str_width(compl[compl_idx]); 624 display_col += compl_width; 625 if (col < cols - 1) { 626 for (i = compl_width; i < col_width; i++) { 625 else { 626 for (i = compl_len; i < col_width; i++) { 627 627 printf(" "); 628 display_col++;629 628 } 630 629 } 631 630 } 632 if ((display_col % ti->con_cols) > 0) 633 printf("\n"); 634 } 635 fflush(stdout); 631 if (!wlc) printf("\n"); 632 } 636 633 } 637 634
Note:
See TracChangeset
for help on using the changeset viewer.