summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2005-11-04 13:11:39 +0000
committerSebastien Helleu <flashcode@flashtux.org>2005-11-04 13:11:39 +0000
commitdd3977367fa50d5f0d4fdb86534bb70415eeaa65 (patch)
tree988e6d41007b33fe872fa7d50fe1073fba9f50e5
parent8a9e8ecc885fe254234a42b692f8c2e20d5c24a5 (diff)
downloadweechat-dd3977367fa50d5f0d4fdb86534bb70415eeaa65.zip
Fixed log problem with new color display system (now color codes are removed in
log file)
-rw-r--r--src/common/log.c33
-rw-r--r--src/common/log.h2
-rw-r--r--src/gui/curses/gui-display.c12
-rw-r--r--src/gui/gui-common.c14
-rw-r--r--src/gui/gui.h1
-rw-r--r--weechat/src/common/log.c33
-rw-r--r--weechat/src/common/log.h2
-rw-r--r--weechat/src/gui/curses/gui-display.c12
-rw-r--r--weechat/src/gui/gui-common.c14
-rw-r--r--weechat/src/gui/gui.h1
10 files changed, 114 insertions, 10 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 1c18553ec..d6745171e 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -59,16 +59,45 @@ 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
*/
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);
}
}
diff --git a/src/common/log.h b/src/common/log.h
index 7119d50af..8ac650d10 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -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 *);
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index bc9708367..9addeeab0 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -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++;
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 2f4c6163f..a471fe54d 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -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);
}
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 09f13dbca..fb69c9a35 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -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 */
};
diff --git a/weechat/src/common/log.c b/weechat/src/common/log.c
index 1c18553ec..d6745171e 100644
--- a/weechat/src/common/log.c
+++ b/weechat/src/common/log.c
@@ -59,16 +59,45 @@ 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
*/
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);
}
}
diff --git a/weechat/src/common/log.h b/weechat/src/common/log.h
index 7119d50af..8ac650d10 100644
--- a/weechat/src/common/log.h
+++ b/weechat/src/common/log.h
@@ -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 *);
diff --git a/weechat/src/gui/curses/gui-display.c b/weechat/src/gui/curses/gui-display.c
index bc9708367..9addeeab0 100644
--- a/weechat/src/gui/curses/gui-display.c
+++ b/weechat/src/gui/curses/gui-display.c
@@ -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++;
diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c
index 2f4c6163f..a471fe54d 100644
--- a/weechat/src/gui/gui-common.c
+++ b/weechat/src/gui/gui-common.c
@@ -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);
}
}
diff --git a/weechat/src/gui/gui.h b/weechat/src/gui/gui.h
index 09f13dbca..fb69c9a35 100644
--- a/weechat/src/gui/gui.h
+++ b/weechat/src/gui/gui.h
@@ -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 */
};