mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 08:43:13 +02:00
Added date in plugin function get_buffer_data()
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2006-10-12
|
||||
ChangeLog - 2006-10-14
|
||||
|
||||
|
||||
Version 0.2.2 (under dev!):
|
||||
* added date in plugin function get_buffer_data()
|
||||
* fixed some portability bugs (patch #5271)
|
||||
* fixed iconv detection for BSD (patch #5456)
|
||||
* fixed typo in configure.in (bash specific test) (patch #5450)
|
||||
|
||||
@@ -4076,6 +4076,11 @@ else
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>time_t</entry>
|
||||
<entry><literal>date</literal></entry>
|
||||
<entry>Datum/Zeit</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>char *</entry>
|
||||
<entry><literal>nick</literal></entry>
|
||||
@@ -4108,13 +4113,16 @@ else
|
||||
Example:
|
||||
<screen>
|
||||
t_plugin_buffer_line *buffer_line, *ptr_line;
|
||||
char text_time[256];
|
||||
|
||||
buffer_line = plugin->get_buffer_data (plugin);
|
||||
if (buffer_line)
|
||||
{
|
||||
for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "nick: %s, data: %s", ptr_line->nick, ptr_line->data);
|
||||
strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date)));
|
||||
plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s",
|
||||
text_time, ptr_line->nick, ptr_line->data);
|
||||
}
|
||||
plugin->free_buffer_data (plugin, buffer_line);
|
||||
}
|
||||
|
||||
@@ -4110,6 +4110,11 @@ else
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>time_t</entry>
|
||||
<entry><literal>date</literal></entry>
|
||||
<entry>date and time</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>char *</entry>
|
||||
<entry><literal>nick</literal></entry>
|
||||
@@ -4142,13 +4147,16 @@ else
|
||||
Example:
|
||||
<screen>
|
||||
t_plugin_buffer_line *buffer_line, *ptr_line;
|
||||
char text_time[256];
|
||||
|
||||
buffer_line = plugin->get_buffer_data (plugin);
|
||||
if (buffer_line)
|
||||
{
|
||||
for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "nick: %s, data: %s", ptr_line->nick, ptr_line->data);
|
||||
strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date)));
|
||||
plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s",
|
||||
text_time, ptr_line->nick, ptr_line->data);
|
||||
}
|
||||
plugin->free_buffer_data (plugin, buffer_line);
|
||||
}
|
||||
|
||||
@@ -4207,6 +4207,11 @@ else
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>time_t</entry>
|
||||
<entry><literal>date</literal></entry>
|
||||
<entry>date et heure</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>char *</entry>
|
||||
<entry><literal>nick</literal></entry>
|
||||
@@ -4242,13 +4247,16 @@ else
|
||||
Exemple :
|
||||
<screen>
|
||||
t_plugin_buffer_line *buffer_line, *ptr_line;
|
||||
char text_time[256];
|
||||
|
||||
buffer_line = plugin->get_buffer_data (plugin);
|
||||
if (buffer_line)
|
||||
{
|
||||
for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "pseudo: %s, données: %s", ptr_line->nick, ptr_line->data);
|
||||
strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date)));
|
||||
plugin->print (plugin, NULL, NULL, "date: %s, pseudo: %s, données: %s",
|
||||
text_time, ptr_line->nick, ptr_line->data);
|
||||
}
|
||||
plugin->free_buffer_data (plugin, buffer_line);
|
||||
}
|
||||
|
||||
@@ -377,6 +377,7 @@ session_save_line (FILE *file, t_gui_line *line)
|
||||
rc = rc && (session_write_int (file, SESSION_LINE_OFS_AFTER_DATE, line->ofs_start_message));
|
||||
rc = rc && (session_write_int (file, SESSION_LINE_OFS_START_MESSAGE, line->ofs_start_message));
|
||||
rc = rc && (session_write_str (file, SESSION_LINE_NICK, line->nick));
|
||||
rc = rc && (session_write_buf (file, SESSION_LINE_NICK, &(line->date), sizeof (time_t)));
|
||||
rc = rc && (session_write_id (file, SESSION_LINE_END));
|
||||
return rc;
|
||||
}
|
||||
@@ -1524,7 +1525,7 @@ session_load_line (FILE *file)
|
||||
}
|
||||
|
||||
/* allocate line */
|
||||
line = gui_buffer_line_new (session_current_buffer);
|
||||
line = gui_buffer_line_new (session_current_buffer, time (NULL));
|
||||
if (!line)
|
||||
{
|
||||
session_crash (file, _("can't create new line"));
|
||||
@@ -1573,6 +1574,9 @@ session_load_line (FILE *file)
|
||||
case SESSION_LINE_NICK:
|
||||
rc = rc && (session_read_str (file, &(line->nick)));
|
||||
break;
|
||||
case SESSION_LINE_DATE:
|
||||
rc = rc && (session_read_buf (file, &(line->date), sizeof (time_t)));
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"line (object id: %d)\n"),
|
||||
|
||||
@@ -179,7 +179,8 @@ enum t_session_line
|
||||
SESSION_LINE_DATA,
|
||||
SESSION_LINE_OFS_AFTER_DATE,
|
||||
SESSION_LINE_OFS_START_MESSAGE,
|
||||
SESSION_LINE_NICK
|
||||
SESSION_LINE_NICK,
|
||||
SESSION_LINE_DATE
|
||||
};
|
||||
|
||||
enum t_session_uptime
|
||||
|
||||
@@ -551,7 +551,7 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
|
||||
*/
|
||||
|
||||
t_gui_line *
|
||||
gui_buffer_line_new (t_gui_buffer *buffer)
|
||||
gui_buffer_line_new (t_gui_buffer *buffer, time_t date)
|
||||
{
|
||||
t_gui_line *new_line, *ptr_line;
|
||||
|
||||
@@ -562,6 +562,7 @@ gui_buffer_line_new (t_gui_buffer *buffer)
|
||||
new_line->log_write = 1;
|
||||
new_line->line_with_message = 0;
|
||||
new_line->line_with_highlight = 0;
|
||||
new_line->date = date;
|
||||
new_line->nick = NULL;
|
||||
new_line->data = NULL;
|
||||
new_line->ofs_after_date = -1;
|
||||
|
||||
@@ -62,6 +62,7 @@ struct t_gui_line
|
||||
int log_write; /* = 1 if line will be written to log */
|
||||
int line_with_message; /* line contains a message from a user? */
|
||||
int line_with_highlight; /* line contains highlight */
|
||||
time_t date; /* date/time of line */
|
||||
char *nick; /* nickname for line (may be NULL) */
|
||||
char *data; /* line content */
|
||||
int ofs_after_date; /* offset to first char after date */
|
||||
|
||||
+25
-25
@@ -108,7 +108,7 @@ gui_word_real_pos (t_gui_window *window, char *string, int pos)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message)
|
||||
gui_add_to_line (t_gui_buffer *buffer, int type, time_t date, char *nick, char *message)
|
||||
{
|
||||
char *pos;
|
||||
int length;
|
||||
@@ -117,7 +117,7 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message)
|
||||
if (buffer->line_complete)
|
||||
{
|
||||
buffer->line_complete = 0;
|
||||
if (!gui_buffer_line_new (buffer))
|
||||
if (!gui_buffer_line_new (buffer, date))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,14 +220,12 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
|
||||
static char buf[8192];
|
||||
char text_time[1024];
|
||||
char text_time_char[2];
|
||||
time_t time_seconds;
|
||||
time_t date;
|
||||
struct tm *local_time;
|
||||
int time_first_digit, time_last_digit;
|
||||
char *buf2, *pos;
|
||||
int i;
|
||||
va_list argptr;
|
||||
static time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
@@ -271,19 +269,16 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
|
||||
pos = buf2;
|
||||
while (pos)
|
||||
{
|
||||
date = time (NULL);
|
||||
if ((!buffer->last_line) || (buffer->line_complete))
|
||||
{
|
||||
if (display_time && cfg_look_buffer_timestamp &&
|
||||
cfg_look_buffer_timestamp[0])
|
||||
{
|
||||
time_seconds = time (NULL);
|
||||
local_time = localtime (&time_seconds);
|
||||
local_time = localtime (&date);
|
||||
strftime (text_time, sizeof (text_time), cfg_look_buffer_timestamp, local_time);
|
||||
|
||||
time_first_digit = -1;
|
||||
@@ -307,41 +302,46 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
|
||||
text_time_char[0] = text_time[i];
|
||||
if (time_first_digit < 0)
|
||||
{
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_TIME));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, text_time_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((i < time_first_digit) || (i > time_last_digit))
|
||||
{
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_DARK));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT_DARK));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, text_time_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isdigit (text_time[i]))
|
||||
{
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_TIME));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, text_time_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, text_time_char);
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, GUI_COLOR(COLOR_WIN_CHAT));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT));
|
||||
}
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, " ");
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date, NULL, " ");
|
||||
}
|
||||
gui_add_to_line (buffer, type, nick, pos);
|
||||
gui_add_to_line (buffer, type, date, nick, pos);
|
||||
pos = strchr (pos, '\n');
|
||||
if (pos)
|
||||
{
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ extern t_gui_buffer *gui_buffer_get_dcc (t_gui_window *);
|
||||
extern void gui_buffer_clear (t_gui_buffer *);
|
||||
extern void gui_buffer_clear_all ();
|
||||
extern void gui_buffer_free (t_gui_buffer *, int);
|
||||
extern t_gui_line *gui_buffer_line_new (t_gui_buffer *);
|
||||
extern t_gui_line *gui_buffer_line_new (t_gui_buffer *, time_t);
|
||||
extern void gui_buffer_merge_servers (t_gui_window *);
|
||||
extern void gui_buffer_split_server (t_gui_window *);
|
||||
extern void gui_buffer_switch_previous (t_gui_window *);
|
||||
|
||||
@@ -1294,6 +1294,7 @@ weechat_plugin_get_buffer_data (t_weechat_plugin *plugin, char *server, char *ch
|
||||
new_buffer_line = (t_plugin_buffer_line *) malloc (sizeof (t_plugin_buffer_line));
|
||||
if (new_buffer_line)
|
||||
{
|
||||
new_buffer_line->date = ptr_line->date;
|
||||
new_buffer_line->nick = (ptr_line->nick) ? strdup (ptr_line->nick) : NULL;
|
||||
new_buffer_line->data = (ptr_line->data) ?
|
||||
(char *) gui_color_decode ((unsigned char *)(ptr_line->data + ptr_line->ofs_start_message), 0) : NULL;
|
||||
|
||||
@@ -174,8 +174,9 @@ typedef struct t_plugin_buffer_line t_plugin_buffer_line;
|
||||
|
||||
struct t_plugin_buffer_line
|
||||
{
|
||||
char *nick; /* nick */
|
||||
char *data; /* line data */
|
||||
time_t date; /* date */
|
||||
char *nick; /* nick */
|
||||
char *data; /* line data */
|
||||
t_plugin_buffer_line *prev_line; /* link to previous line */
|
||||
t_plugin_buffer_line *next_line; /* link to next line */
|
||||
};
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2006-10-12
|
||||
ChangeLog - 2006-10-14
|
||||
|
||||
|
||||
Version 0.2.2 (under dev!):
|
||||
* added date in plugin function get_buffer_data()
|
||||
* fixed some portability bugs (patch #5271)
|
||||
* fixed iconv detection for BSD (patch #5456)
|
||||
* fixed typo in configure.in (bash specific test) (patch #5450)
|
||||
|
||||
@@ -4076,6 +4076,11 @@ else
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>time_t</entry>
|
||||
<entry><literal>date</literal></entry>
|
||||
<entry>Datum/Zeit</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>char *</entry>
|
||||
<entry><literal>nick</literal></entry>
|
||||
@@ -4108,13 +4113,16 @@ else
|
||||
Example:
|
||||
<screen>
|
||||
t_plugin_buffer_line *buffer_line, *ptr_line;
|
||||
char text_time[256];
|
||||
|
||||
buffer_line = plugin->get_buffer_data (plugin);
|
||||
if (buffer_line)
|
||||
{
|
||||
for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "nick: %s, data: %s", ptr_line->nick, ptr_line->data);
|
||||
strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date)));
|
||||
plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s",
|
||||
text_time, ptr_line->nick, ptr_line->data);
|
||||
}
|
||||
plugin->free_buffer_data (plugin, buffer_line);
|
||||
}
|
||||
|
||||
@@ -4110,6 +4110,11 @@ else
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>time_t</entry>
|
||||
<entry><literal>date</literal></entry>
|
||||
<entry>date and time</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>char *</entry>
|
||||
<entry><literal>nick</literal></entry>
|
||||
@@ -4142,13 +4147,16 @@ else
|
||||
Example:
|
||||
<screen>
|
||||
t_plugin_buffer_line *buffer_line, *ptr_line;
|
||||
char text_time[256];
|
||||
|
||||
buffer_line = plugin->get_buffer_data (plugin);
|
||||
if (buffer_line)
|
||||
{
|
||||
for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "nick: %s, data: %s", ptr_line->nick, ptr_line->data);
|
||||
strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date)));
|
||||
plugin->print (plugin, NULL, NULL, "date: %s, nick: %s, data: %s",
|
||||
text_time, ptr_line->nick, ptr_line->data);
|
||||
}
|
||||
plugin->free_buffer_data (plugin, buffer_line);
|
||||
}
|
||||
|
||||
@@ -4207,6 +4207,11 @@ else
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>time_t</entry>
|
||||
<entry><literal>date</literal></entry>
|
||||
<entry>date et heure</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>char *</entry>
|
||||
<entry><literal>nick</literal></entry>
|
||||
@@ -4242,13 +4247,16 @@ else
|
||||
Exemple :
|
||||
<screen>
|
||||
t_plugin_buffer_line *buffer_line, *ptr_line;
|
||||
char text_time[256];
|
||||
|
||||
buffer_line = plugin->get_buffer_data (plugin);
|
||||
if (buffer_line)
|
||||
{
|
||||
for (ptr_line = buffer_line; ptr_line; ptr_line = ptr_line->next_line)
|
||||
{
|
||||
plugin->print (plugin, NULL, NULL, "pseudo: %s, données: %s", ptr_line->nick, ptr_line->data);
|
||||
strftime (text_time, sizeof (text_time), "%x %X", localtime (&(ptr_line->date)));
|
||||
plugin->print (plugin, NULL, NULL, "date: %s, pseudo: %s, données: %s",
|
||||
text_time, ptr_line->nick, ptr_line->data);
|
||||
}
|
||||
plugin->free_buffer_data (plugin, buffer_line);
|
||||
}
|
||||
|
||||
@@ -377,6 +377,7 @@ session_save_line (FILE *file, t_gui_line *line)
|
||||
rc = rc && (session_write_int (file, SESSION_LINE_OFS_AFTER_DATE, line->ofs_start_message));
|
||||
rc = rc && (session_write_int (file, SESSION_LINE_OFS_START_MESSAGE, line->ofs_start_message));
|
||||
rc = rc && (session_write_str (file, SESSION_LINE_NICK, line->nick));
|
||||
rc = rc && (session_write_buf (file, SESSION_LINE_NICK, &(line->date), sizeof (time_t)));
|
||||
rc = rc && (session_write_id (file, SESSION_LINE_END));
|
||||
return rc;
|
||||
}
|
||||
@@ -1524,7 +1525,7 @@ session_load_line (FILE *file)
|
||||
}
|
||||
|
||||
/* allocate line */
|
||||
line = gui_buffer_line_new (session_current_buffer);
|
||||
line = gui_buffer_line_new (session_current_buffer, time (NULL));
|
||||
if (!line)
|
||||
{
|
||||
session_crash (file, _("can't create new line"));
|
||||
@@ -1573,6 +1574,9 @@ session_load_line (FILE *file)
|
||||
case SESSION_LINE_NICK:
|
||||
rc = rc && (session_read_str (file, &(line->nick)));
|
||||
break;
|
||||
case SESSION_LINE_DATE:
|
||||
rc = rc && (session_read_buf (file, &(line->date), sizeof (time_t)));
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"line (object id: %d)\n"),
|
||||
|
||||
@@ -179,7 +179,8 @@ enum t_session_line
|
||||
SESSION_LINE_DATA,
|
||||
SESSION_LINE_OFS_AFTER_DATE,
|
||||
SESSION_LINE_OFS_START_MESSAGE,
|
||||
SESSION_LINE_NICK
|
||||
SESSION_LINE_NICK,
|
||||
SESSION_LINE_DATE
|
||||
};
|
||||
|
||||
enum t_session_uptime
|
||||
|
||||
@@ -551,7 +551,7 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
|
||||
*/
|
||||
|
||||
t_gui_line *
|
||||
gui_buffer_line_new (t_gui_buffer *buffer)
|
||||
gui_buffer_line_new (t_gui_buffer *buffer, time_t date)
|
||||
{
|
||||
t_gui_line *new_line, *ptr_line;
|
||||
|
||||
@@ -562,6 +562,7 @@ gui_buffer_line_new (t_gui_buffer *buffer)
|
||||
new_line->log_write = 1;
|
||||
new_line->line_with_message = 0;
|
||||
new_line->line_with_highlight = 0;
|
||||
new_line->date = date;
|
||||
new_line->nick = NULL;
|
||||
new_line->data = NULL;
|
||||
new_line->ofs_after_date = -1;
|
||||
|
||||
@@ -62,6 +62,7 @@ struct t_gui_line
|
||||
int log_write; /* = 1 if line will be written to log */
|
||||
int line_with_message; /* line contains a message from a user? */
|
||||
int line_with_highlight; /* line contains highlight */
|
||||
time_t date; /* date/time of line */
|
||||
char *nick; /* nickname for line (may be NULL) */
|
||||
char *data; /* line content */
|
||||
int ofs_after_date; /* offset to first char after date */
|
||||
|
||||
@@ -108,7 +108,7 @@ gui_word_real_pos (t_gui_window *window, char *string, int pos)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message)
|
||||
gui_add_to_line (t_gui_buffer *buffer, int type, time_t date, char *nick, char *message)
|
||||
{
|
||||
char *pos;
|
||||
int length;
|
||||
@@ -117,7 +117,7 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message)
|
||||
if (buffer->line_complete)
|
||||
{
|
||||
buffer->line_complete = 0;
|
||||
if (!gui_buffer_line_new (buffer))
|
||||
if (!gui_buffer_line_new (buffer, date))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,14 +220,12 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
|
||||
static char buf[8192];
|
||||
char text_time[1024];
|
||||
char text_time_char[2];
|
||||
time_t time_seconds;
|
||||
time_t date;
|
||||
struct tm *local_time;
|
||||
int time_first_digit, time_last_digit;
|
||||
char *buf2, *pos;
|
||||
int i;
|
||||
va_list argptr;
|
||||
static time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
@@ -271,19 +269,16 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
|
||||
pos = buf2;
|
||||
while (pos)
|
||||
{
|
||||
date = time (NULL);
|
||||
if ((!buffer->last_line) || (buffer->line_complete))
|
||||
{
|
||||
if (display_time && cfg_look_buffer_timestamp &&
|
||||
cfg_look_buffer_timestamp[0])
|
||||
{
|
||||
time_seconds = time (NULL);
|
||||
local_time = localtime (&time_seconds);
|
||||
local_time = localtime (&date);
|
||||
strftime (text_time, sizeof (text_time), cfg_look_buffer_timestamp, local_time);
|
||||
|
||||
time_first_digit = -1;
|
||||
@@ -307,41 +302,46 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
|
||||
text_time_char[0] = text_time[i];
|
||||
if (time_first_digit < 0)
|
||||
{
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_TIME));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, text_time_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((i < time_first_digit) || (i > time_last_digit))
|
||||
{
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_DARK));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT_DARK));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, text_time_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isdigit (text_time[i]))
|
||||
{
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_TIME));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, text_time_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, text_time_char);
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, GUI_COLOR(COLOR_WIN_CHAT));
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date,
|
||||
NULL, GUI_COLOR(COLOR_WIN_CHAT));
|
||||
}
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, " ");
|
||||
gui_add_to_line (buffer, MSG_TYPE_TIME, date, NULL, " ");
|
||||
}
|
||||
gui_add_to_line (buffer, type, nick, pos);
|
||||
gui_add_to_line (buffer, type, date, nick, pos);
|
||||
pos = strchr (pos, '\n');
|
||||
if (pos)
|
||||
{
|
||||
|
||||
@@ -89,7 +89,7 @@ extern t_gui_buffer *gui_buffer_get_dcc (t_gui_window *);
|
||||
extern void gui_buffer_clear (t_gui_buffer *);
|
||||
extern void gui_buffer_clear_all ();
|
||||
extern void gui_buffer_free (t_gui_buffer *, int);
|
||||
extern t_gui_line *gui_buffer_line_new (t_gui_buffer *);
|
||||
extern t_gui_line *gui_buffer_line_new (t_gui_buffer *, time_t);
|
||||
extern void gui_buffer_merge_servers (t_gui_window *);
|
||||
extern void gui_buffer_split_server (t_gui_window *);
|
||||
extern void gui_buffer_switch_previous (t_gui_window *);
|
||||
|
||||
@@ -1294,6 +1294,7 @@ weechat_plugin_get_buffer_data (t_weechat_plugin *plugin, char *server, char *ch
|
||||
new_buffer_line = (t_plugin_buffer_line *) malloc (sizeof (t_plugin_buffer_line));
|
||||
if (new_buffer_line)
|
||||
{
|
||||
new_buffer_line->date = ptr_line->date;
|
||||
new_buffer_line->nick = (ptr_line->nick) ? strdup (ptr_line->nick) : NULL;
|
||||
new_buffer_line->data = (ptr_line->data) ?
|
||||
(char *) gui_color_decode ((unsigned char *)(ptr_line->data + ptr_line->ofs_start_message), 0) : NULL;
|
||||
|
||||
@@ -174,8 +174,9 @@ typedef struct t_plugin_buffer_line t_plugin_buffer_line;
|
||||
|
||||
struct t_plugin_buffer_line
|
||||
{
|
||||
char *nick; /* nick */
|
||||
char *data; /* line data */
|
||||
time_t date; /* date */
|
||||
char *nick; /* nick */
|
||||
char *data; /* line data */
|
||||
t_plugin_buffer_line *prev_line; /* link to previous line */
|
||||
t_plugin_buffer_line *next_line; /* link to next line */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user