diff options
author | LemonBoy <thatlemon@gmail.com> | 2016-06-12 15:26:07 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2016-06-12 16:18:33 +0200 |
commit | bf9d9494db89e7de45653e4797e2977c6e185c13 (patch) | |
tree | d094d950dc2c94bdaf041e38da063a4ccfd651a1 /src/fe-common | |
parent | 0fad2cd8427a35f6b2de46fa8bd38437b9695495 (diff) | |
download | irssi-bf9d9494db89e7de45653e4797e2977c6e185c13.zip |
Add a CHOICE type to the settings system.
This is useful to let the user choose an option between a finite set of
valid alternatives.
Diffstat (limited to 'src/fe-common')
-rw-r--r-- | src/fe-common/core/completion.c | 17 | ||||
-rw-r--r-- | src/fe-common/core/fe-settings.c | 5 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 861054b5..0e9982d5 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -690,9 +690,20 @@ static void sig_complete_set(GList **list, WINDOW_REC *window, else if (*line != '\0' && *word == '\0') { SETTINGS_REC *rec = settings_get_record(line); if (rec != NULL) { - char *value = settings_get_print(rec); - if (value != NULL) - *list = g_list_append(*list, value); + /* show the whole list of valid options */ + if (rec->type == SETTING_TYPE_CHOICE) { + char **tmp = rec->choices; + + while (*tmp) + *list = g_list_append(*list, g_strdup(*tmp++)); + } + /* show the current option */ + else { + char *value = settings_get_print(rec); + + if (value != NULL) + *list = g_list_append(*list, value); + } } } diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index b689cbf9..e25886ec 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -142,6 +142,11 @@ static void cmd_set(char *data) else set_int(key, value); break; + case SETTING_TYPE_CHOICE: + settings_set_choice(key, clear ? "" : + set_default ? rec->choices[rec->default_value.v_int] : + value); + break; case SETTING_TYPE_STRING: settings_set_str(key, clear ? "" : set_default ? rec->default_value.v_string : |