summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/command.c2
-rw-r--r--src/common/weeconfig.c12
-rw-r--r--src/common/weeconfig.h2
-rw-r--r--src/gui/curses/gui-display.c264
-rw-r--r--src/gui/gui.h1
-rw-r--r--src/irc/irc-display.c8
-rw-r--r--src/irc/irc-recv.c395
-rw-r--r--src/irc/irc-server.c23
-rw-r--r--src/irc/irc.h20
9 files changed, 516 insertions, 211 deletions
diff --git a/src/common/command.c b/src/common/command.c
index e103dbd4b..ced60c86b 100644
--- a/src/common/command.c
+++ b/src/common/command.c
@@ -178,7 +178,7 @@ t_weechat_command weechat_commands[] =
{ "upgrade", N_("upgrade WeeChat without disconnecting from servers"),
"",
N_("This command run again WeeChat binary, so it should have been compiled "
- "installed with a package manager before running this command."),
+ "or installed with a package manager before running this command."),
NULL, 0, 0, weechat_cmd_upgrade, NULL },
{ "uptime", N_("show WeeChat uptime"),
N_("[-o]"),
diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c
index 29b7085a7..1da9e3df5 100644
--- a/src/common/weeconfig.c
+++ b/src/common/weeconfig.c
@@ -107,6 +107,7 @@ int cfg_look_hotlist_names_length;
int cfg_look_day_change;
char *cfg_look_day_change_timestamp;
char *cfg_look_read_marker;
+char *cfg_look_input_format;
t_config_option weechat_options_look[] =
{ { "look_set_title", N_("set title for window (terminal for Curses GUI) with name and version"),
@@ -270,7 +271,11 @@ t_config_option weechat_options_look[] =
{ "look_read_marker", N_("use a marker on servers/channels to show first unread line"),
N_("use a marker on servers/channels to show first unread line"),
OPTION_TYPE_STRING, 0, 0, 0,
- " ", NULL, NULL, &cfg_look_read_marker, config_change_read_marker},
+ " ", NULL, NULL, &cfg_look_read_marker, config_change_read_marker },
+ { "look_input_format", N_("format for input prompt"),
+ N_("format for input prompt"),
+ OPTION_TYPE_STRING, 0, 0, 0,
+ "[%n(%m)] ", NULL, NULL, &cfg_look_input_format, config_change_buffer_content },
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};
@@ -310,6 +315,7 @@ int cfg_col_infobar_delimiters;
int cfg_col_infobar_highlight;
int cfg_col_infobar_bg;
int cfg_col_input;
+int cfg_col_input_server;
int cfg_col_input_channel;
int cfg_col_input_nick;
int cfg_col_input_delimiters;
@@ -484,6 +490,10 @@ t_config_option weechat_options_colors[] =
N_("color for input text"),
OPTION_TYPE_COLOR, 0, 0, 0,
"default", NULL, &cfg_col_input, NULL, &config_change_color },
+ { "col_input_server", N_("color for input text (server name)"),
+ N_("color for input text (server name)"),
+ OPTION_TYPE_COLOR, 0, 0, 0,
+ "brown", NULL, &cfg_col_input_server, NULL, &config_change_color },
{ "col_input_channel", N_("color for input text (channel name)"),
N_("color for input text (channel name)"),
OPTION_TYPE_COLOR, 0, 0, 0,
diff --git a/src/common/weeconfig.h b/src/common/weeconfig.h
index 03e6377dc..b07e04bdc 100644
--- a/src/common/weeconfig.h
+++ b/src/common/weeconfig.h
@@ -126,6 +126,7 @@ extern int cfg_look_hotlist_names_length;
extern int cfg_look_day_change;
extern char *cfg_look_day_change_timestamp;
extern char *cfg_look_read_marker;
+extern char *cfg_look_input_format;
extern int cfg_col_real_white;
extern int cfg_col_separator;
@@ -161,6 +162,7 @@ extern int cfg_col_infobar_delimiters;
extern int cfg_col_infobar_highlight;
extern int cfg_col_infobar_bg;
extern int cfg_col_input;
+extern int cfg_col_input_server;
extern int cfg_col_input_channel;
extern int cfg_col_input_nick;
extern int cfg_col_input_delimiters;
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index e1763c08a..35ca1d06a 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -2432,17 +2432,185 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
}
/*
- * gui_get_input_width: return input width (max # chars displayed)
+ * gui_get_input_prompt_length: return input prompt length
*/
int
-gui_get_input_width (t_gui_window *window, char *nick)
+gui_get_input_prompt_length (t_gui_window *window, char *nick)
{
- if (CHANNEL(window->buffer))
- return (window->win_width - strlen (CHANNEL(window->buffer)->name) -
- strlen (nick) - 4);
- else
- return (window->win_width - strlen (nick) - 3);
+ char *pos, *modes;
+ int length, mode_found;
+
+ length = 0;
+ pos = cfg_look_input_format;
+ while (pos && pos[0])
+ {
+ switch (pos[0])
+ {
+ case '%':
+ pos++;
+ switch (pos[0])
+ {
+ case 'c':
+ if (CHANNEL(window->buffer))
+ length += utf8_strlen (CHANNEL(window->buffer)->name);
+ else
+ {
+ if (SERVER(window->buffer))
+ length += utf8_strlen (SERVER(window->buffer)->name);
+ }
+ pos++;
+ break;
+ case 'm':
+ if (SERVER(window->buffer))
+ {
+ mode_found = 0;
+ for (modes = SERVER(window->buffer)->nick_modes;
+ modes && modes[0]; modes++)
+ {
+ if (modes[0] != ' ')
+ {
+ length++;
+ mode_found = 1;
+ }
+ }
+ if (mode_found)
+ length++;
+ }
+ pos++;
+ break;
+ case 'n':
+ length += utf8_strlen (nick);
+ pos++;
+ break;
+ default:
+ length++;
+ if (pos[0])
+ {
+ if (pos[0] == '%')
+ pos++;
+ else
+ {
+ length++;
+ pos += utf8_char_size (pos);
+ }
+ }
+ break;
+ }
+ break;
+ default:
+ length++;
+ pos += utf8_char_size (pos);
+ break;
+ }
+ }
+ return length;
+}
+
+/*
+ * gui_draw_buffer_input_prompt: display input prompt
+ */
+
+void
+gui_draw_buffer_input_prompt (t_gui_window *window, char *nick)
+{
+ char *pos, saved_char, *modes;
+ int char_size, mode_found;
+
+ wmove (window->win_input, 0, 0);
+ pos = cfg_look_input_format;
+ while (pos && pos[0])
+ {
+ switch (pos[0])
+ {
+ case '%':
+ pos++;
+ switch (pos[0])
+ {
+ case 'c':
+ if (CHANNEL(window->buffer))
+ {
+ gui_window_set_weechat_color (window->win_input,
+ COLOR_WIN_INPUT_CHANNEL);
+ wprintw (window->win_input, "%s",
+ CHANNEL(window->buffer)->name);
+ }
+ else
+ {
+ if (SERVER(window->buffer))
+ {
+ gui_window_set_weechat_color (window->win_input,
+ COLOR_WIN_INPUT_SERVER);
+ wprintw (window->win_input, "%s",
+ SERVER(window->buffer)->name);
+ }
+ }
+ pos++;
+ break;
+ case 'm':
+ if (SERVER(window->buffer))
+ {
+ mode_found = 0;
+ for (modes = SERVER(window->buffer)->nick_modes;
+ modes && modes[0]; modes++)
+ {
+ if (modes[0] != ' ')
+ mode_found = 1;
+ }
+ if (mode_found)
+ {
+ gui_window_set_weechat_color (window->win_input,
+ COLOR_WIN_INPUT);
+ wprintw (window->win_input, "+");
+ for (modes = SERVER(window->buffer)->nick_modes;
+ modes && modes[0]; modes++)
+ {
+ if (modes[0] != ' ')
+ wprintw (window->win_input, "%c",
+ modes[0]);
+ }
+ }
+ }
+ pos++;
+ break;
+ case 'n':
+ gui_window_set_weechat_color (window->win_input,
+ COLOR_WIN_INPUT_NICK);
+ wprintw (window->win_input, "%s", nick);
+ pos++;
+ break;
+ default:
+ if (pos[0])
+ {
+ char_size = utf8_char_size (pos);
+ saved_char = pos[char_size];
+ pos[char_size] = '\0';
+ gui_window_set_weechat_color (window->win_input,
+ COLOR_WIN_INPUT_DELIMITERS);
+ wprintw (window->win_input, "%%%s", pos);
+ pos[char_size] = saved_char;
+ pos += char_size;
+ }
+ else
+ {
+ wprintw (window->win_input, "%%");
+ pos++;
+ }
+ break;
+ }
+ break;
+ default:
+ char_size = utf8_char_size (pos);
+ saved_char = pos[char_size];
+ pos[char_size] = '\0';
+ gui_window_set_weechat_color (window->win_input,
+ COLOR_WIN_INPUT_DELIMITERS);
+ wprintw (window->win_input, "%s", pos);
+ pos[char_size] = saved_char;
+ pos += char_size;
+ break;
+ }
+ }
}
/*
@@ -2500,7 +2668,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
t_gui_window *ptr_win;
char format[32];
char *ptr_nickname;
- int input_width;
+ int prompt_length, display_prompt;
t_irc_dcc *dcc_selected;
if (!gui_ok)
@@ -2526,12 +2694,21 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
SERVER(buffer)->nick : SERVER(buffer)->nick1;
else
ptr_nickname = cfg_look_no_nickname;
- input_width = gui_get_input_width (ptr_win, ptr_nickname);
+
+ prompt_length = gui_get_input_prompt_length (ptr_win, ptr_nickname);
+
+ if (ptr_win->win_width - prompt_length < 3)
+ {
+ prompt_length = 0;
+ display_prompt = 0;
+ }
+ else
+ display_prompt = 1;
if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
- input_width)
+ ptr_win->win_width - prompt_length)
buffer->input_buffer_1st_display = buffer->input_buffer_pos -
- input_width + 1;
+ (ptr_win->win_width - prompt_length) + 1;
else
{
if (buffer->input_buffer_pos < buffer->input_buffer_1st_display)
@@ -2540,60 +2717,32 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
{
if ((buffer->input_buffer_1st_display > 0) &&
(buffer->input_buffer_pos -
- buffer->input_buffer_1st_display + 1) < input_width)
+ buffer->input_buffer_1st_display + 1)
+ < ptr_win->win_width - prompt_length)
{
buffer->input_buffer_1st_display =
- buffer->input_buffer_pos - input_width + 1;
+ buffer->input_buffer_pos -
+ (ptr_win->win_width - prompt_length) + 1;
if (buffer->input_buffer_1st_display < 0)
buffer->input_buffer_1st_display = 0;
}
}
}
- if (CHANNEL(buffer))
- {
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
- mvwprintw (ptr_win->win_input, 0, 0, "[");
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_CHANNEL);
- wprintw (ptr_win->win_input, "%s ", CHANNEL(buffer)->name);
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK);
- wprintw (ptr_win->win_input, "%s", ptr_nickname);
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
- wprintw (ptr_win->win_input, "] ");
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
- snprintf (format, 32, "%%-%ds", input_width);
- if (ptr_win == gui_current_window)
- gui_draw_buffer_input_text (ptr_win, input_width);
- else
- wprintw (ptr_win->win_input, format, "");
- wclrtoeol (ptr_win->win_input);
- ptr_win->win_input_x = utf8_strlen (CHANNEL(buffer)->name) +
- utf8_strlen (SERVER(buffer)->nick) + 4 +
- (buffer->input_buffer_pos - buffer->input_buffer_1st_display);
- if (ptr_win == gui_current_window)
- move (ptr_win->win_y + ptr_win->win_height - 1,
- ptr_win->win_x + ptr_win->win_input_x);
- }
+ if (display_prompt)
+ gui_draw_buffer_input_prompt (ptr_win, ptr_nickname);
+
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
+ snprintf (format, 32, "%%-%ds", ptr_win->win_width - prompt_length);
+ if (ptr_win == gui_current_window)
+ gui_draw_buffer_input_text (ptr_win, ptr_win->win_width - prompt_length);
else
- {
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
- mvwprintw (ptr_win->win_input, 0, 0, "[");
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK);
- wprintw (ptr_win->win_input, "%s", ptr_nickname);
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
- wprintw (ptr_win->win_input, "] ");
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
- snprintf (format, 32, "%%-%ds", input_width);
- if (ptr_win == gui_current_window)
- gui_draw_buffer_input_text (ptr_win, input_width);
- else
- wprintw (ptr_win->win_input, format, "");
- wclrtoeol (ptr_win->win_input);
- ptr_win->win_input_x = utf8_strlen (ptr_nickname) + 3 +
- (buffer->input_buffer_pos - buffer->input_buffer_1st_display);
- if (ptr_win == gui_current_window)
- move (ptr_win->win_y + ptr_win->win_height - 1,
- ptr_win->win_x + ptr_win->win_input_x);
- }
+ wprintw (ptr_win->win_input, format, "");
+ wclrtoeol (ptr_win->win_input);
+ ptr_win->win_input_x = prompt_length +
+ (buffer->input_buffer_pos - buffer->input_buffer_1st_display);
+ if (ptr_win == gui_current_window)
+ move (ptr_win->win_y + ptr_win->win_height - 1,
+ ptr_win->win_x + ptr_win->win_input_x);
}
break;
case BUFFER_TYPE_DCC:
@@ -3565,6 +3714,7 @@ gui_init_weechat_colors ()
gui_color[COLOR_WIN_INFOBAR_DELIMITERS] = gui_color_build (COLOR_WIN_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg);
gui_color[COLOR_WIN_INFOBAR_HIGHLIGHT] = gui_color_build (COLOR_WIN_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg);
gui_color[COLOR_WIN_INPUT] = gui_color_build (COLOR_WIN_INPUT, cfg_col_input, cfg_col_input_bg);
+ gui_color[COLOR_WIN_INPUT_SERVER] = gui_color_build (COLOR_WIN_INPUT_SERVER, cfg_col_input_server, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_CHANNEL] = gui_color_build (COLOR_WIN_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_NICK] = gui_color_build (COLOR_WIN_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg);
gui_color[COLOR_WIN_INPUT_DELIMITERS] = gui_color_build (COLOR_WIN_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg);
diff --git a/src/gui/gui.h b/src/gui/gui.h
index e943a100b..5298f45fd 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -91,6 +91,7 @@ enum t_weechat_color
COLOR_DCC_DONE,
COLOR_DCC_FAILED,
COLOR_DCC_ABORTED,
+ COLOR_WIN_INPUT_SERVER,
GUI_NUM_COLORS
};
diff --git a/src/irc/irc-display.c b/src/irc/irc-display.c
index 197f5d45e..8170304d2 100644
--- a/src/irc/irc-display.c
+++ b/src/irc/irc-display.c
@@ -316,14 +316,16 @@ irc_display_away (t_irc_server *server, char *string1, char *string2)
void
irc_display_mode (t_irc_server *server, t_gui_buffer *buffer,
- char *channel_name, char set_flag,
+ char *channel_name, char *nick_name, char set_flag,
char *symbol, char *nick_host, char *message, char *param)
{
irc_display_prefix (server, buffer, PREFIX_INFO);
gui_printf (buffer, "%s[%s%s%s/%s%c%s%s] %s%s",
GUI_COLOR(COLOR_WIN_CHAT_DARK),
- GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
- channel_name,
+ (channel_name) ?
+ GUI_COLOR(COLOR_WIN_CHAT_CHANNEL) :
+ GUI_COLOR(COLOR_WIN_CHAT_NICK),
+ (channel_name) ? channel_name : nick_name,
GUI_COLOR(COLOR_WIN_CHAT),
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
set_flag,
diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c
index b39f95e00..dd0658642 100644
--- a/src/irc/irc-recv.c
+++ b/src/irc/irc-recv.c
@@ -615,9 +615,10 @@ irc_cmd_recv_kill (t_irc_server *server, char *host, char *nick, char *arguments
* irc_get_channel_modes: get channel modes
*/
-void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
+void irc_get_channel_modes (t_irc_server *server, t_irc_channel *channel,
char *channel_name,
- char *nick_host, char *modes, char *parm)
+ char *nick_host, char *modes, char *parm,
+ int no_display)
{
char *pos, set_flag, unknown_mode[3];
t_irc_nick *ptr_nick;
@@ -641,9 +642,10 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "b", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "b", nick_host,
(set_flag == '+') ?
_("sets ban on") :
_("removes ban on"),
@@ -666,9 +668,10 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "d", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "d", nick_host,
(set_flag == '+') ?
_("sets realname ban on") :
_("removes realname ban on"),
@@ -691,11 +694,12 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "e", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "e", nick_host,
(set_flag == '+') ?
- _("sets ban exemtion on") :
+ _("sets ban exemption on") :
_("removes ban exemption on"),
(parm) ? parm : NULL);
@@ -716,9 +720,10 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "f", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "f", nick_host,
(set_flag == '+') ?
_("sets mode +f") :
_("removes mode +f"),
@@ -741,21 +746,22 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "h", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "h", nick_host,
(set_flag == '+') ?
_("gives half channel operator status to") :
_("removes half channel operator status from"),
(parm) ? parm : NULL);
if (parm)
{
- ptr_nick = nick_search (ptr_channel, parm);
+ ptr_nick = nick_search (channel, parm);
if (ptr_nick)
{
NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_HALFOP);
- nick_resort (ptr_channel, ptr_nick);
- gui_draw_buffer_nick (ptr_channel->buffer, 1);
+ nick_resort (channel, ptr_nick);
+ gui_draw_buffer_nick (channel->buffer, 1);
}
}
@@ -769,14 +775,15 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
}
break;
case 'i':
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "i", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "i", nick_host,
(set_flag == '+') ?
_("sets invite-only channel flag") :
_("removes invite-only channel flag"),
NULL);
- CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'),
+ CHANNEL_SET_MODE(channel, (set_flag == '+'),
CHANNEL_MODE_INVITE);
break;
case 'I':
@@ -787,9 +794,10 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "I", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "I", nick_host,
(set_flag == '+') ?
_("sets invite-only exemption on") :
_("removes invite-only exemption on"),
@@ -812,20 +820,21 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "k", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "k", nick_host,
(set_flag == '+') ?
_("sets channel key to") :
_("removes channel key"),
(set_flag == '+') ?
((parm) ? parm : NULL) :
NULL);
- CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'),
+ CHANNEL_SET_MODE(channel, (set_flag == '+'),
CHANNEL_MODE_KEY);
- if (ptr_channel->key)
- free (ptr_channel->key);
- ptr_channel->key = strdup (parm);
+ if (channel->key)
+ free (channel->key);
+ channel->key = strdup (parm);
/* look for next parameter */
if (parm && pos)
@@ -844,18 +853,19 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "l", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "l", nick_host,
(set_flag == '+') ?
_("sets the user limit to") :
_("removes user limit"),
(set_flag == '+') ?
((parm) ? parm : NULL) :
NULL);
- CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'),
+ CHANNEL_SET_MODE(channel, (set_flag == '+'),
CHANNEL_MODE_LIMIT);
- ptr_channel->limit = atoi (parm);
+ channel->limit = atoi (parm);
/* look for next parameter */
if (parm && pos)
@@ -867,25 +877,27 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
}
break;
case 'm':
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "m", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "m", nick_host,
(set_flag == '+') ?
_("sets moderated channel flag") :
_("removes moderated channel flag"),
NULL);
- CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'),
+ CHANNEL_SET_MODE(channel, (set_flag == '+'),
CHANNEL_MODE_MODERATED);
break;
case 'n':
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "n", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "n", nick_host,
(set_flag == '+') ?
_("sets messages from channel only flag") :
_("removes messages from channel only flag"),
NULL);
- CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'),
+ CHANNEL_SET_MODE(channel, (set_flag == '+'),
CHANNEL_MODE_NO_MSG_OUT);
break;
case 'o':
@@ -896,21 +908,22 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "o", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "o", nick_host,
(set_flag == '+') ?
_("gives channel operator status to") :
_("removes channel operator status from"),
(parm) ? parm : NULL);
if (parm)
{
- ptr_nick = nick_search (ptr_channel, parm);
+ ptr_nick = nick_search (channel, parm);
if (ptr_nick)
{
NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_OP);
- nick_resort (ptr_channel, ptr_nick);
- gui_draw_buffer_nick (ptr_channel->buffer, 1);
+ nick_resort (channel, ptr_nick);
+ gui_draw_buffer_nick (channel->buffer, 1);
}
}
@@ -924,14 +937,15 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
}
break;
case 'p':
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "p", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "p", nick_host,
(set_flag == '+') ?
_("sets private channel flag") :
_("removes private channel flag"),
NULL);
- CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'),
+ CHANNEL_SET_MODE(channel, (set_flag == '+'),
CHANNEL_MODE_PRIVATE);
break;
case 'q':
@@ -942,9 +956,10 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "q", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "q", nick_host,
(set_flag == '+') ?
_("sets quiet on") :
_("removes quiet on"),
@@ -960,25 +975,27 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
}
break;
case 's':
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "s", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "s", nick_host,
(set_flag == '+') ?
_("sets secret channel flag") :
_("removes secret channel flag"),
NULL);
- CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'),
+ CHANNEL_SET_MODE(channel, (set_flag == '+'),
CHANNEL_MODE_SECRET);
break;
case 't':
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "t", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "t", nick_host,
(set_flag == '+') ?
_("sets topic protection") :
_("removes topic protection"),
NULL);
- CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'),
+ CHANNEL_SET_MODE(channel, (set_flag == '+'),
CHANNEL_MODE_TOPIC);
break;
case 'v':
@@ -989,9 +1006,10 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, "v", nick_host,
+ if (nick_host && !no_display)
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ "v", nick_host,
(set_flag == '+') ?
_("gives voice to") :
_("removes voice from"),
@@ -999,12 +1017,12 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (parm)
{
- ptr_nick = nick_search (ptr_channel, parm);
+ ptr_nick = nick_search (channel, parm);
if (ptr_nick)
{
NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_VOICE);
- nick_resort (ptr_channel, ptr_nick);
- gui_draw_buffer_nick (ptr_channel->buffer, 1);
+ nick_resort (channel, ptr_nick);
+ gui_draw_buffer_nick (channel->buffer, 1);
}
}
@@ -1025,14 +1043,14 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
if (pos)
pos[0] = '\0';
}
- if (nick_host)
+ if (nick_host && !no_display)
{
unknown_mode[0] = set_flag;
unknown_mode[1] = modes[0];
unknown_mode[2] = '\0';
- irc_display_mode (server, ptr_channel->buffer,
- channel_name, set_flag, unknown_mode + 1,
- nick_host,
+ irc_display_mode (server, channel->buffer,
+ channel_name, NULL, set_flag,
+ unknown_mode + 1, nick_host,
unknown_mode,
(parm) ? parm : NULL);
}
@@ -1052,6 +1070,122 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel,
}
/*
+ * irc_get_nick_modes: get nick modes
+ */
+
+void irc_get_nick_modes (t_irc_server *server,
+ char *nick_host, char *modes, int no_display)
+{
+ char set_flag, unknown_mode[3];
+
+ set_flag = '+';
+ while (modes && modes[0])
+ {
+ switch (modes[0])
+ {
+ case ':':
+ break;
+ case '+':
+ set_flag = '+';
+ break;
+ case '-':
+ set_flag = '-';
+ break;
+ case 'a':
+ if (nick_host && !no_display)
+ irc_display_mode (server, server->buffer,
+ NULL, server->nick, set_flag,
+ "a", nick_host,
+ (set_flag == '+') ?
+ _("sets away") :
+ _("removes away"),
+ NULL);
+ NICK_SET_MODE(server, (set_flag == '+'), NICK_MODE_AWAY);
+ break;
+ case 'i':
+ if (nick_host && !no_display)
+ irc_display_mode (server, server->buffer,
+ NULL, server->nick, set_flag,
+ "i", nick_host,
+ (set_flag == '+') ?
+ _("sets invisible") :
+ _("removes invisible"),
+ NULL);
+ NICK_SET_MODE(server, (set_flag == '+'), NICK_MODE_INVISIBLE);
+ break;
+ case 'w':
+ if (nick_host && !no_display)
+ irc_display_mode (server, server->buffer,
+ NULL, server->nick, set_flag,
+ "w", nick_host,
+ (set_flag == '+') ?
+ _("sets wallops") :
+ _("removes wallops"),
+ NULL);
+ NICK_SET_MODE(server, (set_flag == '+'), NICK_MODE_WALLOPS);
+ break;
+ case 'r':
+ if (nick_host && !no_display)
+ irc_display_mode (server, server->buffer,
+ NULL, server->nick, set_flag,
+ "r", nick_host,
+ (set_flag == '+') ?
+ _("sets restricted") :
+ _("removes restricted"),
+ NULL);
+ NICK_SET_MODE(server, (set_flag == '+'), NICK_MODE_RESTRICTED);
+ break;
+ case 'o':
+ if (nick_host && !no_display)
+ irc_display_mode (server, server->buffer,
+ NULL, server->nick, set_flag,
+ "o", nick_host,
+ (set_flag == '+') ?
+ _("sets operator") :
+ _("removes operator"),
+ NULL);
+ NICK_SET_MODE(server, (set_flag == '+'), NICK_MODE_OPERATOR);
+ break;
+ case 'O':
+ if (nick_host && !no_display)
+ irc_display_mode (server, server->buffer,
+ NULL, server->nick, set_flag,
+ "O", nick_host,
+ (set_flag == '+') ?
+ _("sets local operator") :
+ _("removes local operator"),
+ NULL);
+ NICK_SET_MODE(server, (set_flag == '+'), NICK_MODE_LOCAL_OPERATOR);
+ break;
+ case 's':
+ if (nick_host && !no_display)
+ irc_display_mode (server, server->buffer,
+ NULL, server->nick, set_flag,
+ "s", nick_host,
+ (set_flag == '+') ?
+ _("sets server notices") :
+ _("removes server notices"),
+ NULL);
+ NICK_SET_MODE(server, (set_flag == '+'), NICK_MODE_LOCAL_OPERATOR);
+ break;
+ default: /* unknown mode received */
+ if (nick_host && !no_display)
+ {
+ unknown_mode[0] = set_flag;
+ unknown_mode[1] = modes[0];
+ unknown_mode[2] = '\0';
+ irc_display_mode (server, server->buffer,
+ NULL, server->nick, set_flag,
+ unknown_mode + 1, nick_host,
+ unknown_mode, NULL);
+ }
+ break;
+ }
+ modes++;
+ }
+}
+
+/*
* irc_cmd_recv_mode: 'mode' message received
*/
@@ -1100,8 +1234,9 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *nick, char *arguments
if (ptr_channel)
{
irc_get_channel_modes (server, ptr_channel, arguments, nick,
- pos, pos_parm);
+ pos, pos_parm, command_ignored);
gui_draw_buffer_status (ptr_channel->buffer, 1);
+ gui_draw_buffer_input (ptr_channel->buffer, 1);
}
else
{
@@ -1114,22 +1249,9 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *nick, char *arguments
}
else
{
- /* nickname modes */
- if (!command_ignored)
- {
- irc_display_prefix (server, server->buffer, PREFIX_SERVER);
- gui_printf (server->buffer, _("%s[%s%s%s/%s%s%s]%s mode changed by %s%s\n"),
- GUI_COLOR(COLOR_WIN_CHAT_DARK),
- GUI_COLOR(COLOR_WIN_CHAT_NICK),
- arguments,
- GUI_COLOR(COLOR_WIN_CHAT),
- GUI_COLOR(COLOR_WIN_CHAT_NICK),
- (pos[0] == ':') ? pos + 1 : pos,
- GUI_COLOR(COLOR_WIN_CHAT_DARK),
- GUI_COLOR(COLOR_WIN_CHAT),
- GUI_COLOR(COLOR_WIN_CHAT_NICK),
- nick);
- }
+ irc_get_nick_modes (server, nick, pos, command_ignored);
+ gui_draw_buffer_status (gui_current_window->buffer, 1);
+ gui_draw_buffer_input (gui_current_window->buffer, 1);
}
return 0;
}
@@ -3745,7 +3867,7 @@ irc_cmd_recv_324 (t_irc_server *server, char *host, char *nick, char *arguments)
if (ptr_channel)
{
irc_get_channel_modes (server, ptr_channel, NULL, NULL,
- pos, pos_parm);
+ pos, pos_parm, command_ignored);
gui_draw_buffer_status (ptr_channel->buffer, 0);
}
}
@@ -3837,6 +3959,7 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos, *pos2;
t_irc_channel *ptr_channel;
+ t_gui_buffer *ptr_buffer;
/* make gcc happy */
(void) host;
@@ -3852,39 +3975,33 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *nick, char *arguments)
{
pos2[0] = '\0';
ptr_channel = channel_search (server, pos);
+ ptr_buffer = (ptr_channel) ?
+ ptr_channel->buffer : server->buffer;
+ pos2++;
+ while (pos2[0] == ' ')
+ pos2++;
+ if (pos2[0] == ':')
+ pos2++;
if (ptr_channel)
{
- pos2++;
- while (pos2[0] == ' ')
- pos2++;
- if (pos2[0] == ':')
- pos2++;
if (ptr_channel->topic)
free (ptr_channel->topic);
ptr_channel->topic = strdup (pos2);
-
- command_ignored |= ignore_check (host, "332", ptr_channel->name, server->name);
- if (!command_ignored)
- {
- irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO);
- gui_printf (ptr_channel->buffer, _("Topic for %s%s%s is: "),
- GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
- pos,
- GUI_COLOR(COLOR_WIN_CHAT));
- gui_printf (ptr_channel->buffer, "\"%s\"\n",
- pos2);
- }
-
- gui_draw_buffer_title (ptr_channel->buffer, 1);
}
- else
+
+ command_ignored |= ignore_check (host, "332", pos, server->name);
+ if (!command_ignored)
{
- irc_display_prefix (server, server->buffer, PREFIX_ERROR);
- gui_printf_nolog (server->buffer,
- _("%s channel \"%s\" not found for \"%s\" command\n"),
- WEECHAT_ERROR, pos, "332");
- return -1;
+ irc_display_prefix (server, ptr_buffer, PREFIX_INFO);
+ gui_printf (ptr_buffer, _("Topic for %s%s%s is: "),
+ GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
+ pos,
+ GUI_COLOR(COLOR_WIN_CHAT));
+ gui_printf (ptr_buffer, "\"%s\"\n", pos2);
}
+
+ if (ptr_channel)
+ gui_draw_buffer_title (ptr_buffer, 1);
}
}
else
@@ -3907,6 +4024,7 @@ irc_cmd_recv_333 (t_irc_server *server, char *host, char *nick, char *arguments)
{
char *pos_channel, *pos_nick, *pos_date;
t_irc_channel *ptr_channel;
+ t_gui_buffer *ptr_buffer;
time_t datetime;
/* make gcc happy */
@@ -3934,27 +4052,20 @@ irc_cmd_recv_333 (t_irc_server *server, char *host, char *nick, char *arguments)
pos_date++;
ptr_channel = channel_search (server, pos_channel);
- if (ptr_channel)
- {
- command_ignored |= ignore_check (host, "333", ptr_channel->name, server->name);
- if (!command_ignored)
- {
- datetime = (time_t)(atol (pos_date));
- irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO);
- gui_printf (ptr_channel->buffer, _("Topic set by %s%s%s, %s"),
- GUI_COLOR(COLOR_WIN_CHAT_NICK),
- pos_nick,
- GUI_COLOR(COLOR_WIN_CHAT),
- ctime (&datetime));
- }
- }
- else
+ ptr_buffer = (ptr_channel) ?
+ ptr_channel->buffer : server->buffer;
+
+ command_ignored |= ignore_check (host, "333",
+ pos_channel, server->name);
+ if (!command_ignored)
{
- irc_display_prefix (server, server->buffer, PREFIX_ERROR);
- gui_printf_nolog (server->buffer,
- _("%s channel \"%s\" not found for \"%s\" command\n"),
- WEECHAT_ERROR, pos_channel, "333");
- return -1;
+ datetime = (time_t)(atol (pos_date));
+ irc_display_prefix (server, ptr_buffer, PREFIX_INFO);
+ gui_printf (ptr_buffer, _("Topic set by %s%s%s, %s"),
+ GUI_COLOR(COLOR_WIN_CHAT_NICK),
+ pos_nick,
+ GUI_COLOR(COLOR_WIN_CHAT),
+ ctime (&datetime));
}
}
else
diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c
index 7a003d673..dee0dcd37 100644
--- a/src/irc/irc-server.c
+++ b/src/irc/irc-server.c
@@ -56,6 +56,9 @@ t_irc_message *recv_msgq, *msgq_last_msg;
int check_away = 0;
+char *nick_modes = "aiwroOs";
+
+
/*
* server_init: init server struct with default values
*/
@@ -98,6 +101,9 @@ server_init (t_irc_server *server)
server->ssl_connected = 0;
server->unterminated_message = NULL;
server->nick = NULL;
+ server->nick_modes = (char *) malloc (NUM_NICK_MODES + 1);
+ memset (server->nick_modes, ' ', NUM_NICK_MODES);
+ server->nick_modes[NUM_NICK_MODES] = '\0';
server->reconnect_start = 0;
server->reconnect_join = 0;
server->is_away = 0;
@@ -311,6 +317,8 @@ server_destroy (t_irc_server *server)
free (server->unterminated_message);
if (server->nick)
free (server->nick);
+ if (server->nick_modes)
+ free (server->nick_modes);
if (server->channels)
channel_free_all (server);
}
@@ -1179,7 +1187,7 @@ resolve (char *hostname, char *ip, int *version)
*/
int
-pass_socks4proxy(int sock, char *address, int port, char *username)
+pass_socks4proxy (int sock, char *address, int port, char *username)
{
/*
* socks4 protocol is explain here:
@@ -1366,13 +1374,13 @@ pass_socks5proxy(int sock, char *address, int port)
*/
int
-pass_proxy(int sock, char *address, int port, char *username)
+pass_proxy (int sock, char *address, int port, char *username)
{
- if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "http") == 0)
+ if (strcmp (cfg_proxy_type_values[cfg_proxy_type], "http") == 0)
return pass_httpproxy(sock, address, port);
- if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks4") == 0)
+ if (strcmp (cfg_proxy_type_values[cfg_proxy_type], "socks4") == 0)
return pass_socks4proxy(sock, address, port, username);
- if (strcmp(cfg_proxy_type_values[cfg_proxy_type], "socks5") == 0)
+ if (strcmp (cfg_proxy_type_values[cfg_proxy_type], "socks5") == 0)
return pass_socks5proxy(sock, address, port);
return 1;
@@ -1683,6 +1691,11 @@ server_disconnect (t_irc_server *server, int reconnect)
gui_printf (server->buffer, _("Disconnected from server!\n"));
}
+ if (server->nick_modes)
+ {
+ memset (server->nick_modes, ' ', NUM_NICK_MODES);
+ server->nick_modes[NUM_NICK_MODES] = '\0';
+ }
server->is_away = 0;
server->away_time = 0;
server->lag = 0;
diff --git a/src/irc/irc.h b/src/irc/irc.h
index 2b2b00959..906d5b08b 100644
--- a/src/irc/irc.h
+++ b/src/irc/irc.h
@@ -125,6 +125,20 @@ struct t_irc_channel
/* server types */
+#define NUM_NICK_MODES 7
+#define NICK_MODE_AWAY 0
+#define NICK_MODE_INVISIBLE 1
+#define NICK_MODE_WALLOPS 2
+#define NICK_MODE_RESTRICTED 3
+#define NICK_MODE_OPERATOR 4
+#define NICK_MODE_LOCAL_OPERATOR 5
+#define NICK_MODE_SERVER_NOTICES 6
+#define NICK_SET_MODE(server, set, mode) \
+ if (set) \
+ server->nick_modes[mode] = nick_modes[mode]; \
+ else \
+ server->nick_modes[mode] = ' ';
+
typedef struct t_irc_server t_irc_server;
struct t_irc_server
@@ -167,6 +181,7 @@ struct t_irc_server
#endif
char *unterminated_message; /* beginning of a message in input buf */
char *nick; /* current nickname */
+ char *nick_modes; /* nick modes */
time_t reconnect_start; /* this time + delay = reconnect time */
int reconnect_join; /* 1 if channels opened to rejoin */
int is_away; /* 1 is user is marker as away */
@@ -301,6 +316,7 @@ extern int check_away;
extern t_irc_dcc *dcc_list;
extern char *dcc_status_string[6];
extern char *channel_modes;
+extern char *nick_modes;
extern char *ignore_types[];
extern t_irc_ignore *irc_ignore;
extern t_irc_ignore *irc_last_ignore;
@@ -408,8 +424,8 @@ extern void irc_display_prefix (t_irc_server *, t_gui_buffer *, char *);
extern void irc_display_nick (t_gui_buffer *, t_irc_nick *, char *, int,
int, int, int);
extern void irc_display_away (t_irc_server *, char *, char *);
-extern void irc_display_mode (t_irc_server *, t_gui_buffer *, char *, char,
- char *, char *, char *, char *);
+extern void irc_display_mode (t_irc_server *, t_gui_buffer *, char *, char *,
+ char, char *, char *, char *, char *);
extern void irc_display_server (t_irc_server *ptr_server);
/* IRC commands issued by user (irc-send.c) */