Add color support in option weechat.look.buffer_time_format

This commit is contained in:
Sebastien Helleu 2010-12-07 19:43:19 +01:00
parent f7d719f8fd
commit b6662ee3cf
23 changed files with 173 additions and 52 deletions

View File

@ -1,12 +1,13 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.4-dev, 2010-12-06
v0.3.4-dev, 2010-12-07
Version 0.3.4 (under dev!)
--------------------------
* core: add color support in option weechat.look.buffer_time_format
* core: call to hook_config when config option is created
* core: add new option weechat.look.highlight_regex and function
string_has_highlight_regex in plugin API (task #10321)

View File

@ -349,7 +349,7 @@
** Werte: none, highlight, message, all (Standardwert: `all`)
* *weechat.look.buffer_time_format*
** Beschreibung: `Format für die Zeit die in jeder Zeile in einem Buffer dargestellt werden soll (siehe man strftime für Datum/Zeit Platzhalter)`
** Beschreibung: `time format for each line displayed in buffers (see man strftime for date/time specifiers), colors are allowed with format "${color}", for example french time: "${lightblue}%H${white}%M${lightred}%S"`
** Typ: Zeichenkette
** Werte: beliebige Zeichenkette (Standardwert: `"%H:%M:%S"`)

View File

@ -349,7 +349,7 @@
** values: none, highlight, message, all (default value: `all`)
* *weechat.look.buffer_time_format*
** description: `time format for each line displayed in buffers (see man strftime for date/time specifiers)`
** description: `time format for each line displayed in buffers (see man strftime for date/time specifiers), colors are allowed with format "${color}", for example french time: "${lightblue}%H${white}%M${lightred}%S"`
** type: string
** values: any string (default value: `"%H:%M:%S"`)

View File

@ -349,7 +349,7 @@
** valeurs: none, highlight, message, all (valeur par défaut: `all`)
* *weechat.look.buffer_time_format*
** description: `format de date/heure pour chaque ligne affichée dans les tampons (voir man strftime pour le format de date/heure)`
** description: `format de date/heure pour chaque ligne affichée dans les tampons (voir man strftime pour le format de date/heure), les couleurs sont autorisées avec le format "${couleur}", par exemple l'heure française: "${lightblue}%H${white}%M${lightred}%S"`
** type: chaîne
** valeurs: toute chaîne (valeur par défaut: `"%H:%M:%S"`)

View File

@ -349,7 +349,7 @@
** valori: none, highlight, message, all (valore predefinito: `all`)
* *weechat.look.buffer_time_format*
** descrizione: `formato dell'ora per ogni riga visualizzata nei buffer (consultare man strftime per gli specificatori data/ora)`
** descrizione: `time format for each line displayed in buffers (see man strftime for date/time specifiers), colors are allowed with format "${color}", for example french time: "${lightblue}%H${white}%M${lightred}%S"`
** tipo: stringa
** valori: qualsiasi stringa (valore predefinito: `"%H:%M:%S"`)

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-11-06 11:55+0100\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1795,7 +1795,8 @@ msgstr ""
#, fuzzy
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr ""
"časová známka použita v logovacích souborech (použijte manuálovou stránku "
"strftime pro spcifikátory data/času)"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.3-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-12-02 18:18+0100\n"
"Last-Translator: Nils G.\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1861,9 +1861,11 @@ msgstr ""
"Nachrichten (Standard), message=Nachrichten+Highlights, highlights=nur "
"Highlights, none=Hotlist wird niemals angezeigt."
#, fuzzy
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr ""
"Format für die Zeit die in jeder Zeile in einem Buffer dargestellt werden "
"soll (siehe man strftime für Datum/Zeit Platzhalter)"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-11-06 11:56+0100\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1810,7 +1810,8 @@ msgstr ""
#, fuzzy
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr ""
"formato de hora en el registro (ver el manual de strftime para los "
"especificadores de fecha/hora)"

View File

@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"PO-Revision-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-12-07 08:39+0100\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: French\n"
@ -1828,10 +1828,13 @@ msgstr ""
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr ""
"format de date/heure pour chaque ligne affichée dans les tampons (voir man "
"strftime pour le format de date/heure)"
"strftime pour le format de date/heure), les couleurs sont autorisées avec le "
"format \"${couleur}\", par exemple l'heure française: \"${lightblue}%H"
"${white}%M${lightred}%S\""
msgid "number of colors to use for nicks colors"
msgstr "nombre de couleurs à utiliser pour les couleurs des pseudos"
@ -7331,6 +7334,13 @@ msgstr "Hashtable (sortie)"
msgid "Pointer"
msgstr "Pointeur"
#~ msgid ""
#~ "time format for each line displayed in buffers (see man strftime for date/"
#~ "time specifiers)"
#~ msgstr ""
#~ "format de date/heure pour chaque ligne affichée dans les tampons (voir "
#~ "man strftime pour le format de date/heure)"
#~ msgid "[-server server] receiver[,receiver] text"
#~ msgstr "[-server serveur] cible[,cible] texte"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-11-05 17:17+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1615,7 +1615,8 @@ msgstr ""
#, fuzzy
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr "új nap kezdetével megjelenő időbélyeg"
msgid "number of colors to use for nicks colors"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-12-04 11:57+0100\n"
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1816,9 +1816,11 @@ msgstr ""
"message=messaggi+eventi, highlight=solo eventi, none=non viene mai "
"visualizzato nella hotlist"
#, fuzzy
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr ""
"formato dell'ora per ogni riga visualizzata nei buffer (consultare man "
"strftime per gli specificatori data/ora)"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-11-06 11:56+0100\n"
"Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1819,7 +1819,8 @@ msgstr ""
#, fuzzy
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr ""
"format czasu użyty w plikach z logami (zobacz man strftime dla "
"specyfikatorów daty/czasu)"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-11-13 09:26+0100\n"
"Last-Translator: Ivan Sichmann Freitas <ivansichfreitas@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1443,7 +1443,8 @@ msgstr ""
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr ""
msgid "number of colors to use for nicks colors"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.4-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: 2010-11-05 17:17+0100\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1624,7 +1624,8 @@ msgstr ""
#, fuzzy
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr "отображение маркера даты при смене дня"
msgid "number of colors to use for nicks colors"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2010-12-05 12:08+0100\n"
"POT-Creation-Date: 2010-12-07 19:35+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1383,7 +1383,8 @@ msgstr ""
msgid ""
"time format for each line displayed in buffers (see man strftime for date/"
"time specifiers)"
"time specifiers), colors are allowed with format \"${color}\", for example "
"french time: \"${lightblue}%H${white}%M${lightred}%S\""
msgstr ""
msgid "number of colors to use for nicks colors"

View File

@ -280,7 +280,7 @@ config_change_buffer_time_format (void *data, struct t_config_option *option)
(void) data;
(void) option;
gui_chat_time_length = util_get_time_length (CONFIG_STRING(config_look_buffer_time_format));
gui_chat_time_length = gui_chat_get_time_length ();
gui_chat_change_time_format ();
if (gui_ok)
gui_window_ask_refresh (1);
@ -1327,7 +1327,9 @@ config_weechat_init_options ()
weechat_config_file, ptr_section,
"buffer_time_format", "string",
N_("time format for each line displayed in buffers (see man strftime "
"for date/time specifiers)"),
"for date/time specifiers), colors are allowed with format "
"\"${color}\", for example french time: "
"\"${lightblue}%H${white}%M${lightred}%S\""),
NULL, 0, 0, "%H:%M:%S", NULL, 0, NULL, NULL, &config_change_buffer_time_format, NULL, NULL, NULL);
config_look_color_nicks_number = config_file_new_option (
weechat_config_file, ptr_section,

View File

@ -105,27 +105,6 @@ util_timeval_add (struct timeval *tv, long interval)
tv->tv_usec = usec;
}
/*
* util_get_time_length: calculates time length with a time format
*/
int
util_get_time_length (const char *time_format)
{
time_t date;
struct tm *local_time;
char text_time[1024];
if (!time_format || !time_format[0])
return 0;
date = time (NULL);
local_time = localtime (&date);
strftime (text_time, sizeof (text_time),
time_format, local_time);
return strlen (text_time);
}
/*
* util_get_time_string: converts date to a string, using format of option
* weechat.look.time_format (can be localized)

View File

@ -23,7 +23,6 @@
extern int util_timeval_cmp (struct timeval *tv1, struct timeval *tv2);
extern long util_timeval_diff (struct timeval *tv1, struct timeval *tv2);
extern void util_timeval_add (struct timeval *tv, long interval);
extern int util_get_time_length (const char *time_format);
extern char *util_get_time_string (const time_t *date);
extern void util_catch_signal (int signum, void (*handler)(int));
extern int util_mkdir_home (const char *directory, int mode);

View File

@ -112,7 +112,7 @@ gui_main_init ()
gui_input_clipboard = NULL;
/* get time length */
gui_chat_time_length = util_get_time_length (CONFIG_STRING(config_look_buffer_time_format));
gui_chat_time_length = gui_chat_get_time_length ();
/* init bar items */
gui_bar_item_init ();

