diff options
author | Michael Vetter <jubalh@iodoru.org> | 2021-05-11 12:16:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-11 12:16:09 +0200 |
commit | 5906c4ade1b215ece95dbd85ea3bdd44fd508b8b (patch) | |
tree | 1e6d4454c60b8527fef885710243c96bdb1f070d /src/command | |
parent | 1ef700f918f706da2098460ead880b2538aaf262 (diff) | |
parent | 64244474d3d3d07e92a943939202e2d27efa3b40 (diff) | |
download | profani-tty-5906c4ade1b215ece95dbd85ea3bdd44fd508b8b.tar.gz |
Merge pull request #1532 from profanity-im/feat/1516-intype
Have separate settings for intype (console/titlebar)
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 29 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 7 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 9 |
3 files changed, 40 insertions, 5 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 14af0552..b84d4d2e 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -127,6 +127,7 @@ static char* _software_autocomplete(ProfWin* window, const char* const input, gb static char* _url_autocomplete(ProfWin* window, const char* const input, gboolean previous); static char* _executable_autocomplete(ProfWin* window, const char* const input, gboolean previous); static char* _lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean previous); +static char* _intype_autocomplete(ProfWin* window, const char* const input, gboolean previous); static char* _script_autocomplete_func(const char* const prefix, gboolean previous, void* context); @@ -267,6 +268,7 @@ static Autocomplete correction_ac; static Autocomplete avatar_ac; static Autocomplete url_ac; static Autocomplete executable_ac; +static Autocomplete intype_ac; /*! * \brief Initialization of auto completion for commands. @@ -1053,6 +1055,10 @@ cmd_ac_init(void) autocomplete_add(executable_ac, "urlopen"); autocomplete_add(executable_ac, "urlsave"); autocomplete_add(executable_ac, "editor"); + + intype_ac = autocomplete_new(); + autocomplete_add(intype_ac, "console"); + autocomplete_add(intype_ac, "titlebar"); } void @@ -1368,6 +1374,7 @@ cmd_ac_reset(ProfWin* window) autocomplete_reset(avatar_ac); autocomplete_reset(url_ac); autocomplete_reset(executable_ac); + autocomplete_reset(intype_ac); autocomplete_reset(script_ac); if (script_show_ac) { @@ -1531,6 +1538,7 @@ cmd_ac_uninit(void) autocomplete_free(avatar_ac); autocomplete_free(url_ac); autocomplete_free(executable_ac); + autocomplete_free(intype_ac); } static void @@ -1660,7 +1668,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ jabber_conn_status_t conn_status = connection_get_status(); // autocomplete boolean settings - gchar* boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", + gchar* boolean_choices[] = { "/beep", "/states", "/outtype", "/flash", "/splash", "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/os", "/slashguard", "/mam" }; for (int i = 0; i < ARRAY_SIZE(boolean_choices); i++) { @@ -1794,6 +1802,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ g_hash_table_insert(ac_funcs, "/url", _url_autocomplete); g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete); g_hash_table_insert(ac_funcs, "/lastactivity", _lastactivity_autocomplete); + g_hash_table_insert(ac_funcs, "/intype", _intype_autocomplete); int len = strlen(input); char parsed[len + 1]; @@ -4121,3 +4130,21 @@ _lastactivity_autocomplete(ProfWin* window, const char* const input, gboolean pr return result; } + +static char* +_intype_autocomplete(ProfWin* window, const char* const input, gboolean previous) +{ + char* result = NULL; + result = autocomplete_param_with_func(input, "/intype console", prefs_autocomplete_boolean_choice, previous, NULL); + if (result) { + return result; + } + + result = autocomplete_param_with_func(input, "/intype titlebar", prefs_autocomplete_boolean_choice, previous, NULL); + if (result) { + return result; + } + + result = autocomplete_param_with_ac(input, "/intype", intype_ac, FALSE, previous); + return result; +} diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 5c03cad3..4ebc3432 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1514,18 +1514,19 @@ static struct cmd_t command_defs[] = { }, { "/intype", - parse_args, 1, 1, &cons_intype_setting, + parse_args, 2, 2, &cons_intype_setting, CMD_NOSUBFUNCS CMD_MAINFUNC(cmd_intype) CMD_TAGS( CMD_TAG_UI, CMD_TAG_CHAT) CMD_SYN( - "/intype on|off") + "/intype console|titlebar on|off") CMD_DESC( "Show when a contact is typing in the console, and in active message window.") CMD_ARGS( - { "on|off", "Enable or disable contact typing messages." }) + { "titlebar on|off", "Enable or disable contact typing messages notification in titlebar." }, + { "console on|off", "Enable or disable contact typing messages notification in console window." }) CMD_NOEXAMPLES }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 351f7b98..ab212975 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -6719,7 +6719,14 @@ cmd_tray(ProfWin* window, const char* const command, gchar** args) gboolean cmd_intype(ProfWin* window, const char* const command, gchar** args) { - _cmd_set_boolean_preference(args[0], command, "Show contact typing", PREF_INTYPE); + if (g_strcmp0(args[0], "console") == 0) { + _cmd_set_boolean_preference(args[1], command, "Show contact typing in console", PREF_INTYPE_CONSOLE); + } else if (g_strcmp0(args[0], "titlebar") == 0) { + _cmd_set_boolean_preference(args[1], command, "Show contact typing in titlebar", PREF_INTYPE); + } else { + cons_bad_cmd_usage(command); + } + return TRUE; } |