| | 53 | | static void help_category(GSList *cmdlist, int items) | | | 54 | | { | | | 55 | | WINDOW_REC *window; | | | 56 | | TEXT_DEST_REC dest; | | | 57 | | GString *str; | | | 58 | | GSList *tmp; | | | 59 | | int *columns, cols, rows, col, row, last_col_rows, max_width; | | | 60 | | char *linebuf, *format, *stripped; | | | 61 | | | | | 62 | | window = window_find_closest(NULL, NULL, MSGLEVEL_CLIENTCRAP);
| | | 63 | | max_width = window->width; | | | 64 | | | | | 65 | | | | | 66 | | format_create_dest(&dest, NULL, NULL, MSGLEVEL_CLIENTCRAP, NULL);
| | | 67 | | format = format_get_line_start(current_theme, &dest, time(NULL));
| | | 68 | | if (format != NULL) {
| | | 69 | | stripped = strip_codes(format); | | | 70 | | max_width -= strlen(stripped); | | | 71 | | g_free(stripped); | | true | 72 | | g_free(format); | | | 73 | | } | | | 74 | | | | | 75 | | | | columns <= 4095 | 76 | | cols = get_max_column_count(cmdlist, get_cmd_length, |
| | 623 | | | | int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func, | | | 624 | | | | int max_width, int max_columns, | | | 625 | | | | int , int item_min_size, | | | 626 | | | | int **save_column_widths, int *rows) | | | 627 | | | | { | | | 628 | | | | GSList *tmp; | | | 629 | | | | int **columns, *columns_width, *columns_rows; | | | 630 | | | | int item_pos, items_count; | | | 631 | | | | int ret, len, max_len, n, col; | | | 632 | | | | | | | 633 | | | | items_count = g_slist_length(items); | | | 634 | | | | if (items_count == 0) { | | | 635 | | | | *save_column_widths = NULL;
| | | 636 | | | | *rows = 0; | | | 637 | | | | return 0; | | | 638 | | | | } | | | 639 | | | | | | | 640 | | | | len = max_width/(+item_min_size); | | | 641 | | | | if (len <= 0) len = 1; | | | 642 | | | | if (max_columns <= 0 || len < max_columns) | | | 643 | | | | max_columns = len; | | | 644 | | | | | | | 645 | | | | columns = g_new0(int *, max_columns);
| | | 646 | | | | columns_width = g_new0(int, max_columns);
| | | 647 | | | | columns_rows = g_new0(int, max_columns);
| | | | | | | ... | | | 690 | | | | *rows = columns_rows[ret-1]; | | | 691 | | | | } | | | 692 | | | | | | | 693 | | | | for (n = 1; n < max_columns; n++) | | | 694 | | | | g_free(columns[n]); | | | 695 | | | | g_free(columns_width); | | | 696 | | | | g_free(columns_rows); | | | 697 | | | | g_free(columns); | | | 698 | | | | | | | 699 | | | | return ret; | | columns <= 4095 | 700 | | | | } |
|