diff options
author | Timo Sirainen <cras@irssi.org> | 2000-06-18 01:18:12 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-06-18 01:18:12 +0000 |
commit | a5d31a195d1e3b682cd57d88a5db7ef0ffa5d492 (patch) | |
tree | e5c335b77da2d17293e87debeb17ab4c966e34c4 /src/fe-common/core/hilight-text.c | |
parent | ca4226cca692ee96109a46b3a1d381ac0d37cb6f (diff) | |
download | irssi-a5d31a195d1e3b682cd57d88a5db7ef0ffa5d492.zip |
Changed option handling in /commands. Irssi will now complain about
unknown options and missing option arguments.
Renamed /SERVER -add, -remove and -list to /SERVER ADD, REMOVE and LIST.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@365 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core/hilight-text.c')
-rw-r--r-- | src/fe-common/core/hilight-text.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index f78d8904..d2da11cd 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -268,9 +268,11 @@ static void cmd_hilight_show(void) static void cmd_hilight(const char *data) { /* /HILIGHT [-nick | -regexp | -word] [-color <color>] [-level <level>] [-channels <channels>] <text> */ - char *params, *args, *colorarg, *levelarg, *chanarg, *text; - char **channels; + GHashTable *optlist; HILIGHT_REC *rec; + char *colorarg, *levelarg, *chanarg, *text; + char **channels; + void *free_arg; g_return_if_fail(data != NULL); @@ -279,12 +281,17 @@ static void cmd_hilight(const char *data) return; } - args = "color level channels"; - params = cmd_get_params(data, 5 | PARAM_FLAG_MULTIARGS | PARAM_FLAG_GETREST, - &args, &colorarg, &levelarg, &chanarg, &text); + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | + PARAM_FLAG_GETREST, "hilight", &optlist, &text)) + return; + + chanarg = g_hash_table_lookup(optlist, "channels"); + levelarg = g_hash_table_lookup(optlist, "level"); + colorarg = g_hash_table_lookup(optlist, "color"); + if (*text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - channels = *chanarg == '\0' ? NULL : + channels = (chanarg == NULL || *chanarg == '\0') ? NULL : g_strsplit(replace_chars(chanarg, ',', ' '), " ", -1); rec = hilight_find(text, channels); @@ -302,17 +309,19 @@ static void cmd_hilight(const char *data) } hilights = g_slist_append(hilights, rec); - rec->nickmask = stristr(args, "-nick") != NULL; - rec->fullword = stristr(args, "-word") != NULL; - rec->regexp = stristr(args, "-regexp") != NULL; + rec->nickmask = g_hash_table_lookup(optlist, "nick") != NULL; + rec->fullword = g_hash_table_lookup(optlist, "word") != NULL; + rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL; - rec->level = level2bits(replace_chars(levelarg, ',', ' ')); - if (*colorarg != '\0') rec->color = g_strdup(colorarg); + rec->level = (levelarg == NULL || *levelarg == '\0') ? 0 : + level2bits(replace_chars(levelarg, ',', ' ')); + if (colorarg != NULL && *colorarg != '\0') + rec->color = g_strdup(colorarg); hilight_print(g_slist_index(hilights, rec)+1, rec); hilight_add_config(rec); - g_free(params); + cmd_params_free(free_arg); } static void cmd_dehilight(const char *data) @@ -349,6 +358,8 @@ void hilight_text_init(void) signal_add("setup reread", (SIGNAL_FUNC) read_hilight_config); command_bind("hilight", NULL, (SIGNAL_FUNC) cmd_hilight); command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight); + + command_set_options("hilight", "-color -level -channels nick word regexp"); } void hilight_text_deinit(void) |