summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-chat.c3
-rw-r--r--src/gui/curses/gui-curses-color.c152
-rw-r--r--src/gui/curses/gui-curses-input.c34
-rw-r--r--src/gui/curses/gui-curses-keyboard.c5
-rw-r--r--src/gui/curses/gui-curses-main.c3
-rw-r--r--src/gui/gtk/gui-gtk-chat.c3
-rw-r--r--src/gui/gtk/gui-gtk-color.c156
-rw-r--r--src/gui/gui-action.c9
-rw-r--r--src/gui/gui-buffer.c2
-rw-r--r--src/gui/gui-color.h4
-rw-r--r--src/gui/gui-common.c28
-rw-r--r--src/gui/gui-keyboard.c20
-rw-r--r--src/gui/gui-log.c4
-rw-r--r--src/gui/gui.h19
14 files changed, 244 insertions, 198 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index 1f2eba401..285fb1762 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -186,7 +186,7 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase)
{
if (CHANNEL(buffer)->topic)
{
- buf = (char *)gui_color_decode ((unsigned char *)(CHANNEL(buffer)->topic), 0);
+ buf = (char *)gui_color_decode ((unsigned char *)(CHANNEL(buffer)->topic), 0, 0);
ptr_topic = utf8_add_offset ((buf) ? buf : CHANNEL(buffer)->topic,
ptr_win->win_title_start);
if (!ptr_topic || !ptr_topic[0])
@@ -365,6 +365,7 @@ gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
}
break;
case GUI_ATTR_RESET_CHAR:
+ case GUI_ATTR_WEECHAT_RESET_CHAR:
string++;
if (apply_style)
gui_chat_reset_style (window);
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c
index 1b9f7dd02..42c19eb8c 100644
--- a/src/gui/curses/gui-curses-color.c
+++ b/src/gui/curses/gui-curses-color.c
@@ -112,16 +112,14 @@ gui_color_get_name (int num_color)
/*
* gui_color_decode: parses a message (coming from IRC server),
- * and according:
- * - remove any color/style in message
- * or:
- * - change colors by codes to be compatible with
- * other IRC clients
+ * if keep_colors == 0: remove any color/style in message
+ * otherwise change colors by internal WeeChat color codes
+ * if wkeep_eechat_attr == 0: remove any weechat color/style attribute
* After use, string returned has to be free()
*/
unsigned char *
-gui_color_decode (unsigned char *string, int keep_colors)
+gui_color_decode (unsigned char *string, int keep_irc_colors, int keep_weechat_attr)
{
unsigned char *out;
int out_length, out_pos;
@@ -134,7 +132,7 @@ gui_color_decode (unsigned char *string, int keep_colors)
return NULL;
out_pos = 0;
- while (string[0] && (out_pos < out_length - 1))
+ while (string && string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
@@ -145,7 +143,7 @@ gui_color_decode (unsigned char *string, int keep_colors)
case GUI_ATTR_REVERSE2_CHAR:
case GUI_ATTR_ITALIC_CHAR:
case GUI_ATTR_UNDERLINE_CHAR:
- if (keep_colors)
+ if (keep_irc_colors)
out[out_pos++] = string[0];
string++;
break;
@@ -181,7 +179,7 @@ gui_color_decode (unsigned char *string, int keep_colors)
}
}
}
- if (keep_colors)
+ if (keep_irc_colors)
{
if (!str_fg[0] && !str_bg[0])
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
@@ -226,10 +224,12 @@ gui_color_decode (unsigned char *string, int keep_colors)
}
break;
case GUI_ATTR_WEECHAT_COLOR_CHAR:
+ if (keep_weechat_attr)
+ out[out_pos++] = string[0];
string++;
if (isdigit (string[0]) && isdigit (string[1]))
{
- if (keep_colors)
+ if (keep_weechat_attr)
{
out[out_pos++] = string[0];
out[out_pos++] = string[1];
@@ -239,17 +239,21 @@ gui_color_decode (unsigned char *string, int keep_colors)
break;
case GUI_ATTR_WEECHAT_SET_CHAR:
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
+ if (keep_weechat_attr)
+ out[out_pos++] = string[0];
string++;
if (string[0])
{
- if (keep_colors)
- {
- out[out_pos++] = *(string - 1);
+ if (keep_weechat_attr)
out[out_pos++] = string[0];
- }
string++;
}
break;
+ case GUI_ATTR_WEECHAT_RESET_CHAR:
+ if (keep_weechat_attr)
+ out[out_pos++] = string[0];
+ string++;
+ break;
default:
out[out_pos++] = string[0];
string++;
@@ -261,7 +265,7 @@ gui_color_decode (unsigned char *string, int keep_colors)
/*
* gui_color_decode_for_user_entry: parses a message (coming from IRC server),
- * and replaces colors/bold/.. by %C, %B, ..
+ * and replaces colors/bold/.. by ^C, ^B, ..
* After use, string returned has to be free()
*/
@@ -277,40 +281,35 @@ gui_color_decode_for_user_entry (unsigned char *string)
return NULL;
out_pos = 0;
- while (string[0] && (out_pos < out_length - 1))
+ while (string && string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'B';
+ out[out_pos++] = 0x02; /* ^B */
string++;
break;
case GUI_ATTR_FIXED_CHAR:
string++;
break;
case GUI_ATTR_RESET_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'O';
+ out[out_pos++] = 0x0F; /* ^O */
string++;
break;
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'R';
+ out[out_pos++] = 0x12; /* ^R */
string++;
break;
case GUI_ATTR_ITALIC_CHAR:
string++;
break;
case GUI_ATTR_UNDERLINE_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'R';
+ out[out_pos++] = 0x15; /* ^U */
string++;
break;
case GUI_ATTR_COLOR_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'C';
+ out[out_pos++] = 0x03; /* ^C */
string++;
break;
default:
@@ -324,12 +323,14 @@ gui_color_decode_for_user_entry (unsigned char *string)
/*
* gui_color_encode: parses a message (entered by user), and
- * encode special chars (%B, %C, ..) in IRC colors
+ * encode special chars (^Cb, ^Cc, ..) in IRC colors
+ * if keep_colors == 0: remove any color/style in message
+ * otherwise: keep colors
* After use, string returned has to be free()
*/
unsigned char *
-gui_color_encode (unsigned char *string)
+gui_color_encode (unsigned char *string, int keep_colors)
{
unsigned char *out;
int out_length, out_pos;
@@ -340,72 +341,65 @@ gui_color_encode (unsigned char *string)
return NULL;
out_pos = 0;
- while (string[0] && (out_pos < out_length - 1))
+ while (string && string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
- case '%':
+ case 0x02: /* ^B */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_BOLD_CHAR;
string++;
- switch (string[0])
+ break;
+ case 0x03: /* ^C */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_COLOR_CHAR;
+ string++;
+ if (isdigit (string[0]))
{
- case '\0':
- out[out_pos++] = '%';
- break;
- case '%': /* double '%' replaced by single '%' */
+ if (keep_colors)
out[out_pos++] = string[0];
+ string++;
+ if (isdigit (string[0]))
+ {
+ if (keep_colors)
+ out[out_pos++] = string[0];
string++;
- break;
- case 'B': /* bold */
- out[out_pos++] = GUI_ATTR_BOLD_CHAR;
- string++;
- break;
- case 'C': /* color */
- out[out_pos++] = GUI_ATTR_COLOR_CHAR;
+ }
+ }
+ if (string[0] == ',')
+ {
+ if (keep_colors)
+ out[out_pos++] = ',';
+ string++;
+ if (isdigit (string[0]))
+ {
+ if (keep_colors)
+ out[out_pos++] = string[0];
string++;
if (isdigit (string[0]))
{
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
- {
+ if (keep_colors)
out[out_pos++] = string[0];
- string++;
- }
- }
- if (string[0] == ',')
- {
- out[out_pos++] = ',';
string++;
- if (isdigit (string[0]))
- {
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
- {
- out[out_pos++] = string[0];
- string++;
- }
- }
}
- break;
- case 'O': /* reset */
- out[out_pos++] = GUI_ATTR_RESET_CHAR;
- string++;
- break;
- case 'R': /* reverse */
- out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
- string++;
- break;
- case 'U': /* underline */
- out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
- string++;
- break;
- default:
- out[out_pos++] = '%';
- out[out_pos++] = string[0];
- string++;
+ }
}
break;
+ case 0x0F: /* ^O */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_RESET_CHAR;
+ string++;
+ break;
+ case 0x12: /* ^R */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
+ string++;
+ break;
+ case 0x15: /* ^U */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
+ string++;
+ break;
default:
out[out_pos++] = string[0];
string++;
diff --git a/src/gui/curses/gui-curses-input.c b/src/gui/curses/gui-curses-input.c
index 922b1e748..8b25c7a51 100644
--- a/src/gui/curses/gui-curses-input.c
+++ b/src/gui/curses/gui-curses-input.c
@@ -273,7 +273,7 @@ gui_input_draw_prompt (t_gui_window *window, char *nick)
int
gui_input_draw_text (t_gui_window *window, int input_width)
{
- char *ptr_start, *ptr_next, saved_char, *output;
+ char *ptr_start, *ptr_next, saved_char, *output, *ptr_string;
int pos_mask, size, last_color, color, count_cursor, offset_cursor;
ptr_start = utf8_add_offset (window->buffer->input_buffer,
@@ -316,14 +316,34 @@ gui_input_draw_text (t_gui_window *window, int input_width)
last_color = color;
}
output = weechat_iconv_from_internal (NULL, ptr_start);
- wprintw (GUI_CURSES(window)->win_input, "%s", (output) ? output : ptr_start);
- if (output)
- free (output);
- if (count_cursor > 0)
+
+ ptr_string = (output) ? output : ptr_start;
+
+ if ((((unsigned char)ptr_string[0]) < 32) && (!ptr_string[1]))
+ {
+ wattron (GUI_CURSES(window)->win_input, A_REVERSE);
+ wprintw (GUI_CURSES(window)->win_input, "%c",
+ 'A' + ((unsigned char)ptr_string[0]) - 1);
+ wattroff (GUI_CURSES(window)->win_input, A_REVERSE);
+ if (count_cursor > 0)
+ {
+ offset_cursor++;
+ count_cursor--;
+ }
+ }
+ else
{
- offset_cursor += utf8_width_screen (ptr_start);
- count_cursor--;
+ wprintw (GUI_CURSES(window)->win_input, "%s", ptr_string);
+ if (count_cursor > 0)
+ {
+ offset_cursor += utf8_width_screen (ptr_start);
+ count_cursor--;
+ }
}
+
+ if (output)
+ free (output);
+
ptr_next[0] = saved_char;
ptr_start = ptr_next;
pos_mask += size;
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index 927f25dd1..90074bb27 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -105,6 +105,11 @@ gui_keyboard_default_bindings ()
gui_keyboard_bind ( /* m-s */ "meta-s", "switch_server");
gui_keyboard_bind ( /* m-u */ "meta-u", "scroll_unread");
gui_keyboard_bind ( /* ^R */ "ctrl-R", "search_text");
+ gui_keyboard_bind ( /* ^Cb */ "ctrl-Cb", "insert \\x02");
+ gui_keyboard_bind ( /* ^Cc */ "ctrl-Cc", "insert \\x03");
+ gui_keyboard_bind ( /* ^Co */ "ctrl-Co", "insert \\x0F");
+ gui_keyboard_bind ( /* ^Cr */ "ctrl-Cr", "insert \\x12");
+ gui_keyboard_bind ( /* ^Cu */ "ctrl-Cu", "insert \\x15");
/* keys bound with commands */
gui_keyboard_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index 89ba3409e..f4066b836 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -323,7 +323,8 @@ gui_main_init ()
curs_set (1);
noecho ();
nodelay (stdscr, TRUE);
-
+ raw ();
+
gui_color_init ();
gui_infobar = NULL;
diff --git a/src/gui/gtk/gui-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c
index 6a9a7c6ce..27a7b7d7b 100644
--- a/src/gui/gtk/gui-gtk-chat.c
+++ b/src/gui/gtk/gui-gtk-chat.c
@@ -263,6 +263,7 @@ gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
}
break;
case GUI_ATTR_RESET_CHAR:
+ case GUI_ATTR_WEECHAT_RESET_CHAR:
string++;
if (apply_style)
gui_chat_reset_style (window);
@@ -628,7 +629,7 @@ gui_chat_draw_line (t_gui_buffer *buffer, t_gui_line *line)
ptr_win = gui_buffer_find_window (buffer);
if (ptr_win)
{
- text_without_color = gui_color_decode ((unsigned char *)(line->data), 0);
+ text_without_color = gui_color_decode ((unsigned char *)(line->data), 0, 0);
if (text_without_color)
{
gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat,
diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c
index a852c3d9d..1c40f00e1 100644
--- a/src/gui/gtk/gui-gtk-color.c
+++ b/src/gui/gtk/gui-gtk-color.c
@@ -112,16 +112,14 @@ gui_color_get_name (int num_color)
/*
* gui_color_decode: parses a message (coming from IRC server),
- * and according:
- * - remove any color/style in message
- * or:
- * - change colors by codes to be compatible with
- * other IRC clients
+ * if keep_colors == 0: remove any color/style in message
+ * otherwise change colors by internal WeeChat color codes
+ * if wkeep_eechat_attr == 0: remove any weechat color/style attribute
* After use, string returned has to be free()
*/
unsigned char *
-gui_color_decode (unsigned char *string, int keep_colors)
+gui_color_decode (unsigned char *string, int keep_irc_colors, int keep_weechat_attr)
{
unsigned char *out;
int out_length, out_pos;
@@ -134,7 +132,7 @@ gui_color_decode (unsigned char *string, int keep_colors)
return NULL;
out_pos = 0;
- while (string[0] && (out_pos < out_length - 1))
+ while (string && string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
@@ -145,7 +143,7 @@ gui_color_decode (unsigned char *string, int keep_colors)
case GUI_ATTR_REVERSE2_CHAR:
case GUI_ATTR_ITALIC_CHAR:
case GUI_ATTR_UNDERLINE_CHAR:
- if (keep_colors)
+ if (keep_irc_colors)
out[out_pos++] = string[0];
string++;
break;
@@ -181,7 +179,7 @@ gui_color_decode (unsigned char *string, int keep_colors)
}
}
}
- if (keep_colors)
+ if (keep_irc_colors)
{
if (!str_fg[0] && !str_bg[0])
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
@@ -191,13 +189,13 @@ gui_color_decode (unsigned char *string, int keep_colors)
if (str_fg[0])
{
sscanf (str_fg, "%d", &fg);
- fg %= 16;
+ fg %= GUI_NUM_IRC_COLORS;
attr |= gui_irc_colors[fg][1];
}
if (str_bg[0])
{
sscanf (str_bg, "%d", &bg);
- bg %= 16;
+ bg %= GUI_NUM_IRC_COLORS;
attr |= gui_irc_colors[bg][1];
}
if (attr & A_BOLD)
@@ -226,10 +224,12 @@ gui_color_decode (unsigned char *string, int keep_colors)
}
break;
case GUI_ATTR_WEECHAT_COLOR_CHAR:
+ if (keep_weechat_attr)
+ out[out_pos++] = string[0];
string++;
if (isdigit (string[0]) && isdigit (string[1]))
{
- if (keep_colors)
+ if (keep_weechat_attr)
{
out[out_pos++] = string[0];
out[out_pos++] = string[1];
@@ -239,17 +239,21 @@ gui_color_decode (unsigned char *string, int keep_colors)
break;
case GUI_ATTR_WEECHAT_SET_CHAR:
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
+ if (keep_weechat_attr)
+ out[out_pos++] = string[0];
string++;
if (string[0])
{
- if (keep_colors)
- {
- out[out_pos++] = *(string - 1);
+ if (keep_weechat_attr)
out[out_pos++] = string[0];
- }
string++;
}
break;
+ case GUI_ATTR_WEECHAT_RESET_CHAR:
+ if (keep_weechat_attr)
+ out[out_pos++] = string[0];
+ string++;
+ break;
default:
out[out_pos++] = string[0];
string++;
@@ -261,7 +265,7 @@ gui_color_decode (unsigned char *string, int keep_colors)
/*
* gui_color_decode_for_user_entry: parses a message (coming from IRC server),
- * and replaces colors/bold/.. by %C, %B, ..
+ * and replaces colors/bold/.. by ^C, ^B, ..
* After use, string returned has to be free()
*/
@@ -277,40 +281,35 @@ gui_color_decode_for_user_entry (unsigned char *string)
return NULL;
out_pos = 0;
- while (string[0] && (out_pos < out_length - 1))
+ while (string && string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
case GUI_ATTR_BOLD_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'B';
+ out[out_pos++] = 0x02; /* ^B */
string++;
break;
case GUI_ATTR_FIXED_CHAR:
string++;
break;
case GUI_ATTR_RESET_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'O';
+ out[out_pos++] = 0x0F; /* ^O */
string++;
break;
case GUI_ATTR_REVERSE_CHAR:
case GUI_ATTR_REVERSE2_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'R';
+ out[out_pos++] = 0x12; /* ^R */
string++;
break;
case GUI_ATTR_ITALIC_CHAR:
string++;
break;
case GUI_ATTR_UNDERLINE_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'R';
+ out[out_pos++] = 0x15; /* ^U */
string++;
break;
case GUI_ATTR_COLOR_CHAR:
- out[out_pos++] = '%';
- out[out_pos++] = 'C';
+ out[out_pos++] = 0x03; /* ^C */
string++;
break;
default:
@@ -324,12 +323,14 @@ gui_color_decode_for_user_entry (unsigned char *string)
/*
* gui_color_encode: parses a message (entered by user), and
- * encode special chars (%B, %C, ..) in IRC colors
+ * encode special chars (^Cb, ^Cc, ..) in IRC colors
+ * if keep_colors == 0: remove any color/style in message
+ * otherwise: keep colors
* After use, string returned has to be free()
*/
unsigned char *
-gui_color_encode (unsigned char *string)
+gui_color_encode (unsigned char *string, int keep_colors)
{
unsigned char *out;
int out_length, out_pos;
@@ -340,72 +341,65 @@ gui_color_encode (unsigned char *string)
return NULL;
out_pos = 0;
- while (string[0] && (out_pos < out_length - 1))
+ while (string && string[0] && (out_pos < out_length - 1))
{
switch (string[0])
{
- case '%':
+ case 0x02: /* ^B */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_BOLD_CHAR;
string++;
- switch (string[0])
+ break;
+ case 0x03: /* ^C */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_COLOR_CHAR;
+ string++;
+ if (isdigit (string[0]))
{
- case '\0':
- out[out_pos++] = '%';
- break;
- case '%': /* double '%' replaced by single '%' */
+ if (keep_colors)
out[out_pos++] = string[0];
+ string++;
+ if (isdigit (string[0]))
+ {
+ if (keep_colors)
+ out[out_pos++] = string[0];
string++;
- break;
- case 'B': /* bold */
- out[out_pos++] = GUI_ATTR_BOLD_CHAR;
- string++;
- break;
- case 'C': /* color */
- out[out_pos++] = GUI_ATTR_COLOR_CHAR;
+ }
+ }
+ if (string[0] == ',')
+ {
+ if (keep_colors)
+ out[out_pos++] = ',';
+ string++;
+ if (isdigit (string[0]))
+ {
+ if (keep_colors)
+ out[out_pos++] = string[0];
string++;
if (isdigit (string[0]))
{
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
- {
+ if (keep_colors)
out[out_pos++] = string[0];
- string++;
- }
- }
- if (string[0] == ',')
- {
- out[out_pos++] = ',';
string++;
- if (isdigit (string[0]))
- {
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
- {
- out[out_pos++] = string[0];
- string++;
- }
- }
}
- break;
- case 'O': /* reset */
- out[out_pos++] = GUI_ATTR_RESET_CHAR;
- string++;
- break;
- case 'R': /* reverse */
- out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
- string++;
- break;
- case 'U': /* underline */
- out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
- string++;
- break;
- default:
- out[out_pos++] = '%';
- out[out_pos++] = string[0];
- string++;
+ }
}
break;
+ case 0x0F: /* ^O */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_RESET_CHAR;
+ string++;
+ break;
+ case 0x12: /* ^R */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
+ string++;
+ break;
+ case 0x15: /* ^U */
+ if (keep_colors)
+ out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
+ string++;
+ break;
default:
out[out_pos++] = string[0];
string++;
diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c
index b0fd8b154..520a1e9f1 100644
--- a/src/gui/gui-action.c
+++ b/src/gui/gui-action.c
@@ -39,6 +39,7 @@
#include "../common/hotlist.h"
#include "../common/log.h"
#include "../common/utf8.h"
+#include "../common/util.h"
#include "../irc/irc.h"
@@ -1446,10 +1447,16 @@ gui_action_grab_key (t_gui_window *window, char *args)
void
gui_action_insert_string (t_gui_window *window, char *args)
{
+ char *args2;
+
if (args)
{
- gui_insert_string_input (window, args, -1);
+ args2 = weechat_convert_hex_chars (args);
+ gui_insert_string_input (window,
+ (args2) ? args2 : args, -1);
gui_input_draw (window->buffer, 0);
+ if (args2)
+ free (args2);
}
}
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 3de88052a..05758b68b 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -735,7 +735,7 @@ gui_buffer_line_search (t_gui_line *line, char *text, int case_sensitive)
return 0;
rc = 0;
- data = (char *)gui_color_decode ((unsigned char *)line->data, 0);
+ data = (char *)gui_color_decode ((unsigned char *)line->data, 0, 0);
if (data)
{
if ((case_sensitive && (strstr (data, text)))
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 2d4569b85..5655a32ac 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -122,9 +122,11 @@ enum t_weechat_color
#define GUI_ATTR_WEECHAT_SET_STR "\x1A"
#define GUI_ATTR_WEECHAT_REMOVE_CHAR '\x1B'
#define GUI_ATTR_WEECHAT_REMOVE_STR "\x1B"
+#define GUI_ATTR_WEECHAT_RESET_CHAR '\x1C'
+#define GUI_ATTR_WEECHAT_RESET_STR "\x1C"
#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "")
-#define GUI_NO_COLOR GUI_ATTR_RESET_STR
+#define GUI_NO_COLOR GUI_ATTR_WEECHAT_RESET_STR
/* color structure */
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 34085092a..369b31b93 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -220,11 +220,12 @@ gui_add_to_line (t_gui_buffer *buffer, int type, time_t date, char *nick, char *
*/
void
-gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nick, char *message, ...)
+gui_printf_internal (t_gui_buffer *buffer, int display_time, int type,
+ int keep_irc_colors, char *nick, char *message, ...)
{
static char buf[8192];
- char text_time[1024];
- char text_time_char[2];
+ char *buf2;
+ char text_time[1024], text_time_char[2];
time_t date;
struct tm *local_time;
int time_first_digit, time_last_digit;
@@ -267,12 +268,20 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
if (!buf[0])
return;
-
- utf8_normalize (buf, '?');
+
+ buf2 = (char *)gui_color_decode ((unsigned char *)buf,
+ (keep_irc_colors >= 0) ?
+ keep_irc_colors : cfg_irc_colors_receive,
+ 1);
+
+ if (!buf2)
+ return;
+
+ utf8_normalize (buf2, '?');
if (gui_init_ok)
{
- pos = buf;
+ pos = buf2;
while (pos)
{
date = time (NULL);
@@ -356,7 +365,10 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *nic
}
}
else
- weechat_iconv_fprintf (stdout, buf);
+ weechat_iconv_fprintf (stdout, buf2);
+
+ if (buf2)
+ free (buf2);
}
/*
@@ -417,7 +429,7 @@ gui_infobar_printf (int time_displayed, int color, char *message, ...)
ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar));
if (ptr_infobar)
{
- buf2 = (char *)gui_color_decode ((unsigned char *)buf, 0);
+ buf2 = (char *)gui_color_decode ((unsigned char *)buf, 0, 0);
ptr_buf = (buf2) ? buf2 : buf;
ptr_infobar->color = color;
diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c
index ea8bd272c..05ddd3b69 100644
--- a/src/gui/gui-keyboard.c
+++ b/src/gui/gui-keyboard.c
@@ -469,7 +469,7 @@ gui_keyboard_bind (char *key, char *command)
{
t_gui_key_func *ptr_function;
t_gui_key *new_key;
- char *ptr_args;
+ char *command2, *ptr_args;
if (!key || !command)
{
@@ -480,18 +480,24 @@ gui_keyboard_bind (char *key, char *command)
ptr_function = NULL;
ptr_args = NULL;
+
if (command[0] != '/')
{
ptr_args = strchr (command, ' ');
if (ptr_args)
- ptr_args[0] = '\0';
- ptr_function = gui_keyboard_function_search_by_name (command);
- if (ptr_args)
+ command2 = strndup (command, ptr_args - command);
+ else
+ command2 = strdup (command);
+ if (command2)
{
- ptr_args[0] = ' ';
- ptr_args++;
- while (ptr_args[0] == ' ')
+ ptr_function = gui_keyboard_function_search_by_name (command2);
+ if (ptr_args)
+ {
ptr_args++;
+ while (ptr_args[0] == ' ')
+ ptr_args++;
+ }
+ free (command2);
}
if (!ptr_function)
{
diff --git a/src/gui/gui-log.c b/src/gui/gui-log.c
index c4a54640b..515a9c5e0 100644
--- a/src/gui/gui-log.c
+++ b/src/gui/gui-log.c
@@ -69,7 +69,7 @@ gui_log_write_line (t_gui_buffer *buffer, char *message)
if (buffer->log_file)
{
- msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0);
+ msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0, 0);
weechat_iconv_fprintf (buffer->log_file,
"%s\n", (msg_no_color) ? msg_no_color : message);
fflush (buffer->log_file);
@@ -89,7 +89,7 @@ gui_log_write (t_gui_buffer *buffer, char *message)
if (buffer->log_file)
{
- msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0);
+ msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0, 0);
weechat_iconv_fprintf (buffer->log_file,
"%s", (msg_no_color) ? msg_no_color : message);
fflush (buffer->log_file);
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 8afb5d79c..045587839 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -28,19 +28,22 @@
#define gui_printf(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 1, MSG_TYPE_INFO, NULL, fmt, ##argz)
+ gui_printf_internal(buffer, 1, MSG_TYPE_INFO, -1, NULL, fmt, ##argz)
+
+#define gui_printf_keep_colors(buffer, fmt, argz...) \
+ gui_printf_internal(buffer, 1, MSG_TYPE_INFO, 1, NULL, fmt, ##argz)
#define gui_printf_type(buffer, type, fmt, argz...) \
- gui_printf_internal(buffer, 1, type, NULL, fmt, ##argz)
+ gui_printf_internal(buffer, 1, type, -1, NULL, fmt, ##argz)
#define gui_printf_type_nick(buffer, type, nick, fmt, argz...) \
- gui_printf_internal(buffer, 1, type, nick, fmt, ##argz)
+ gui_printf_internal(buffer, 1, type, -1, nick, fmt, ##argz)
#define gui_printf_nolog(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, NULL, fmt, ##argz)
+ gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, -1, NULL, fmt, ##argz)
#define gui_printf_nolog_notime(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, NULL, fmt, ##argz)
+ gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, -1, NULL, fmt, ##argz)
typedef struct t_gui_infobar t_gui_infobar;
@@ -191,7 +194,7 @@ extern void gui_log_end (t_gui_buffer *);
/* other */
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 *, char *, ...);
+extern void gui_printf_internal (t_gui_buffer *, int, int, int, char *, char *, ...);
extern void gui_printf_raw_data (void *, int, int, char *);
extern void gui_infobar_printf (int, int, char *, ...);
extern void gui_infobar_printf_from_buffer (t_gui_buffer *, int, int, char *, char *, ...);
@@ -210,9 +213,9 @@ extern int gui_insert_string_input (t_gui_window *, char *, int);
/* color */
extern int gui_color_assign (int *, char *);
extern char *gui_color_get_name (int);
-extern unsigned char *gui_color_decode (unsigned char *, int);
+extern unsigned char *gui_color_decode (unsigned char *, int, int);
extern unsigned char *gui_color_decode_for_user_entry (unsigned char *);
-extern unsigned char *gui_color_encode (unsigned char *);
+extern unsigned char *gui_color_encode (unsigned char *, int);
extern void gui_color_init_pairs ();
extern void gui_color_rebuild_weechat();