diff options
author | Timo Sirainen <cras@irssi.org> | 2000-07-02 17:57:10 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-07-02 17:57:10 +0000 |
commit | b9cfabc419ab3424f09983d67ae17cfa68bb988f (patch) | |
tree | 8bbdd99c13331a73d00d76d01a2ae7c3fb509c09 /src/fe-common/core | |
parent | c451c94c6838223e7476104b3c52924eff9b9924 (diff) | |
download | irssi-b9cfabc419ab3424f09983d67ae17cfa68bb988f.zip |
/^command hides the output of the command, it's not written to log
either. Good for sending passwords for example.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@416 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core')
-rw-r--r-- | src/fe-common/core/fe-core-commands.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/fe-common/core/fe-core-commands.c b/src/fe-common/core/fe-core-commands.c index b1edbf78..39580adf 100644 --- a/src/fe-common/core/fe-core-commands.c +++ b/src/fe-common/core/fe-core-commands.c @@ -49,6 +49,7 @@ static int ret_texts[] = { "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 hide_output; static int commands_compare(COMMAND_REC *rec, COMMAND_REC *rec2) { @@ -274,9 +275,33 @@ static void cmd_beep(void) printbeep(); } +static void sig_stop(void) +{ + signal_stop(); +} + static void event_command(const char *data) { - current_cmdline = data; + const char *cmdchar; + + current_cmdline = data; + + cmdchar = strchr(settings_get_str("cmdchars"), *data); + if (cmdchar != NULL && (data[1] == '^' || (data[1] == *cmdchar && data[2] == '^'))) { + /* /^command hides the output of the command */ + hide_output = TRUE; + signal_add_first("print text stripped", (SIGNAL_FUNC) sig_stop); + signal_add_first("print text", (SIGNAL_FUNC) sig_stop); + } +} + +static void event_command_last(const char *data) +{ + if (hide_output) { + hide_output = FALSE; + signal_remove("print text stripped", (SIGNAL_FUNC) sig_stop); + signal_remove("print text", (SIGNAL_FUNC) sig_stop); + } } static void event_default_command(const char *data, void *server, WI_ITEM_REC *item) @@ -321,6 +346,8 @@ static void event_cmderror(gpointer errorp, const char *arg) void fe_core_commands_init(void) { + hide_output = FALSE; + command_bind("help", NULL, (SIGNAL_FUNC) cmd_help); command_bind("echo", NULL, (SIGNAL_FUNC) cmd_echo); command_bind("version", NULL, (SIGNAL_FUNC) cmd_version); @@ -328,6 +355,7 @@ void fe_core_commands_init(void) command_bind("beep", NULL, (SIGNAL_FUNC) cmd_beep); signal_add("send command", (SIGNAL_FUNC) event_command); + signal_add_last("send command", (SIGNAL_FUNC) event_command_last); signal_add("default command", (SIGNAL_FUNC) event_default_command); signal_add("error command", (SIGNAL_FUNC) event_cmderror); } @@ -341,6 +369,7 @@ void fe_core_commands_deinit(void) command_unbind("beep", (SIGNAL_FUNC) cmd_beep); signal_remove("send command", (SIGNAL_FUNC) event_command); + signal_remove("send command", (SIGNAL_FUNC) event_command_last); signal_remove("default command", (SIGNAL_FUNC) event_default_command); signal_remove("error command", (SIGNAL_FUNC) event_cmderror); } |