summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/gui/curses/gui-display.c24
-rw-r--r--src/irc/irc-commands.c2
-rw-r--r--src/irc/irc-send.c33
-rw-r--r--weechat/ChangeLog1
-rw-r--r--weechat/src/gui/curses/gui-display.c24
-rw-r--r--weechat/src/irc/irc-commands.c2
-rw-r--r--weechat/src/irc/irc-send.c33
8 files changed, 84 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index 879ce839b..01ac1fbad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ ChangeLog - 2005-11-29
Version 0.1.7 (under dev!):
+ * /nick command is now allowed when not connected to server
* added server/channel arg to /buffer command for jumping to buffer
* fixed display bug in chat window when a message length equals to window
width
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index 413e3b96a..fe077972c 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -2332,18 +2332,13 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
*/
int
-gui_get_input_width (t_gui_window *window)
+gui_get_input_width (t_gui_window *window, char *nick)
{
if (CHANNEL(window->buffer))
return (window->win_width - strlen (CHANNEL(window->buffer)->name) -
- strlen (SERVER(window->buffer)->nick) - 4);
+ strlen (nick) - 4);
else
- {
- if (SERVER(window->buffer) && (SERVER(window->buffer)->is_connected))
- return (window->win_width - strlen (SERVER(window->buffer)->nick) - 3);
- else
- return (window->win_width - strlen (cfg_look_no_nickname) - 3);
- }
+ return (window->win_width - strlen (nick) - 3);
}
/*
@@ -2406,7 +2401,12 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
if (buffer->input_buffer_length == 0)
buffer->input_buffer[0] = '\0';
- input_width = gui_get_input_width (ptr_win);
+ if (SERVER(buffer))
+ ptr_nickname = (SERVER(buffer)->nick) ?
+ SERVER(buffer)->nick : SERVER(buffer)->nick1;
+ else
+ ptr_nickname = cfg_look_no_nickname;
+ input_width = gui_get_input_width (ptr_win, ptr_nickname);
if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
input_width)
@@ -2436,7 +2436,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
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", SERVER(buffer)->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);
@@ -2461,10 +2461,6 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
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);
- if (SERVER(buffer) && (SERVER(buffer)->is_connected))
- ptr_nickname = SERVER(buffer)->nick;
- else
- ptr_nickname = cfg_look_no_nickname;
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, "] ");
diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c
index f994d2262..c14a096c9 100644
--- a/src/irc/irc-commands.c
+++ b/src/irc/irc-commands.c
@@ -174,7 +174,7 @@ t_irc_command irc_commands[] =
N_("[-all] nickname"),
N_("-all: set new nickname for all connected servers\n"
"nickname: new nickname"),
- 1, 2, 1, irc_cmd_send_nick, NULL, irc_cmd_recv_nick },
+ 1, 2, 0, irc_cmd_send_nick, NULL, irc_cmd_recv_nick },
{ "notice", N_("send notice message to user"),
N_("nickname text"), N_("nickname: user to send notice to\ntext: text to send"),
2, MAX_ARGS, 1, NULL, irc_cmd_send_notice, irc_cmd_recv_notice },
diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c
index aaf319e78..a0bee886b 100644
--- a/src/irc/irc-send.c
+++ b/src/irc/irc-send.c
@@ -1214,6 +1214,31 @@ irc_cmd_send_names (t_irc_server *server, char *arguments)
}
/*
+ * irc_cmd_send_nick_server: change nickname on a server
+ */
+
+void
+irc_cmd_send_nick_server (t_irc_server *server, char *nickname)
+{
+ t_irc_channel *ptr_channel;
+
+ if (server->is_connected)
+ server_sendf (server, "NICK %s\r\n", nickname);
+ else
+ {
+ if (server->nick)
+ free (server->nick);
+ server->nick = strdup (nickname);
+ gui_draw_buffer_input (server->buffer, 1);
+ for (ptr_channel = server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
+ {
+ gui_draw_buffer_input (ptr_channel->buffer, 1);
+ }
+ }
+}
+
+/*
* irc_cmd_send_nick: change nickname
*/
@@ -1222,6 +1247,9 @@ irc_cmd_send_nick (t_irc_server *server, int argc, char **argv)
{
t_irc_server *ptr_server;
+ if (!server)
+ return 0;
+
if (argc == 2)
{
if (strncmp (argv[0], "-all", 4) != 0)
@@ -1230,14 +1258,13 @@ irc_cmd_send_nick (t_irc_server *server, int argc, char **argv)
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- if (ptr_server->is_connected)
- server_sendf (ptr_server, "NICK %s\r\n", argv[1]);
+ irc_cmd_send_nick_server (ptr_server, argv[1]);
}
}
else
{
if (argc == 1)
- server_sendf (server, "NICK %s\r\n", argv[0]);
+ irc_cmd_send_nick_server (server, argv[0]);
else
return -1;
}
diff --git a/weechat/ChangeLog b/weechat/ChangeLog
index 879ce839b..01ac1fbad 100644
--- a/weechat/ChangeLog
+++ b/weechat/ChangeLog
@@ -5,6 +5,7 @@ ChangeLog - 2005-11-29
Version 0.1.7 (under dev!):
+ * /nick command is now allowed when not connected to server
* added server/channel arg to /buffer command for jumping to buffer
* fixed display bug in chat window when a message length equals to window
width
diff --git a/weechat/src/gui/curses/gui-display.c b/weechat/src/gui/curses/gui-display.c
index 413e3b96a..fe077972c 100644
--- a/weechat/src/gui/curses/gui-display.c
+++ b/weechat/src/gui/curses/gui-display.c
@@ -2332,18 +2332,13 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
*/
int
-gui_get_input_width (t_gui_window *window)
+gui_get_input_width (t_gui_window *window, char *nick)
{
if (CHANNEL(window->buffer))
return (window->win_width - strlen (CHANNEL(window->buffer)->name) -
- strlen (SERVER(window->buffer)->nick) - 4);
+ strlen (nick) - 4);
else
- {
- if (SERVER(window->buffer) && (SERVER(window->buffer)->is_connected))
- return (window->win_width - strlen (SERVER(window->buffer)->nick) - 3);
- else
- return (window->win_width - strlen (cfg_look_no_nickname) - 3);
- }
+ return (window->win_width - strlen (nick) - 3);
}
/*
@@ -2406,7 +2401,12 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
if (buffer->input_buffer_length == 0)
buffer->input_buffer[0] = '\0';
- input_width = gui_get_input_width (ptr_win);
+ if (SERVER(buffer))
+ ptr_nickname = (SERVER(buffer)->nick) ?
+ SERVER(buffer)->nick : SERVER(buffer)->nick1;
+ else
+ ptr_nickname = cfg_look_no_nickname;
+ input_width = gui_get_input_width (ptr_win, ptr_nickname);
if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
input_width)
@@ -2436,7 +2436,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
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", SERVER(buffer)->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);
@@ -2461,10 +2461,6 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
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);
- if (SERVER(buffer) && (SERVER(buffer)->is_connected))
- ptr_nickname = SERVER(buffer)->nick;
- else
- ptr_nickname = cfg_look_no_nickname;
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, "] ");
diff --git a/weechat/src/irc/irc-commands.c b/weechat/src/irc/irc-commands.c
index f994d2262..c14a096c9 100644
--- a/weechat/src/irc/irc-commands.c
+++ b/weechat/src/irc/irc-commands.c
@@ -174,7 +174,7 @@ t_irc_command irc_commands[] =
N_("[-all] nickname"),
N_("-all: set new nickname for all connected servers\n"
"nickname: new nickname"),
- 1, 2, 1, irc_cmd_send_nick, NULL, irc_cmd_recv_nick },
+ 1, 2, 0, irc_cmd_send_nick, NULL, irc_cmd_recv_nick },
{ "notice", N_("send notice message to user"),
N_("nickname text"), N_("nickname: user to send notice to\ntext: text to send"),
2, MAX_ARGS, 1, NULL, irc_cmd_send_notice, irc_cmd_recv_notice },
diff --git a/weechat/src/irc/irc-send.c b/weechat/src/irc/irc-send.c
index aaf319e78..a0bee886b 100644
--- a/weechat/src/irc/irc-send.c
+++ b/weechat/src/irc/irc-send.c
@@ -1214,6 +1214,31 @@ irc_cmd_send_names (t_irc_server *server, char *arguments)
}
/*
+ * irc_cmd_send_nick_server: change nickname on a server
+ */
+
+void
+irc_cmd_send_nick_server (t_irc_server *server, char *nickname)
+{
+ t_irc_channel *ptr_channel;
+
+ if (server->is_connected)
+ server_sendf (server, "NICK %s\r\n", nickname);
+ else
+ {
+ if (server->nick)
+ free (server->nick);
+ server->nick = strdup (nickname);
+ gui_draw_buffer_input (server->buffer, 1);
+ for (ptr_channel = server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
+ {
+ gui_draw_buffer_input (ptr_channel->buffer, 1);
+ }
+ }
+}
+
+/*
* irc_cmd_send_nick: change nickname
*/
@@ -1222,6 +1247,9 @@ irc_cmd_send_nick (t_irc_server *server, int argc, char **argv)
{
t_irc_server *ptr_server;
+ if (!server)
+ return 0;
+
if (argc == 2)
{
if (strncmp (argv[0], "-all", 4) != 0)
@@ -1230,14 +1258,13 @@ irc_cmd_send_nick (t_irc_server *server, int argc, char **argv)
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- if (ptr_server->is_connected)
- server_sendf (ptr_server, "NICK %s\r\n", argv[1]);
+ irc_cmd_send_nick_server (ptr_server, argv[1]);
}
}
else
{
if (argc == 1)
- server_sendf (server, "NICK %s\r\n", argv[0]);
+ irc_cmd_send_nick_server (server, argv[0]);
else
return -1;
}