mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 04:16:38 +02:00
Fixed log problem with new color display system (now color codes are removed in
log file)
This commit is contained in:
+31
-2
@@ -58,6 +58,29 @@ log_write_date (t_gui_buffer *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* log_write_line: writes a line to log file
|
||||
*/
|
||||
|
||||
void
|
||||
log_write_line (t_gui_buffer *buffer, char *message)
|
||||
{
|
||||
char *msg_no_color;
|
||||
|
||||
if (buffer->log_file)
|
||||
{
|
||||
wee_log_printf ("avant write line: %s\n", message);
|
||||
msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0);
|
||||
wee_log_printf ("apres decode: %s\n", msg_no_color);
|
||||
log_write_date (buffer);
|
||||
fprintf (buffer->log_file, "%s\n",
|
||||
(msg_no_color) ? msg_no_color : message);
|
||||
fflush (buffer->log_file);
|
||||
if (msg_no_color)
|
||||
free (msg_no_color);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* log_write: writes a message to log file
|
||||
*/
|
||||
@@ -65,10 +88,16 @@ log_write_date (t_gui_buffer *buffer)
|
||||
void
|
||||
log_write (t_gui_buffer *buffer, char *message)
|
||||
{
|
||||
char *msg_no_color;
|
||||
|
||||
if (buffer->log_file)
|
||||
{
|
||||
fprintf (buffer->log_file, "%s", message);
|
||||
{
|
||||
msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0);
|
||||
fprintf (buffer->log_file, "%s",
|
||||
(msg_no_color) ? msg_no_color : message);
|
||||
fflush (buffer->log_file);
|
||||
if (msg_no_color)
|
||||
free (msg_no_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -25,8 +25,8 @@
|
||||
#include "../gui/gui.h"
|
||||
|
||||
extern void log_write_date (t_gui_buffer *);
|
||||
extern void log_write_line (t_gui_buffer *, char *);
|
||||
extern void log_write (t_gui_buffer *, char *);
|
||||
extern void log_write_line (t_gui_buffer *, t_gui_line *);
|
||||
extern void log_start (t_gui_buffer *);
|
||||
extern void log_end (t_gui_buffer *);
|
||||
|
||||
|
||||
@@ -238,6 +238,18 @@ gui_color_decode (unsigned char *string, int keep_colors)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_COLOR_CHAR:
|
||||
string++;
|
||||
if (isdigit (string[0]) && isdigit (string[1]))
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
out[out_pos++] = string[1];
|
||||
}
|
||||
string += 2;
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_SET_CHAR:
|
||||
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
|
||||
string++;
|
||||
|
||||
+12
-2
@@ -494,6 +494,7 @@ gui_new_line (t_gui_buffer *buffer)
|
||||
new_line->line_with_message = 0;
|
||||
new_line->line_with_highlight = 0;
|
||||
new_line->data = NULL;
|
||||
new_line->ofs_after_date = -1;
|
||||
if (!buffer->lines)
|
||||
buffer->lines = new_line;
|
||||
else
|
||||
@@ -601,10 +602,16 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *message)
|
||||
buffer->last_line->data = (char *) realloc (buffer->last_line->data,
|
||||
strlen (buffer->last_line->data) +
|
||||
strlen (message) + 1);
|
||||
if (((type & MSG_TYPE_TIME) == 0) && (buffer->last_line->ofs_after_date < 0))
|
||||
buffer->last_line->ofs_after_date = strlen (buffer->last_line->data);
|
||||
strcat (buffer->last_line->data, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((type & MSG_TYPE_TIME) == 0) && (buffer->last_line->ofs_after_date < 0))
|
||||
buffer->last_line->ofs_after_date = 0;
|
||||
buffer->last_line->data = strdup (message);
|
||||
}
|
||||
|
||||
length = gui_word_strlen (NULL, message);
|
||||
buffer->last_line->length += length;
|
||||
@@ -641,8 +648,11 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *message)
|
||||
}
|
||||
if (buffer->line_complete && buffer->log_file && buffer->last_line->log_write)
|
||||
{
|
||||
log_write (buffer, buffer->last_line->data);
|
||||
log_write (buffer, "\n");
|
||||
if (buffer->last_line->ofs_after_date >= 0)
|
||||
log_write_line (buffer,
|
||||
buffer->last_line->data + buffer->last_line->ofs_after_date);
|
||||
else
|
||||
log_write_line (buffer, buffer->last_line->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,7 @@ struct t_gui_line
|
||||
int line_with_message; /* line contains a message from a user? */
|
||||
int line_with_highlight; /* line contains highlight */
|
||||
char *data; /* line content */
|
||||
int ofs_after_date; /* offset to first char after date */
|
||||
t_gui_line *prev_line; /* link to previous line */
|
||||
t_gui_line *next_line; /* link to next line */
|
||||
};
|
||||
|
||||
@@ -58,6 +58,29 @@ log_write_date (t_gui_buffer *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* log_write_line: writes a line to log file
|
||||
*/
|
||||
|
||||
void
|
||||
log_write_line (t_gui_buffer *buffer, char *message)
|
||||
{
|
||||
char *msg_no_color;
|
||||
|
||||
if (buffer->log_file)
|
||||
{
|
||||
wee_log_printf ("avant write line: %s\n", message);
|
||||
msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0);
|
||||
wee_log_printf ("apres decode: %s\n", msg_no_color);
|
||||
log_write_date (buffer);
|
||||
fprintf (buffer->log_file, "%s\n",
|
||||
(msg_no_color) ? msg_no_color : message);
|
||||
fflush (buffer->log_file);
|
||||
if (msg_no_color)
|
||||
free (msg_no_color);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* log_write: writes a message to log file
|
||||
*/
|
||||
@@ -65,10 +88,16 @@ log_write_date (t_gui_buffer *buffer)
|
||||
void
|
||||
log_write (t_gui_buffer *buffer, char *message)
|
||||
{
|
||||
char *msg_no_color;
|
||||
|
||||
if (buffer->log_file)
|
||||
{
|
||||
fprintf (buffer->log_file, "%s", message);
|
||||
{
|
||||
msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0);
|
||||
fprintf (buffer->log_file, "%s",
|
||||
(msg_no_color) ? msg_no_color : message);
|
||||
fflush (buffer->log_file);
|
||||
if (msg_no_color)
|
||||
free (msg_no_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#include "../gui/gui.h"
|
||||
|
||||
extern void log_write_date (t_gui_buffer *);
|
||||
extern void log_write_line (t_gui_buffer *, char *);
|
||||
extern void log_write (t_gui_buffer *, char *);
|
||||
extern void log_write_line (t_gui_buffer *, t_gui_line *);
|
||||
extern void log_start (t_gui_buffer *);
|
||||
extern void log_end (t_gui_buffer *);
|
||||
|
||||
|
||||
@@ -238,6 +238,18 @@ gui_color_decode (unsigned char *string, int keep_colors)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_COLOR_CHAR:
|
||||
string++;
|
||||
if (isdigit (string[0]) && isdigit (string[1]))
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
out[out_pos++] = string[1];
|
||||
}
|
||||
string += 2;
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_SET_CHAR:
|
||||
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
|
||||
string++;
|
||||
|
||||
@@ -494,6 +494,7 @@ gui_new_line (t_gui_buffer *buffer)
|
||||
new_line->line_with_message = 0;
|
||||
new_line->line_with_highlight = 0;
|
||||
new_line->data = NULL;
|
||||
new_line->ofs_after_date = -1;
|
||||
if (!buffer->lines)
|
||||
buffer->lines = new_line;
|
||||
else
|
||||
@@ -601,10 +602,16 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *message)
|
||||
buffer->last_line->data = (char *) realloc (buffer->last_line->data,
|
||||
strlen (buffer->last_line->data) +
|
||||
strlen (message) + 1);
|
||||
if (((type & MSG_TYPE_TIME) == 0) && (buffer->last_line->ofs_after_date < 0))
|
||||
buffer->last_line->ofs_after_date = strlen (buffer->last_line->data);
|
||||
strcat (buffer->last_line->data, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((type & MSG_TYPE_TIME) == 0) && (buffer->last_line->ofs_after_date < 0))
|
||||
buffer->last_line->ofs_after_date = 0;
|
||||
buffer->last_line->data = strdup (message);
|
||||
}
|
||||
|
||||
length = gui_word_strlen (NULL, message);
|
||||
buffer->last_line->length += length;
|
||||
@@ -641,8 +648,11 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *message)
|
||||
}
|
||||
if (buffer->line_complete && buffer->log_file && buffer->last_line->log_write)
|
||||
{
|
||||
log_write (buffer, buffer->last_line->data);
|
||||
log_write (buffer, "\n");
|
||||
if (buffer->last_line->ofs_after_date >= 0)
|
||||
log_write_line (buffer,
|
||||
buffer->last_line->data + buffer->last_line->ofs_after_date);
|
||||
else
|
||||
log_write_line (buffer, buffer->last_line->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,7 @@ struct t_gui_line
|
||||
int line_with_message; /* line contains a message from a user? */
|
||||
int line_with_highlight; /* line contains highlight */
|
||||
char *data; /* line content */
|
||||
int ofs_after_date; /* offset to first char after date */
|
||||
t_gui_line *prev_line; /* link to previous line */
|
||||
t_gui_line *next_line; /* link to next line */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user