summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui-action.c8
-rw-r--r--src/gui/gui-common.c63
-rw-r--r--src/gui/gui.h15
3 files changed, 57 insertions, 29 deletions
diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c
index 8d00f1ba1..3cedac744 100644
--- a/src/gui/gui-action.c
+++ b/src/gui/gui-action.c
@@ -216,12 +216,12 @@ gui_action_tab (t_gui_window *window)
{
if (strncmp (utf8_add_offset (window->buffer->input_buffer,
window->buffer->input_buffer_pos),
- cfg_look_completor, strlen (cfg_look_completor)) != 0)
- gui_insert_string_input (window, cfg_look_completor,
+ cfg_look_nick_completor, strlen (cfg_look_nick_completor)) != 0)
+ gui_insert_string_input (window, cfg_look_nick_completor,
window->buffer->input_buffer_pos);
if (window->buffer->completion.position >= 0)
- window->buffer->completion.position += strlen (cfg_look_completor);
- window->buffer->input_buffer_pos += utf8_strlen (cfg_look_completor);
+ window->buffer->completion.position += strlen (cfg_look_nick_completor);
+ window->buffer->input_buffer_pos += utf8_strlen (cfg_look_nick_completor);
if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer,
window->buffer->input_buffer_pos)] != ' ')
gui_insert_string_input (window, " ",
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 0ffe77ce8..4efb40587 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -645,6 +645,8 @@ gui_line_free (t_gui_line *line)
gui_draw_buffer_status (ptr_win->buffer, 0);
}
}
+ if (line->nick)
+ free (line->nick);
if (line->data)
free (line->data);
free (line);
@@ -762,8 +764,10 @@ gui_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->nick = NULL;
new_line->data = NULL;
new_line->ofs_after_date = -1;
+ new_line->ofs_start_message = -1;
if (!buffer->lines)
buffer->lines = new_line;
else
@@ -846,7 +850,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 *message)
+gui_add_to_line (t_gui_buffer *buffer, int type, char *nick, char *message)
{
char *pos;
int length;
@@ -865,19 +869,31 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *message)
pos[0] = '\0';
buffer->line_complete = 1;
}
+
+ if (nick && (!buffer->last_line->nick))
+ buffer->last_line->nick = strdup (nick);
+
if (buffer->last_line->data)
{
+ length = strlen (buffer->last_line->data);
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);
+ length + strlen (message) + 1);
+ if (((type & MSG_TYPE_TIME) == 0)
+ && (buffer->last_line->ofs_after_date < 0))
+ buffer->last_line->ofs_after_date = length;
+ if (((type & (MSG_TYPE_TIME | MSG_TYPE_NICK)) == 0)
+ && (buffer->last_line->ofs_start_message < 0))
+ buffer->last_line->ofs_start_message = length;
strcat (buffer->last_line->data, message);
}
else
{
- if (((type & MSG_TYPE_TIME) == 0) && (buffer->last_line->ofs_after_date < 0))
+ if (((type & MSG_TYPE_TIME) == 0)
+ && (buffer->last_line->ofs_after_date < 0))
buffer->last_line->ofs_after_date = 0;
+ if (((type & (MSG_TYPE_TIME | MSG_TYPE_NICK)) == 0)
+ && (buffer->last_line->ofs_start_message < 0))
+ buffer->last_line->ofs_start_message = 0;
buffer->last_line->data = strdup (message);
}
@@ -919,9 +935,16 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *message)
}
if (buffer->line_complete && buffer->log_file && buffer->last_line->log_write)
{
- if (buffer->last_line->ofs_after_date >= 0)
+ log_write_date (buffer);
+ if (buffer->last_line->nick)
+ {
+ log_write (buffer, "<");
+ log_write (buffer, buffer->last_line->nick);
+ log_write (buffer, "> ");
+ }
+ if (buffer->last_line->ofs_start_message >= 0)
log_write_line (buffer,
- buffer->last_line->data + buffer->last_line->ofs_after_date);
+ buffer->last_line->data + buffer->last_line->ofs_start_message);
else
log_write_line (buffer, buffer->last_line->data);
}
@@ -934,7 +957,7 @@ gui_add_to_line (t_gui_buffer *buffer, int type, char *message)
*/
void
-gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *message, ...)
+gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nick, char *message, ...)
{
static char buf[8192];
char text_time[1024];
@@ -1026,41 +1049,41 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *mes
text_time_char[0] = text_time[i];
if (time_first_digit < 0)
{
- gui_add_to_line (buffer, MSG_TYPE_TIME,
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
GUI_COLOR(COLOR_WIN_CHAT_TIME));
- gui_add_to_line (buffer, MSG_TYPE_TIME, text_time_char);
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
}
else
{
if ((i < time_first_digit) || (i > time_last_digit))
{
- gui_add_to_line (buffer, MSG_TYPE_TIME,
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
GUI_COLOR(COLOR_WIN_CHAT_DARK));
- gui_add_to_line (buffer, MSG_TYPE_TIME, text_time_char);
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
}
else
{
if (isdigit (text_time[i]))
{
- gui_add_to_line (buffer, MSG_TYPE_TIME,
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
GUI_COLOR(COLOR_WIN_CHAT_TIME));
- gui_add_to_line (buffer, MSG_TYPE_TIME, text_time_char);
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
}
else
{
- gui_add_to_line (buffer, MSG_TYPE_TIME,
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL,
GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP));
- gui_add_to_line (buffer, MSG_TYPE_TIME, text_time_char);
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, text_time_char);
}
}
}
i++;
}
- gui_add_to_line (buffer, MSG_TYPE_TIME, GUI_COLOR(COLOR_WIN_CHAT));
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, GUI_COLOR(COLOR_WIN_CHAT));
}
- gui_add_to_line (buffer, MSG_TYPE_TIME, " ");
+ gui_add_to_line (buffer, MSG_TYPE_TIME, NULL, " ");
}
- gui_add_to_line (buffer, type, pos);
+ gui_add_to_line (buffer, type, nick, pos);
pos = strchr (pos, '\n');
if (pos)
{
diff --git a/src/gui/gui.h b/src/gui/gui.h
index a479b2e5b..e943a100b 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -145,16 +145,19 @@ enum t_weechat_color
#define MSG_TYPE_NOLOG 64
#define gui_printf(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 1, MSG_TYPE_INFO, fmt, ##argz)
+ gui_printf_internal(buffer, 1, MSG_TYPE_INFO, NULL, fmt, ##argz)
#define gui_printf_type(buffer, type, fmt, argz...) \
- gui_printf_internal(buffer, 1, type, fmt, ##argz)
+ gui_printf_internal(buffer, 1, type, NULL, fmt, ##argz)
+
+#define gui_printf_type_nick(buffer, type, nick, fmt, argz...) \
+ gui_printf_internal(buffer, 1, type, nick, fmt, ##argz)
#define gui_printf_nolog(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, fmt, ##argz)
+ gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, NULL, fmt, ##argz)
#define gui_printf_nolog_notime(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, fmt, ##argz)
+ gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, NULL, fmt, ##argz)
#define WINDOW_MIN_WIDTH 10
#define WINDOW_MIN_HEIGHT 5
@@ -201,8 +204,10 @@ 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 */
+ char *nick; /* nickname for line (may be NULL) */
char *data; /* line content */
int ofs_after_date; /* offset to first char after date */
+ int ofs_start_message; /* offset to first char after date/nick */
t_gui_line *prev_line; /* link to previous line */
t_gui_line *next_line; /* link to next line */
};
@@ -417,7 +422,7 @@ extern void gui_buffer_free (t_gui_buffer *, int);
extern t_gui_line *gui_line_new (t_gui_buffer *);
extern int gui_word_strlen (t_gui_window *, char *);
extern int gui_word_real_pos (t_gui_window *, char *, int);
-extern void gui_printf_internal (t_gui_buffer *, int, int, char *, ...);
+extern void gui_printf_internal (t_gui_buffer *, int, int, char *, char *, ...);
extern void gui_printf_raw_data (void *, int, char *);
extern void gui_input_optimize_size (t_gui_buffer *);
extern void gui_input_init_color_mask (t_gui_buffer *);