Use target window width rather than terminal width to wrap /list -wide output

This should make the output correct in more circumstances.  It's the same wrapping used by add_to_window, anyway.
This commit is contained in:
Kevin Easton
2018-05-10 17:33:35 +10:00
parent 14a501bd04
commit 5cc052ee6c
2 changed files with 10 additions and 4 deletions

View File

@@ -1,5 +1,8 @@
[Changes 1.2.2] [Changes 1.2.2]
* Use target window width rather than terminal width to wrap /list -wide
output. (caf)
* Change arcfour example module to use ARC4CHAT instead of SCHAT as the DCC * Change arcfour example module to use ARC4CHAT instead of SCHAT as the DCC
type (SCHAT is already used by some other clients for SSL CHAT). (caf) type (SCHAT is already used by some other clients for SSL CHAT). (caf)

View File

@@ -94,6 +94,7 @@ void funny_print_widelist(void)
char buffer1[BIG_BUFFER_SIZE]; char buffer1[BIG_BUFFER_SIZE];
char buffer2[BIG_BUFFER_SIZE]; char buffer2[BIG_BUFFER_SIZE];
char *ptr; char *ptr;
int cols;
if (!wide_list) if (!wide_list)
return; return;
@@ -106,13 +107,15 @@ void funny_print_widelist(void)
(int (*) (const void *, const void *)) funny_widelist_users); (int (*) (const void *, const void *)) funny_widelist_users);
set_display_target(NULL, LOG_CRAP); set_display_target(NULL, LOG_CRAP);
cols = window_columns(target_window);
*buffer1 = '\0'; *buffer1 = '\0';
for (i = 1; i < wl_elements; i++) for (i = 1; i < wl_elements; i++)
{ {
snprintf(buffer2, sizeof buffer2, "%s(%d) ", wide_list[i]->channel, snprintf(buffer2, sizeof buffer2, "%s(%d) ", wide_list[i]->channel,
wide_list[i]->users); wide_list[i]->users);
ptr = strchr(buffer1, '\0'); ptr = strchr(buffer1, '\0');
if (strlen(buffer1) + strlen(buffer2) > current_term->TI_cols - 5) if (strlen(buffer1) + strlen(buffer2) + 5 > cols)
{ {
if (do_hook(WIDELIST_LIST, "%s", buffer1)) if (do_hook(WIDELIST_LIST, "%s", buffer1))
put_it("%s", convert_output_format(fget_string_var(FORMAT_WIDELIST_FSET), "%s %s", update_clock(GET_TIME), buffer1)); put_it("%s", convert_output_format(fget_string_var(FORMAT_WIDELIST_FSET), "%s %s", update_clock(GET_TIME), buffer1));