View File

@ -289,6 +289,7 @@ char *
gui_chat_get_time_string (time_t date)
{
char text_time[128], text_time2[(128*3)+16], text_time_char[2];
char *text_with_color;
int i, time_first_digit, time_last_digit, last_color;
struct tm *local_time;
@ -302,6 +303,17 @@ gui_chat_get_time_string (time_t date)
local_time) == 0)
return NULL;
if (strstr (text_time, "${"))
{
text_with_color = gui_color_string_replace_colors (text_time);
if (text_with_color)
{
if (strcmp (text_time, text_with_color) != 0)
return text_with_color;
free (text_with_color);
}
}
time_first_digit = -1;
time_last_digit = -1;
i = 0;
@ -372,6 +384,35 @@ gui_chat_get_time_string (time_t date)
return strdup (text_time2);
}
/*
* gui_chat_get_time_length: calculates time length with a time format
* (format can include color codes with format ${name})
*/
int
gui_chat_get_time_length ()
{
time_t date;
char *text_time;
int length;
if (!CONFIG_STRING(config_look_buffer_time_format)
|| !CONFIG_STRING(config_look_buffer_time_format)[0])
return 0;
length = 0;
date = time (NULL);
text_time = gui_chat_get_time_string (date);
if (text_time)
{
length = gui_chat_strlen_screen (text_time);
free (text_time);
}
return length;
}
/*
* gui_chat_change_time_format: change time format for all lines of all buffers
*/

