summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-input.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-02-20 16:54:58 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-02-20 16:54:58 +0100
commit94764208e42c919a322c24a2a53d25a68afc92ee (patch)
tree1c4f81f8fde9c4ec7d441ed1a24f35ba8e4c321d /src/plugins/irc/irc-input.c
parentb523613e7385ae1475234451e9c45aea96e33ad0 (diff)
downloadweechat-94764208e42c919a322c24a2a53d25a68afc92ee.zip
Allow input "q" to close IRC raw buffer
Diffstat (limited to 'src/plugins/irc/irc-input.c')
-rw-r--r--src/plugins/irc/irc-input.c67
1 files changed, 38 insertions, 29 deletions
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index 2d75c1f41..ba3ce319e 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -31,6 +31,7 @@
#include "irc-color.h"
#include "irc-config.h"
#include "irc-protocol.h"
+#include "irc-raw.h"
/*
@@ -146,44 +147,52 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer,
const char *ptr_data;
char *data_with_colors, *msg;
+ IRC_GET_SERVER_CHANNEL(buffer);
+
/* make C compiler happy */
(void) data;
- IRC_GET_SERVER_CHANNEL(buffer);
-
- /* if send unknown commands is enabled and that input data is a command,
- then send this command to IRC server */
- if (weechat_config_boolean (irc_config_network_send_unknown_commands)
- && (input_data[0] == '/') && (input_data[1] != '/'))
+ if (buffer == irc_raw_buffer)
{
- if (ptr_server)
- irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
- input_data + 1);
- return WEECHAT_RC_OK;
+ if (weechat_strcasecmp (input_data, "q") == 0)
+ weechat_buffer_close (buffer);
}
-
- if (ptr_channel)
+ else
{
- ptr_data = ((input_data[0] == '/') && (input_data[1] == '/')) ?
- input_data + 1 : input_data;
- data_with_colors = irc_color_encode (ptr_data,
- weechat_config_boolean (irc_config_network_colors_send));
-
- msg = strdup ((data_with_colors) ? data_with_colors : ptr_data);
- if (msg)
+ /* if send unknown commands is enabled and that input data is a command,
+ then send this command to IRC server */
+ if (weechat_config_boolean (irc_config_network_send_unknown_commands)
+ && (input_data[0] == '/') && (input_data[1] != '/'))
{
- irc_input_send_user_message (buffer, msg);
- free (msg);
+ if (ptr_server)
+ irc_server_sendf (ptr_server, IRC_SERVER_OUTQUEUE_PRIO_HIGH,
+ input_data + 1);
+ return WEECHAT_RC_OK;
}
- if (data_with_colors)
- free (data_with_colors);
- }
- else
- {
- weechat_printf (buffer,
- _("%s%s: this buffer is not a channel!"),
- weechat_prefix ("error"), IRC_PLUGIN_NAME);
+ if (ptr_channel)
+ {
+ ptr_data = ((input_data[0] == '/') && (input_data[1] == '/')) ?
+ input_data + 1 : input_data;
+ data_with_colors = irc_color_encode (ptr_data,
+ weechat_config_boolean (irc_config_network_colors_send));
+
+ msg = strdup ((data_with_colors) ? data_with_colors : ptr_data);
+ if (msg)
+ {
+ irc_input_send_user_message (buffer, msg);
+ free (msg);
+ }
+
+ if (data_with_colors)
+ free (data_with_colors);
+ }
+ else
+ {
+ weechat_printf (buffer,
+ _("%s%s: this buffer is not a channel!"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME);
+ }
}
return WEECHAT_RC_OK;