diff options
author | James Booth <boothj5@gmail.com> | 2012-10-22 22:15:06 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-22 22:15:06 +0100 |
commit | f9b4abe3dabd3384524e4506124dce4e9cec6814 (patch) | |
tree | d73cf164bedf7d685f2fde1138424c7270c91378 | |
parent | 57f0a407993bf46070e6bb844eb0fd88c648574f (diff) | |
download | profani-tty-f9b4abe3dabd3384524e4506124dce4e9cec6814.tar.gz |
Added autocomplete for boolean settings
-rw-r--r-- | src/input_win.c | 24 | ||||
-rw-r--r-- | src/preferences.c | 33 | ||||
-rw-r--r-- | src/preferences.h | 2 |
3 files changed, 48 insertions, 11 deletions
diff --git a/src/input_win.c b/src/input_win.c index 403dc9e6..107d6985 100644 --- a/src/input_win.c +++ b/src/input_win.c @@ -166,6 +166,7 @@ inp_get_char(int *ch, char *input, int *size) contact_list_reset_search_attempts(); prefs_reset_login_search(); + prefs_reset_boolean_choice(); cmd_help_reset_completer(); cmd_reset_completer(); } @@ -340,9 +341,26 @@ _handle_edit(const int ch, char *input, int *size) } } - _parameter_autocomplete(input, size, "/msg", contact_list_find_contact); - _parameter_autocomplete(input, size, "/connect", prefs_find_login); - _parameter_autocomplete(input, size, "/help", cmd_help_complete); + _parameter_autocomplete(input, size, "/msg", + contact_list_find_contact); + _parameter_autocomplete(input, size, "/connect", + prefs_find_login); + _parameter_autocomplete(input, size, "/help", + cmd_help_complete); + _parameter_autocomplete(input, size, "/beep", + prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/notify", + prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/typing", + prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/flash", + prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/showsplash", + prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/chlog", + prefs_autocomplete_boolean_choice); + _parameter_autocomplete(input, size, "/history", + prefs_autocomplete_boolean_choice); return 1; diff --git a/src/preferences.c b/src/preferences.c index 870ce051..67f9345a 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -39,8 +39,8 @@ static GString *prefs_loc; static GKeyFile *prefs; -// search logins list -static PAutocomplete ac; +static PAutocomplete login_ac; +static PAutocomplete boolean_choice_ac; struct colour_string_t { char *str; @@ -87,7 +87,7 @@ void prefs_load(void) { log_info("Loading preferences"); - ac = p_autocomplete_new(); + login_ac = p_autocomplete_new(); prefs_loc = g_string_new(getenv("HOME")); g_string_append(prefs_loc, "/.profanity/config"); @@ -102,7 +102,7 @@ prefs_load(void) gsize i; for (i = 0; i < njids; i++) { - p_autocomplete_add(ac, strdup(jids[i])); + p_autocomplete_add(login_ac, strdup(jids[i])); } for (i = 0; i < njids; i++) { @@ -110,14 +110,19 @@ prefs_load(void) } free(jids); - _load_colours(); + + boolean_choice_ac = p_autocomplete_new(); + p_autocomplete_add(boolean_choice_ac, strdup("on")); + p_autocomplete_add(boolean_choice_ac, strdup("off")); + } void prefs_close(void) { - p_autocomplete_clear(ac); + p_autocomplete_clear(login_ac); + p_autocomplete_clear(boolean_choice_ac); g_key_file_free(prefs); } @@ -196,13 +201,25 @@ _load_colours(void) char * prefs_find_login(char *prefix) { - return p_autocomplete_complete(ac, prefix); + return p_autocomplete_complete(login_ac, prefix); } void prefs_reset_login_search(void) { - p_autocomplete_reset(ac); + p_autocomplete_reset(login_ac); +} + +char * +prefs_autocomplete_boolean_choice(char *prefix) +{ + return p_autocomplete_complete(boolean_choice_ac, prefix); +} + +void +prefs_reset_boolean_choice(void) +{ + p_autocomplete_reset(boolean_choice_ac); } gboolean diff --git a/src/preferences.h b/src/preferences.h index 0fa1d6cf..e816b7c0 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -39,6 +39,8 @@ void prefs_close(void); char * prefs_find_login(char *prefix); void prefs_reset_login_search(void); +char * prefs_autocomplete_boolean_choice(char *prefix); +void prefs_reset_boolean_choice(void); gboolean prefs_get_beep(void); void prefs_set_beep(gboolean value); |