diff options
author | Timo Sirainen <cras@irssi.org> | 2000-11-26 03:52:23 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-11-26 03:52:23 +0000 |
commit | 8c02aa15b483d3769aa9cd9814b65ca756da5f1b (patch) | |
tree | a63e4bafe0460b6837f5578dbc569d6a922c2cfc /src | |
parent | 504dedeb4e29806248a3ab5514e676801527db22 (diff) | |
download | irssi-8c02aa15b483d3769aa9cd9814b65ca756da5f1b.zip |
Added -current, -window and -level options to /echo
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@879 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/core/fe-core-commands.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/fe-common/core/fe-core-commands.c b/src/fe-common/core/fe-core-commands.c index 6b3bfc90..8885e94a 100644 --- a/src/fe-common/core/fe-core-commands.c +++ b/src/fe-common/core/fe-core-commands.c @@ -252,9 +252,32 @@ static void cmd_help(const char *data) /* SYNTAX: ECHO [<text>] */ static void cmd_echo(const char *data, void *server, WI_ITEM_REC *item) { + WINDOW_REC *window; + GHashTable *optlist; + char *msg, *levelstr, *winname; + void *free_arg; + int level; + g_return_if_fail(data != NULL); - printtext_window(active_win, MSGLEVEL_CRAP, "%s", data); + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | + PARAM_FLAG_GETREST, "echo", &optlist, &msg)) + return; + + levelstr = g_hash_table_lookup(optlist, "level"); + level = levelstr == NULL ? 0 : + level2bits(g_hash_table_lookup(optlist, "level")); + if (level == 0) level = MSGLEVEL_CRAP; + + winname = g_hash_table_lookup(optlist, "window"); + window = winname == NULL ? NULL : + is_numeric(winname, '\0') ? + window_find_refnum(atoi(winname)) : + window_find_item(NULL, winname); + if (window == NULL) window = active_win; + + printtext_window(window, level, "%s", msg); + cmd_params_free(free_arg); } /* SYNTAX: VERSION */ @@ -455,6 +478,8 @@ void fe_core_commands_init(void) 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); + + command_set_options("echo", "current +level +window"); } void fe_core_commands_deinit(void) |