View File

@ -67,6 +67,7 @@ extern void gui_chat_get_word_info (struct t_gui_window *window,
int *word_length_with_spaces,
int *word_length);
extern char *gui_chat_get_time_string (time_t date);
extern int gui_chat_get_time_length ();
extern void gui_chat_change_time_format ();
extern char *gui_chat_build_string_prefix_message (struct t_gui_line *line);
extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,

View File

@ -347,6 +347,82 @@ gui_color_decode (const char *string, const char *replacement)
return (char *)out;
}
/*
* gui_color_string_replace_colors: replace colors in string with color codes
* colors are using format: ${name} where name
* is a color name
*/
char *
gui_color_string_replace_colors (const char *string)
{
int length, length_color, index_string, index_result;
char *result, *color_name;
const char *pos_end_name, *ptr_color;
if (!string)
return NULL;
length = strlen (string) + 1;
result = malloc (length);
if (result)
{
index_string = 0;
index_result = 0;
while (string[index_string])
{
if ((string[index_string] == '\\')
&& (string[index_string + 1] == '$'))
{
index_string++;
result[index_result++] = string[index_string++];
}
else if ((string[index_string] == '$')
&& (string[index_string + 1] == '{'))
{
pos_end_name = strchr (string + index_string + 2, '}');
if (pos_end_name)
{
color_name = string_strndup (string + index_string + 2,
pos_end_name - (string + index_string + 2));
if (color_name)
{
ptr_color = gui_color_get_custom (color_name);
if (ptr_color)
{
length_color = strlen (ptr_color);
length += length_color;
result = realloc (result, length);
if (!result)
{
free (color_name);
return NULL;
}
strcpy (result + index_result, ptr_color);
index_result += length_color;
index_string += pos_end_name - string -
index_string + 1;
}
else
result[index_result++] = string[index_string++];
free (color_name);
}
else
result[index_result++] = string[index_string++];
}
else
result[index_result++] = string[index_string++];
}
else
result[index_result++] = string[index_string++];
}
result[index_result] = '\0';
}
return result;
}
/*
* gui_color_free: free a color
*/

View File

@ -131,6 +131,7 @@ extern struct t_gui_color *gui_color[];
extern const char *gui_color_search_config (const char *color_name);
extern const char *gui_color_get_custom (const char *color_name);
extern char *gui_color_decode (const char *string, const char *replacement);
extern char *gui_color_string_replace_colors (const char *string);
extern void gui_color_free (struct t_gui_color *color);
/* color functions (GUI dependent) */