diff options
author | James Booth <boothj5@gmail.com> | 2015-12-06 02:12:20 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-12-06 02:12:20 +0000 |
commit | 53fd2b35343d6ba66ee97be3adb136f266270c07 (patch) | |
tree | f131b0e27ee9156e48d6be620c97b7f6c71d9de5 /src | |
parent | e9e54dca4490d3e60760100e066ad0d7ae2a71f4 (diff) | |
download | profani-tty-53fd2b35343d6ba66ee97be3adb136f266270c07.tar.gz |
Read ~/.config/profanity/inputrc
Diffstat (limited to 'src')
-rw-r--r-- | src/config/preferences.c | 22 | ||||
-rw-r--r-- | src/config/preferences.h | 2 | ||||
-rw-r--r-- | src/ui/inputwin.c | 7 |
3 files changed, 29 insertions, 2 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c index 30b07598..088fb527 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -85,8 +85,7 @@ prefs_load(void) } prefs = g_key_file_new(); - g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, - NULL); + g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS, NULL); err = NULL; log_maxsize = g_key_file_get_integer(prefs, PREF_GROUP_LOGGING, "maxsize", &err); @@ -920,6 +919,25 @@ prefs_get_aliases(void) } } +gchar* +prefs_get_inputrc(void) +{ + gchar *xdg_config = xdg_get_config_home(); + GString *inputrc_file = g_string_new(xdg_config); + g_free(xdg_config); + + g_string_append(inputrc_file, "/profanity/inputrc"); + + if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) { + gchar *result = strdup(inputrc_file->str); + g_string_free(inputrc_file, TRUE); + + return result; + } + + return NULL; +} + void _free_alias(ProfAlias *alias) { diff --git a/src/config/preferences.h b/src/config/preferences.h index b2411906..910245c1 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -222,4 +222,6 @@ gboolean prefs_get_room_notify(const char *const roomjid); gboolean prefs_get_room_notify_mention(const char *const roomjid); gboolean prefs_get_room_notify_trigger(const char *const roomjid); +gchar* prefs_get_inputrc(void); + #endif diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index c840baac..a6711bab 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -421,6 +421,13 @@ _inp_rl_startup_hook(void) // disable readline completion rl_variable_bind("disable-completion", "on"); + // check for and load ~/.config/profanity/inputrc + char *inputrc = prefs_get_inputrc(); + if (inputrc) { + rl_read_init_file(inputrc); + free(inputrc); + } + return 0; } |