diff options
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 179 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 3 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 45 |
3 files changed, 135 insertions, 92 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 13c8f09d..3561449e 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -265,6 +265,7 @@ static Autocomplete statusbar_self_ac; static Autocomplete statusbar_chat_ac; static Autocomplete statusbar_room_ac; static Autocomplete statusbar_show_ac; +static Autocomplete statusbar_tabmode_ac; static Autocomplete clear_ac; static Autocomplete invite_ac; static Autocomplete status_ac; @@ -294,6 +295,8 @@ static Autocomplete vcard_togglable_param_ac; static Autocomplete vcard_toggle_ac; static Autocomplete vcard_address_type_ac; +static GHashTable* ac_funcs = NULL; + /*! * \brief Initialization of auto completion for commands. * @@ -1030,6 +1033,7 @@ cmd_ac_init(void) autocomplete_add(statusbar_ac, "hide"); autocomplete_add(statusbar_ac, "maxtabs"); autocomplete_add(statusbar_ac, "tablen"); + autocomplete_add(statusbar_ac, "tabmode"); autocomplete_add(statusbar_ac, "self"); autocomplete_add(statusbar_ac, "chat"); autocomplete_add(statusbar_ac, "room"); @@ -1058,6 +1062,10 @@ cmd_ac_init(void) autocomplete_add(statusbar_show_ac, "number"); autocomplete_add(statusbar_show_ac, "read"); + statusbar_tabmode_ac = autocomplete_new(); + autocomplete_add(statusbar_tabmode_ac, "actlist"); + autocomplete_add(statusbar_tabmode_ac, "default"); + status_ac = autocomplete_new(); autocomplete_add(status_ac, "set"); autocomplete_add(status_ac, "get"); @@ -1299,6 +1307,78 @@ cmd_ac_init(void) vcard_address_type_ac = autocomplete_new(); autocomplete_add(vcard_address_type_ac, "domestic"); autocomplete_add(vcard_address_type_ac, "international"); + + if (ac_funcs != NULL) + g_hash_table_destroy(ac_funcs); + ac_funcs = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_insert(ac_funcs, "/account", _account_autocomplete); + g_hash_table_insert(ac_funcs, "/affiliation", _affiliation_autocomplete); + g_hash_table_insert(ac_funcs, "/alias", _alias_autocomplete); + g_hash_table_insert(ac_funcs, "/autoaway", _autoaway_autocomplete); + g_hash_table_insert(ac_funcs, "/autoconnect", _autoconnect_autocomplete); + g_hash_table_insert(ac_funcs, "/avatar", _avatar_autocomplete); + g_hash_table_insert(ac_funcs, "/ban", _ban_autocomplete); + g_hash_table_insert(ac_funcs, "/blocked", _blocked_autocomplete); + g_hash_table_insert(ac_funcs, "/bookmark", _bookmark_autocomplete); + g_hash_table_insert(ac_funcs, "/clear", _clear_autocomplete); + g_hash_table_insert(ac_funcs, "/close", _close_autocomplete); + g_hash_table_insert(ac_funcs, "/cmd", _adhoc_cmd_autocomplete); + g_hash_table_insert(ac_funcs, "/color", _color_autocomplete); + g_hash_table_insert(ac_funcs, "/connect", _connect_autocomplete); + g_hash_table_insert(ac_funcs, "/console", _console_autocomplete); + g_hash_table_insert(ac_funcs, "/correct", _correct_autocomplete); + g_hash_table_insert(ac_funcs, "/correction", _correction_autocomplete); + g_hash_table_insert(ac_funcs, "/executable", _executable_autocomplete); + g_hash_table_insert(ac_funcs, "/form", _form_autocomplete); + g_hash_table_insert(ac_funcs, "/help", _help_autocomplete); + g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); + g_hash_table_insert(ac_funcs, "/intype", _intype_autocomplete); + g_hash_table_insert(ac_funcs, "/invite", _invite_autocomplete); + g_hash_table_insert(ac_funcs, "/join", _join_autocomplete); + g_hash_table_insert(ac_funcs, "/kick", _kick_autocomplete); + g_hash_table_insert(ac_funcs, "/lastactivity", _lastactivity_autocomplete); + g_hash_table_insert(ac_funcs, "/log", _log_autocomplete); + g_hash_table_insert(ac_funcs, "/logging", _logging_autocomplete); + g_hash_table_insert(ac_funcs, "/mood", _mood_autocomplete); + g_hash_table_insert(ac_funcs, "/notify", _notify_autocomplete); + g_hash_table_insert(ac_funcs, "/occupants", _occupants_autocomplete); +#ifdef HAVE_OMEMO + g_hash_table_insert(ac_funcs, "/omemo", _omemo_autocomplete); +#endif +#ifdef HAVE_LIBOTR + g_hash_table_insert(ac_funcs, "/otr", _otr_autocomplete); +#endif +#ifdef HAVE_LIBGPGME + g_hash_table_insert(ac_funcs, "/ox", _ox_autocomplete); + g_hash_table_insert(ac_funcs, "/pgp", _pgp_autocomplete); +#endif + g_hash_table_insert(ac_funcs, "/plugins", _plugins_autocomplete); + g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); + g_hash_table_insert(ac_funcs, "/receipts", _receipts_autocomplete); + g_hash_table_insert(ac_funcs, "/reconnect", _reconnect_autocomplete); + g_hash_table_insert(ac_funcs, "/resource", _resource_autocomplete); + g_hash_table_insert(ac_funcs, "/role", _role_autocomplete); + g_hash_table_insert(ac_funcs, "/rooms", _rooms_autocomplete); + g_hash_table_insert(ac_funcs, "/roster", _roster_autocomplete); + g_hash_table_insert(ac_funcs, "/script", _script_autocomplete); + g_hash_table_insert(ac_funcs, "/sendfile", _sendfile_autocomplete); + g_hash_table_insert(ac_funcs, "/software", _software_autocomplete); + g_hash_table_insert(ac_funcs, "/status", _status_autocomplete); + g_hash_table_insert(ac_funcs, "/statusbar", _statusbar_autocomplete); + g_hash_table_insert(ac_funcs, "/strophe", _strophe_autocomplete); + g_hash_table_insert(ac_funcs, "/sub", _sub_autocomplete); + g_hash_table_insert(ac_funcs, "/subject", _subject_autocomplete); + g_hash_table_insert(ac_funcs, "/theme", _theme_autocomplete); + g_hash_table_insert(ac_funcs, "/time", _time_autocomplete); + g_hash_table_insert(ac_funcs, "/titlebar", _titlebar_autocomplete); + g_hash_table_insert(ac_funcs, "/tls", _tls_autocomplete); + g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete); + g_hash_table_insert(ac_funcs, "/url", _url_autocomplete); + g_hash_table_insert(ac_funcs, "/vcard", _vcard_autocomplete); + g_hash_table_insert(ac_funcs, "/who", _who_autocomplete); + g_hash_table_insert(ac_funcs, "/win", _win_autocomplete); + g_hash_table_insert(ac_funcs, "/wins", _wins_autocomplete); + g_hash_table_insert(ac_funcs, "/wintitle", _wintitle_autocomplete); } void @@ -1606,6 +1686,7 @@ cmd_ac_reset(ProfWin* window) autocomplete_reset(statusbar_chat_ac); autocomplete_reset(statusbar_room_ac); autocomplete_reset(statusbar_show_ac); + autocomplete_reset(statusbar_tabmode_ac); autocomplete_reset(clear_ac); autocomplete_reset(invite_ac); autocomplete_reset(status_ac); @@ -1792,6 +1873,7 @@ cmd_ac_uninit(void) autocomplete_free(statusbar_chat_ac); autocomplete_free(statusbar_room_ac); autocomplete_free(statusbar_show_ac); + autocomplete_free(statusbar_tabmode_ac); autocomplete_free(clear_ac); autocomplete_free(invite_ac); autocomplete_free(status_ac); @@ -2011,86 +2093,26 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ } } - gchar* cmds[] = { "/prefs", "/disco", "/room", "/autoping", "/mainwin", "/inputwin" }; - Autocomplete completers[] = { prefs_ac, disco_ac, room_ac, autoping_ac, winpos_ac, winpos_ac }; - - for (int i = 0; i < ARRAY_SIZE(cmds); i++) { - result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE, previous); + struct + { + gchar* cmd; + Autocomplete completer; + } ac_cmds[] = { + { "/prefs", prefs_ac }, + { "/disco", disco_ac }, + { "/room", room_ac }, + { "/autoping", autoping_ac }, + { "/mainwin", winpos_ac }, + { "/inputwin", winpos_ac }, + }; + + for (int i = 0; i < ARRAY_SIZE(ac_cmds); i++) { + result = autocomplete_param_with_ac(input, ac_cmds[i].cmd, ac_cmds[i].completer, TRUE, previous); if (result) { return result; } } - GHashTable* ac_funcs = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_insert(ac_funcs, "/help", _help_autocomplete); - g_hash_table_insert(ac_funcs, "/who", _who_autocomplete); - g_hash_table_insert(ac_funcs, "/sub", _sub_autocomplete); - g_hash_table_insert(ac_funcs, "/notify", _notify_autocomplete); - g_hash_table_insert(ac_funcs, "/autoaway", _autoaway_autocomplete); - g_hash_table_insert(ac_funcs, "/theme", _theme_autocomplete); - g_hash_table_insert(ac_funcs, "/log", _log_autocomplete); - g_hash_table_insert(ac_funcs, "/account", _account_autocomplete); - g_hash_table_insert(ac_funcs, "/roster", _roster_autocomplete); - g_hash_table_insert(ac_funcs, "/bookmark", _bookmark_autocomplete); - g_hash_table_insert(ac_funcs, "/autoconnect", _autoconnect_autocomplete); -#ifdef HAVE_LIBOTR - g_hash_table_insert(ac_funcs, "/otr", _otr_autocomplete); -#endif -#ifdef HAVE_LIBGPGME - g_hash_table_insert(ac_funcs, "/pgp", _pgp_autocomplete); - g_hash_table_insert(ac_funcs, "/ox", _ox_autocomplete); -#endif -#ifdef HAVE_OMEMO - g_hash_table_insert(ac_funcs, "/omemo", _omemo_autocomplete); -#endif - g_hash_table_insert(ac_funcs, "/connect", _connect_autocomplete); - g_hash_table_insert(ac_funcs, "/alias", _alias_autocomplete); - g_hash_table_insert(ac_funcs, "/join", _join_autocomplete); - g_hash_table_insert(ac_funcs, "/form", _form_autocomplete); - g_hash_table_insert(ac_funcs, "/occupants", _occupants_autocomplete); - g_hash_table_insert(ac_funcs, "/kick", _kick_autocomplete); - g_hash_table_insert(ac_funcs, "/ban", _ban_autocomplete); - g_hash_table_insert(ac_funcs, "/affiliation", _affiliation_autocomplete); - g_hash_table_insert(ac_funcs, "/role", _role_autocomplete); - g_hash_table_insert(ac_funcs, "/resource", _resource_autocomplete); - g_hash_table_insert(ac_funcs, "/wintitle", _wintitle_autocomplete); - g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); - g_hash_table_insert(ac_funcs, "/time", _time_autocomplete); - g_hash_table_insert(ac_funcs, "/receipts", _receipts_autocomplete); - g_hash_table_insert(ac_funcs, "/reconnect", _reconnect_autocomplete); - g_hash_table_insert(ac_funcs, "/wins", _wins_autocomplete); - g_hash_table_insert(ac_funcs, "/tls", _tls_autocomplete); - g_hash_table_insert(ac_funcs, "/titlebar", _titlebar_autocomplete); - g_hash_table_insert(ac_funcs, "/script", _script_autocomplete); - g_hash_table_insert(ac_funcs, "/subject", _subject_autocomplete); - g_hash_table_insert(ac_funcs, "/console", _console_autocomplete); - g_hash_table_insert(ac_funcs, "/win", _win_autocomplete); - g_hash_table_insert(ac_funcs, "/close", _close_autocomplete); - g_hash_table_insert(ac_funcs, "/plugins", _plugins_autocomplete); - g_hash_table_insert(ac_funcs, "/sendfile", _sendfile_autocomplete); - g_hash_table_insert(ac_funcs, "/blocked", _blocked_autocomplete); - g_hash_table_insert(ac_funcs, "/tray", _tray_autocomplete); - g_hash_table_insert(ac_funcs, "/presence", _presence_autocomplete); - g_hash_table_insert(ac_funcs, "/rooms", _rooms_autocomplete); - g_hash_table_insert(ac_funcs, "/statusbar", _statusbar_autocomplete); - g_hash_table_insert(ac_funcs, "/clear", _clear_autocomplete); - g_hash_table_insert(ac_funcs, "/invite", _invite_autocomplete); - g_hash_table_insert(ac_funcs, "/status", _status_autocomplete); - g_hash_table_insert(ac_funcs, "/logging", _logging_autocomplete); - g_hash_table_insert(ac_funcs, "/color", _color_autocomplete); - g_hash_table_insert(ac_funcs, "/avatar", _avatar_autocomplete); - g_hash_table_insert(ac_funcs, "/correction", _correction_autocomplete); - g_hash_table_insert(ac_funcs, "/correct", _correct_autocomplete); - g_hash_table_insert(ac_funcs, "/software", _software_autocomplete); - 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); - g_hash_table_insert(ac_funcs, "/mood", _mood_autocomplete); - g_hash_table_insert(ac_funcs, "/strophe", _strophe_autocomplete); - g_hash_table_insert(ac_funcs, "/cmd", _adhoc_cmd_autocomplete); - g_hash_table_insert(ac_funcs, "/vcard", _vcard_autocomplete); - int len = strlen(input); char parsed[len + 1]; int i = 0; @@ -2108,11 +2130,9 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ if (ac_func) { result = ac_func(window, input, previous); if (result) { - g_hash_table_destroy(ac_funcs); return result; } } - g_hash_table_destroy(ac_funcs); result = plugins_autocomplete(input, previous); if (result) { @@ -4100,6 +4120,11 @@ _statusbar_autocomplete(ProfWin* window, const char* const input, gboolean previ return found; } + found = autocomplete_param_with_ac(input, "/statusbar tabmode", statusbar_tabmode_ac, TRUE, previous); + if (found) { + return found; + } + found = autocomplete_param_with_ac(input, "/statusbar room", statusbar_room_ac, TRUE, previous); return found; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 60c1c971..6f30652b 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -1293,6 +1293,7 @@ static const struct cmd_t command_defs[] = { "/statusbar hide name|number|read", "/statusbar maxtabs <value>", "/statusbar tablen <value>", + "/statusbar tabmode default|actlist", "/statusbar self user|barejid|fulljid|off", "/statusbar chat user|jid", "/statusbar room room|jid", @@ -1303,6 +1304,7 @@ static const struct cmd_t command_defs[] = { CMD_ARGS( { "maxtabs <value>", "Set the maximum number of tabs to display, <value> must be between 0 and 10." }, { "tablen <value>", "Set the maximum number of characters to show as the tab name, 0 sets to unlimited." }, + { "tabmode default|actlist", "Set the mode how the 'active tabs' are shown." }, { "show|hide name", "Show or hide names in tabs." }, { "show|hide number", "Show or hide numbers in tabs." }, { "show|hide read", "Show or hide inactive tabs." }, @@ -1315,6 +1317,7 @@ static const struct cmd_t command_defs[] = { CMD_EXAMPLES( "/statusbar maxtabs 8", "/statusbar tablen 5", + "/statusbar tabmode actlist", "/statusbar self user", "/statusbar chat jid", "/statusbar hide read", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index b9ad139c..f6736156 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1314,7 +1314,7 @@ cmd_disconnect(ProfWin* window, const char* const command, gchar** args) gboolean cmd_quit(ProfWin* window, const char* const command, gchar** args) { - log_info("Profanity is shutting down..."); + log_info("Profanity is shutting down…"); exit(0); return FALSE; } @@ -3767,11 +3767,11 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) value = args[0]; if (g_strcmp0(value, "on") == 0) { form_set_value(form, tag, "1"); - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } else if (g_strcmp0(value, "off") == 0) { form_set_value(form, tag, "0"); - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } else { win_println(window, THEME_DEFAULT, "-", "Invalid command, usage:"); @@ -3790,7 +3790,7 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) win_println(window, THEME_DEFAULT, "-", ""); } else { form_set_value(form, tag, value); - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } break; @@ -3802,7 +3802,7 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) win_println(window, THEME_DEFAULT, "-", ""); } else { form_set_value(form, tag, value); - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } break; @@ -3826,7 +3826,7 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) } if (g_strcmp0(cmd, "add") == 0) { form_add_value(form, tag, value); - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); break; } @@ -3854,7 +3854,7 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) removed = form_remove_text_multi_value(form, tag, index); if (removed) { - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } else { win_println(window, THEME_DEFAULT, "-", "Could not remove %s from %s", value, tag); @@ -3883,7 +3883,7 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) if (valid) { added = form_add_unique_value(form, tag, value); if (added) { - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } else { win_println(window, THEME_DEFAULT, "-", "Value %s already selected for %s", value, tag); @@ -3900,7 +3900,7 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) if (valid == TRUE) { removed = form_remove_value(form, tag, value); if (removed) { - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } else { win_println(window, THEME_DEFAULT, "-", "Value %s is not currently set for %s", value, tag); @@ -3932,7 +3932,7 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) if (g_strcmp0(args[0], "add") == 0) { added = form_add_unique_value(form, tag, value); if (added) { - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } else { win_println(window, THEME_DEFAULT, "-", "JID %s already exists in %s", value, tag); @@ -3942,7 +3942,7 @@ cmd_form_field(ProfWin* window, char* tag, gchar** args) if (g_strcmp0(args[0], "remove") == 0) { removed = form_remove_value(form, tag, value); if (removed) { - win_println(window, THEME_DEFAULT, "-", "Field updated..."); + win_println(window, THEME_DEFAULT, "-", "Field updated…"); confwin_show_form_field(confwin, form, tag); } else { win_println(window, THEME_DEFAULT, "-", "Field %s does not contain %s", tag, value); @@ -6343,6 +6343,21 @@ cmd_statusbar(ProfWin* window, const char* const command, gchar** args) } } + if (g_strcmp0(args[0], "tabmode") == 0) { + char* tabmode = NULL; + if ((g_strcmp0(args[1], "default") == 0) || (g_strcmp0(args[1], "actlist") == 0)) { + tabmode = args[1]; + } + if (tabmode == NULL) { + cons_bad_cmd_usage(command); + return TRUE; + } + prefs_set_string(PREF_STATUSBAR_TABMODE, tabmode); + cons_show("Using \"%s\" tabmode for statusbar.", tabmode); + ui_resize(); + return TRUE; + } + if (g_strcmp0(args[0], "self") == 0) { if (g_strcmp0(args[1], "barejid") == 0) { prefs_set_string(PREF_STATUSBAR_SELF, "barejid"); @@ -6626,9 +6641,9 @@ cmd_ping(ProfWin* window, const char* const command, gchar** args) iq_send_ping(args[0]); if (args[0] == NULL) { - cons_show("Pinged server..."); + cons_show("Pinged server…"); } else { - cons_show("Pinged %s...", args[0]); + cons_show("Pinged %s…", args[0]); } return TRUE; } @@ -8396,7 +8411,7 @@ cmd_command_exec(ProfWin* window, const char* const command, gchar** args) iq_command_exec(jid, args[1]); - cons_show("Execute %s...", args[1]); + cons_show("Execute %s…", args[1]); return TRUE; } @@ -8612,7 +8627,7 @@ cmd_omemo_gen(ProfWin* window, const char* const command, gchar** args) return TRUE; } - cons_show("Generating OMEMO crytographic materials, it may take a while..."); + cons_show("Generating OMEMO crytographic materials, it may take a while…"); ui_update(); ProfAccount* account = accounts_get_account(session_get_account_name()); omemo_generate_crypto_materials(account); |