| | 328 | | static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) |
| | 329 | | { |
| | 330 | | WINDOW_REC *window; |
| | 331 | | TEXT_DEST_REC dest; |
| | 332 | | GString *str; |
| | 333 | | GSList *tmp; |
| | 334 | | char *format, *stripped, *prefix_format; |
| | 335 | | char *linebuf, nickmode[2] = { 0, 0 }; |
| | 336 | | int *columns, cols, rows, last_col_rows, col, row, max_width; |
| | 337 | | int , linebuf_size, formatnum; |
| | 338 | | |
| | 339 | | window = window_find_closest(channel->server, channel->visible_name, |
| | 340 | | MSGLEVEL_CLIENTCRAP); |
| | 341 | | max_width = window->width; |
| | 342 | | |
| | 343 | | |
| | 344 | | format = format_get_text(MODULE_NAME, NULL,
|
| | 345 | | channel->server, channel->visible_name, |
| | 346 | | TXT_NAMES_NICK, " ", ""); |
| | 347 | | stripped = strip_codes(format); |
| | 348 | | = strlen(stripped); |
| | 349 | | g_free(stripped); |
| | 350 | | g_free(format); |
| | 351 | | |
| | 352 | | if (settings_get_int("names_max_width") > 0 && |
| | 353 | | settings_get_int("names_max_width") < max_width) |
| | 354 | | max_width = settings_get_int("names_max_width"); |
| | 355 | | |
| | 356 | | |
| | 357 | | format_create_dest(&dest, channel->server, channel->visible_name, |
| | 358 | | MSGLEVEL_CLIENTCRAP, NULL);
|
| | 359 | | format = format_get_line_start(current_theme, &dest, time(NULL));
|
| | 360 | | if (format != NULL) {
|
| | 361 | | stripped = strip_codes(format); |
| | 362 | | max_width -= strlen(stripped); |
| | 363 | | g_free(stripped); |
| | 364 | | g_free(format); |
| | 365 | | } |
| | 366 | | |
| | 367 | | |
| | 368 | | prefix_format = format_get_text(MODULE_NAME, NULL,
|
| | 369 | | channel->server, channel->visible_name, |
| | 370 | | TXT_NAMES_PREFIX, |
| | 371 | | channel->visible_name); |
| | 372 | | if (prefix_format != NULL) {
|
| | 373 | | stripped = strip_codes(prefix_format); |
| | 374 | | max_width -= strlen(stripped); |
| | 375 | | g_free(stripped); |
| | 376 | | } |
| | 377 | | |
| | 378 | | if (max_width <= 0) { |
| | 379 | | |
| | 380 | | |
| | 381 | | max_width = 10; |
| | 382 | | } |
| | 383 | | |
| | 384 | | |
| | 385 | | cols = get_max_column_count(nicklist, get_nick_length, max_width, |
| | 386 | | settings_get_int("names_max_columns"), |
| | 387 | | , 3, &columns, &rows); |
| | 388 | | nicklist = columns_sort_list(nicklist, rows); |
| | 389 | | |
| | 390 | | |
| | 391 | | last_col_rows = rows-(cols*rows-g_slist_length(nicklist)); |
| | 392 | | if (last_col_rows == 0) |
| | 393 | | last_col_rows = rows; |
| | 394 | | |
| | 395 | | str = g_string_new(prefix_format); |
| | 396 | | linebuf_size = max_width+1; linebuf = g_malloc(linebuf_size); |
| | 397 | | |
| | 398 | | col = 0; row = 0; |
| | 399 | | for (tmp = nicklist; tmp != NULL; tmp = tmp->next) {
|
| | 400 | | NICK_REC *rec = tmp->data; |
| | 401 | | |
| | 402 | | if (rec->prefixes[0]) |
| | 403 | | nickmode[0] = rec->prefixes[0]; |
| | 404 | | else |
| | 405 | | nickmode[0] = ' '; |
| | 406 | | |
| | 407 | | if (linebuf_size < columns[col]-+1) { |
| | 408 | | linebuf_size = (columns[col]-+1)*2; |
| | 409 | | linebuf = g_realloc(linebuf, linebuf_size); |
| | 410 | | } |
| | 411 | | memset(linebuf, ' ', columns[col]-); |
| | 412 | | linebuf[columns[col]-] = '\0'; |
| | 413 | | memcpy(linebuf, rec->nick, strlen(rec->nick)); |
| | 414 | | |
| | 415 | | formatnum = rec->op ? TXT_NAMES_NICK_OP : |
| | 416 | | rec->halfop ? TXT_NAMES_NICK_HALFOP : |
| | 417 | | rec->voice ? TXT_NAMES_NICK_VOICE : |
| | 418 | | TXT_NAMES_NICK; |
| | 419 | | format = format_get_text(MODULE_NAME, NULL,
|
| | 420 | | channel->server, |
| | 421 | | channel->visible_name, |
| | 422 | | formatnum, nickmode, linebuf); |
| | 423 | | g_string_append(str, format); |
| | 424 | | g_free(format); |
| | 425 | | |
| | 426 | | if (++col == cols) { |
| | 427 | | printtext(channel->server, channel->visible_name, |
| | 428 | | MSGLEVEL_CLIENTCRAP, "%s", str->str); |
| | 429 | | g_string_truncate(str, 0); |
| true | 430 | | if (prefix_format != NULL)
|
| | 431 | | g_string_assign(str, prefix_format); |
| | 432 | | col = 0; row++; |
| | 433 | | |
| | 434 | | if (row == last_col_rows) |
| | 435 | | cols--; |
| | 436 | | } |
| | 437 | | } |
| | 438 | | |
| prefix_format <= 4095 | 439 | | if (str->len > strlen(prefix_format)) { |