1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 10:13:12 +02:00

Added date option for printf functions (weechat core and plugins API)

This commit is contained in:
Sebastien Helleu
2007-11-05 15:59:43 +01:00
parent a97e2955be
commit 0d66286efe
8 changed files with 84 additions and 18 deletions
+2 -1
View File
@@ -40,7 +40,8 @@ enum t_gui_buffer_type
struct t_gui_line
{
time_t date; /* date/time of line */
time_t date; /* date/time of line (may be past) */
time_t date_printed; /* date/time when weechat print it */
char *str_time; /* time string (for display) */
char *prefix; /* prefix for line (may be NULL) */
int prefix_length; /* prefix length (on screen) */
+11 -6
View File
@@ -399,8 +399,8 @@ gui_chat_line_free (struct t_gui_line *line)
*/
void
gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, char *prefix,
char *message)
gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
time_t date_printed, char *prefix, char *message)
{
struct t_gui_line *new_line, *ptr_line;
@@ -413,6 +413,7 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, char *prefix,
/* add new line */
new_line->date = date;
new_line->date_printed = date_printed;
new_line->str_time = (date == 0) ?
NULL : gui_chat_get_time_string (date);
new_line->prefix = (prefix) ?
@@ -446,14 +447,15 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, char *prefix,
}
/*
* gui_chat_printf: display a message in a buffer
* gui_chat_printf_date: display a message in a buffer
*/
void
gui_chat_printf (struct t_gui_buffer *buffer, char *message, ...)
gui_chat_printf_date (struct t_gui_buffer *buffer, time_t date,
char *message, ...)
{
static char buf[8192];
time_t date;
time_t date_printed;
int display_time;
char *pos, *pos_prefix, *pos_tab, *pos_end;
va_list argptr;
@@ -476,7 +478,9 @@ gui_chat_printf (struct t_gui_buffer *buffer, char *message, ...)
utf8_normalize (buf, '?');
date = time (NULL);
date_printed = time (NULL);
if (date <= 0)
date = date_printed;
pos = buf;
while (pos)
@@ -509,6 +513,7 @@ gui_chat_printf (struct t_gui_buffer *buffer, char *message, ...)
if (gui_init_ok)
gui_chat_line_add (buffer, (display_time) ? date : 0,
(display_time) ? date_printed : 0,
pos_prefix, pos);
else
{
+4 -1
View File
@@ -22,6 +22,9 @@
#include "gui-buffer.h"
#define gui_chat_printf(buffer, argz...) \
gui_chat_printf_date(buffer, 0, ##argz) \
enum t_gui_prefix
{
GUI_CHAT_PREFIX_INFO = 0,
@@ -49,7 +52,7 @@ extern int gui_chat_get_line_align (struct t_gui_buffer *,
struct t_gui_line *, int);
extern int gui_chat_line_search (struct t_gui_line *, char *, int);
extern void gui_chat_line_free (struct t_gui_line *);
extern void gui_chat_printf (struct t_gui_buffer *, char *, ...);
extern void gui_chat_printf_date (struct t_gui_buffer *, time_t, char *, ...);
extern void gui_chat_printf_raw_data (void *, int, int, char *);
/* chat functions (GUI dependent) */