diff options
author | Timo Sirainen <cras@irssi.org> | 2000-06-10 23:40:47 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-06-10 23:40:47 +0000 |
commit | 08af8081d089bbedc2add1cc422ad4f7a38b210c (patch) | |
tree | aaf0193bdb56a520c7272a7c946dd57baf1238da | |
parent | 89b47010b3ce85a3fb4ba7d5d94ac7c6d7271e7f (diff) | |
download | irssi-08af8081d089bbedc2add1cc422ad4f7a38b210c.zip |
if command is unknown, and cmdchar is found inside the command name, we
probably want to send the whole line to channel. for example when
pasting a path /usr/bin/xxx
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@318 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | src/fe-common/core/fe-core-commands.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/fe-common/core/fe-core-commands.c b/src/fe-common/core/fe-core-commands.c index 96ae568c..4de1ae6a 100644 --- a/src/fe-common/core/fe-core-commands.c +++ b/src/fe-common/core/fe-core-commands.c @@ -25,6 +25,7 @@ #include "levels.h" #include "misc.h" #include "line-split.h" +#include "settings.h" #include "irssi-version.h" #include "windows.h" @@ -39,6 +40,11 @@ static const char *ret_texts[] = { "Doing this is not a good idea. Add -YES if you really mean it", }; +/* keep the whole command line here temporarily. we need it in + "default command" event handler, but there we don't know if the start of + the line had one or two command chars, and which one.. */ +static const char *current_cmdline; + static int commands_compare(COMMAND_REC *rec, COMMAND_REC *rec2) { if (rec->category == NULL && rec2->category != NULL) @@ -271,6 +277,30 @@ static void cmd_unknown(const char *data, void *server, WI_ITEM_REC *item) signal_stop(); } +static void event_command(const char *data) +{ + current_cmdline = data; +} + +static void event_default_command(const char *data, void *server, WI_ITEM_REC *item) +{ + const char *cmd; + + cmd = data; + while (*cmd != '\0' && *cmd != ' ') { + if (strchr(settings_get_str("cmdchars"), *cmd)) { + /* command character inside command .. we probably + want to send this text to channel. for example + when pasting a path /usr/bin/xxx. */ + signal_emit("send text", 3, current_cmdline, server, item); + return; + } + cmd++; + } + + cmd_unknown(data, server, item); +} + static void event_cmderror(gpointer errorp) { int error; @@ -291,7 +321,8 @@ void fe_core_commands_init(void) command_bind("beep", NULL, (SIGNAL_FUNC) cmd_beep); signal_add("unknown command", (SIGNAL_FUNC) cmd_unknown); - signal_add("default command", (SIGNAL_FUNC) cmd_unknown); + signal_add("send command", (SIGNAL_FUNC) event_command); + signal_add("default command", (SIGNAL_FUNC) event_default_command); signal_add("error command", (SIGNAL_FUNC) event_cmderror); } @@ -304,6 +335,7 @@ void fe_core_commands_deinit(void) command_unbind("beep", (SIGNAL_FUNC) cmd_beep); signal_remove("unknown command", (SIGNAL_FUNC) cmd_unknown); - signal_remove("default command", (SIGNAL_FUNC) cmd_unknown); + signal_remove("send command", (SIGNAL_FUNC) event_command); + signal_remove("default command", (SIGNAL_FUNC) event_default_command); signal_remove("error command", (SIGNAL_FUNC) event_cmderror); } |