mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 22:06:38 +02:00
Xfer list: help about keys, fix of minor display bugs
This commit is contained in:
@@ -41,7 +41,7 @@ int xfer_buffer_selected_line = 0;
|
||||
void
|
||||
xfer_buffer_refresh (char *hotlist)
|
||||
{
|
||||
struct t_xfer *ptr_xfer;
|
||||
struct t_xfer *ptr_xfer, *xfer_selected;
|
||||
char str_color[256], status[64], date[128], *progress_bar, format[128];
|
||||
char format_per_sec[128], bytes_per_sec[256], eta[128];
|
||||
int i, length, line, progress_bar_size, num_bars, num_unit;
|
||||
@@ -56,6 +56,28 @@ xfer_buffer_refresh (char *hotlist)
|
||||
{
|
||||
weechat_buffer_clear (xfer_buffer);
|
||||
line = 0;
|
||||
xfer_selected = xfer_search_by_number (xfer_buffer_selected_line);
|
||||
if (xfer_selected)
|
||||
{
|
||||
weechat_printf_y (xfer_buffer, 0,
|
||||
"%sActions (letter+enter):%s%s%s%s%s%s",
|
||||
weechat_color("green"),
|
||||
weechat_color("lightgreen"),
|
||||
/* accept */
|
||||
(XFER_IS_RECV(xfer_selected->type)
|
||||
&& (xfer_selected->status == XFER_STATUS_WAITING)) ?
|
||||
_(" [A] Accept") : "",
|
||||
/* cancel */
|
||||
(!XFER_HAS_ENDED(xfer_selected->status)) ?
|
||||
_(" [C] Cancel") : "",
|
||||
/* remove */
|
||||
(XFER_HAS_ENDED(xfer_selected->status)) ?
|
||||
_(" [R] Remove") : "",
|
||||
/* purge old */
|
||||
_(" [P] Purge finished"),
|
||||
/* quit */
|
||||
_(" [Q] Close xfer list"));
|
||||
}
|
||||
for (ptr_xfer = xfer_list; ptr_xfer; ptr_xfer = ptr_xfer->next_xfer)
|
||||
{
|
||||
snprintf (str_color, sizeof (str_color),
|
||||
@@ -66,8 +88,8 @@ xfer_buffer_refresh (char *hotlist)
|
||||
weechat_config_string (xfer_config_color_text_bg));
|
||||
|
||||
/* display first line with remote nick and filename */
|
||||
weechat_printf_y (xfer_buffer, line * 2,
|
||||
"%s%s%-25s %s%s%s",
|
||||
weechat_printf_y (xfer_buffer, (line * 2) + 2,
|
||||
"%s%s%-24s %s%s%s",
|
||||
weechat_color(str_color),
|
||||
(line == xfer_buffer_selected_line) ?
|
||||
"*** " : " ",
|
||||
@@ -79,7 +101,7 @@ xfer_buffer_refresh (char *hotlist)
|
||||
|
||||
snprintf (status, sizeof (status),
|
||||
"%s", _(xfer_status_string[ptr_xfer->status]));
|
||||
length = strlen (status);
|
||||
length = weechat_utf8_strlen_screen (status);
|
||||
if (length < 20)
|
||||
{
|
||||
for (i = 0; i < 20 - length; i++)
|
||||
@@ -94,8 +116,8 @@ xfer_buffer_refresh (char *hotlist)
|
||||
date_tmp = localtime (&(ptr_xfer->start_time));
|
||||
strftime (date, sizeof (date),
|
||||
"%a, %d %b %Y %H:%M:%S", date_tmp);
|
||||
weechat_printf_y (xfer_buffer, (line * 2) + 1,
|
||||
"%s%s%s %s%s %s%s%s",
|
||||
weechat_printf_y (xfer_buffer, (line * 2) + 3,
|
||||
"%s%s%s %s%s%s%s%s",
|
||||
weechat_color(str_color),
|
||||
(line == xfer_buffer_selected_line) ?
|
||||
"*** " : " ",
|
||||
@@ -114,7 +136,7 @@ xfer_buffer_refresh (char *hotlist)
|
||||
progress_bar_size = weechat_config_integer (xfer_config_look_progress_bar_size);
|
||||
if (progress_bar_size > 0)
|
||||
{
|
||||
progress_bar = malloc (1 + progress_bar_size + 1 + 1);
|
||||
progress_bar = malloc (1 + progress_bar_size + 1 + 1 + 1);
|
||||
strcpy (progress_bar, "[");
|
||||
if (ptr_xfer->size == 0)
|
||||
{
|
||||
@@ -135,7 +157,7 @@ xfer_buffer_refresh (char *hotlist)
|
||||
{
|
||||
strcat (progress_bar, " ");
|
||||
}
|
||||
strcat (progress_bar, "]");
|
||||
strcat (progress_bar, "] ");
|
||||
}
|
||||
|
||||
/* computes pourcentage */
|
||||
@@ -158,7 +180,7 @@ xfer_buffer_refresh (char *hotlist)
|
||||
pct_complete = (unsigned long)(((float)(ptr_xfer->pos)/(float)(ptr_xfer->size)) * 100);
|
||||
|
||||
snprintf (format, sizeof (format),
|
||||
"%%s%%s%%s %%s%%s%%s%%s %%3lu%%%% %s %%s / %s %%s (%%s%%s)",
|
||||
"%%s%%s%%s %%s%%s%%s%%s%%3lu%%%% %s %%s / %s %%s (%%s%%s)",
|
||||
unit_format[num_unit],
|
||||
unit_format[num_unit]);
|
||||
|
||||
@@ -193,7 +215,7 @@ xfer_buffer_refresh (char *hotlist)
|
||||
}
|
||||
|
||||
/* display second line for file with status, progress bar and estimated time */
|
||||
weechat_printf_y (xfer_buffer, (line * 2) + 1,
|
||||
weechat_printf_y (xfer_buffer, (line * 2) + 3,
|
||||
format,
|
||||
weechat_color(str_color),
|
||||
(line == xfer_buffer_selected_line) ?
|
||||
@@ -265,6 +287,11 @@ xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
}
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
/* quit xfer buffer (close it) */
|
||||
else if (weechat_strcasecmp (input_data, "q") == 0)
|
||||
{
|
||||
weechat_buffer_close (buffer, 1);
|
||||
}
|
||||
/* remove xfer */
|
||||
else if (weechat_strcasecmp (input_data, "r") == 0)
|
||||
{
|
||||
@@ -274,10 +301,6 @@ xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
}
|
||||
else if (weechat_strcasecmp (input_data, "q") == 0)
|
||||
{
|
||||
weechat_buffer_close (buffer, 1);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "../weechat-plugin.h"
|
||||
#include "xfer.h"
|
||||
#include "xfer-config.h"
|
||||
#include "xfer-buffer.h"
|
||||
|
||||
|
||||
struct t_config_file *xfer_config_file = NULL;
|
||||
@@ -61,6 +62,22 @@ struct t_config_option *xfer_config_file_auto_accept_chats;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* xfer_config_refresh_cb: callback called when user changes xfer option that
|
||||
* needs a refresh of xfer list
|
||||
*/
|
||||
|
||||
void
|
||||
xfer_config_refresh_cb (void *data, struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
if (xfer_buffer)
|
||||
xfer_buffer_refresh (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* xfer_config_reload: reload xfer configuration file
|
||||
*/
|
||||
@@ -110,7 +127,7 @@ xfer_config_init ()
|
||||
"progress_bar_size", "integer",
|
||||
N_("size of progress bar, in chars (if 0, progress bar is disabled)"),
|
||||
NULL, 0, XFER_CONFIG_PROGRESS_BAR_MAX_SIZE, "20",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
|
||||
ptr_section = weechat_config_new_section (xfer_config_file, "color",
|
||||
0, 0,
|
||||
@@ -127,55 +144,55 @@ xfer_config_init ()
|
||||
"text", "color",
|
||||
N_("text color"),
|
||||
NULL, 0, 0, "default",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
xfer_config_color_text_bg = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"text_bg", "color",
|
||||
N_("background color"),
|
||||
NULL, 0, 0, "default",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
xfer_config_color_text_selected = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"text_selected", "color",
|
||||
N_("text color of selected xfer line"),
|
||||
NULL, 0, 0, "white",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
xfer_config_color_status[XFER_STATUS_WAITING] = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"status_waiting", "color",
|
||||
N_("text color for \"waiting\" status"),
|
||||
NULL, 0, 0, "lightcyan",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
xfer_config_color_status[XFER_STATUS_CONNECTING] = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"status_connecting", "color",
|
||||
N_("text color for \"connecting\" status"),
|
||||
NULL, 0, 0, "yellow",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
xfer_config_color_status[XFER_STATUS_ACTIVE] = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"status_active", "color",
|
||||
N_("text color for \"active\" status"),
|
||||
NULL, 0, 0, "lightblue",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
xfer_config_color_status[XFER_STATUS_DONE] = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"status_done", "color",
|
||||
N_("text color for \"done\" status"),
|
||||
NULL, 0, 0, "lightgreen",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
xfer_config_color_status[XFER_STATUS_FAILED] = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"status_failed", "color",
|
||||
N_("text color for \"failed\" status"),
|
||||
NULL, 0, 0, "lightred",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
xfer_config_color_status[XFER_STATUS_ABORTED] = weechat_config_new_option (
|
||||
xfer_config_file, ptr_section,
|
||||
"status_aborted", "color",
|
||||
N_("text color for \"aborted\" status"),
|
||||
NULL, 0, 0, "lightred",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
|
||||
|
||||
ptr_section = weechat_config_new_section (xfer_config_file, "network",
|
||||
0, 0,
|
||||
|
||||
Reference in New Issue
Block a user