diff options
Diffstat (limited to 'src/command/command.c')
-rw-r--r-- | src/command/command.c | 127 |
1 files changed, 99 insertions, 28 deletions
diff --git a/src/command/command.c b/src/command/command.c index e7d8547a..86185f59 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -96,6 +96,8 @@ static char * _ban_autocomplete(char *input, int *size); static char * _affiliation_autocomplete(char *input, int *size); static char * _role_autocomplete(char *input, int *size); static char * _resource_autocomplete(char *input, int *size); +static char * _titlebar_autocomplete(char *input, int *size); +static char * _inpblock_autocomplete(char *input, int *size); GHashTable *commands = NULL; @@ -278,13 +280,15 @@ static struct cmd_t command_defs[] = NULL } } }, { "/resource", - cmd_resource, parse_args, 1, 2, NULL, - { "/resource set|off [resource]", "Set the contact's resource.", - { "/resource set|off [resource]", - "----------------------------", - "Set the resource to use when chatting to a contact.", - "set resource - Set the resource.", - "off - Let the server choose which resource to route messages to.", + cmd_resource, parse_args, 1, 2, &cons_resource_setting, + { "/resource set|off|title|message [resource]", "Set the contact's resource.", + { "/resource set|off|title|message [resource]", + "------------------------------------------", + "Set the resource to use when chatting to a contact and manage resource display settings.", + "set resource - Set the resource.", + "off - Let the server choose which resource to route messages to.", + "title on|off - Show or hide the current resource in the titlebar.", + "message on|off - Show or hide the resource from which a message was recieved.", NULL } } }, { "/join", @@ -620,14 +624,18 @@ static struct cmd_t command_defs[] = NULL } } }, { "/inpblock", - cmd_inpblock, parse_args, 1, 1, &cons_inpblock_setting, - { "/inpblock millis", "Input blocking delay.", - { "/inpblock millis", - "----------------", - "Time to wait in milliseconds before reading input from the terminal buffer, defaults to 20.", - "Valid values are 1-1000.", - "A higher value will result in less CPU usage, but a noticable delay for response to input.", - "A lower value will result in higher CPU usage, but faster response to input.", + cmd_inpblock, parse_args, 2, 2, &cons_inpblock_setting, + { "/inpblock timeout|dynamic [millis|on|off]", "Input blocking delay (dynamic or static).", + { "/inpblock timeout|dynamic [millis|on|off]", + "-----------------------------------------", + "How long to wait for input before checking for new messages or checking for state changes such as 'idle'.", + "timeout : Time to wait in milliseconds before reading input from the terminal buffer, defaults to 500.", + " : Valid values are 1-1000.", + "dynamic : Start with a 0 timeout and increase the value dynamically up to the specified 'timeout'.", + " : on|off", + "A higher timeout will result in less CPU usage, but a noticable delay for response to input.", + "A lower timeout will result in higher CPU usage, but faster response to input.", + "Using the dynamic setting, higher CPU usage will occur during activity, but over time the CPU usage will decrease whilst there is no activity.", NULL } } }, { "/notify", @@ -719,11 +727,13 @@ static struct cmd_t command_defs[] = NULL } } }, { "/titlebar", - cmd_titlebar, parse_args, 1, 1, &cons_titlebar_setting, - { "/titlebar on|off", "Show information in the window title bar.", - { "/titlebar on|off", - "----------------", - "Show information in the window title bar.", + cmd_titlebar, parse_args, 2, 2, &cons_titlebar_setting, + { "/titlebar show|goodbye on|off", "Manage the terminal window title.", + { "/titlebar show|goodbye on|off", + "---------------------", + "Show or hide a title and exit message in the terminal window title.", + "show - Show current logged in user, and unread messages in the title.", + "goodbye - Show a message in the title when exiting profanity.", NULL } } }, { "/mouse", @@ -1110,6 +1120,7 @@ static Autocomplete occupants_ac; static Autocomplete occupants_default_ac; static Autocomplete time_ac; static Autocomplete resource_ac; +static Autocomplete inpblock_ac; /* * Initialise command autocompleter and history @@ -1205,7 +1216,8 @@ cmd_init(void) autocomplete_add(sub_ac, "received"); titlebar_ac = autocomplete_new(); - autocomplete_add(titlebar_ac, "version"); + autocomplete_add(titlebar_ac, "show"); + autocomplete_add(titlebar_ac, "goodbye"); log_ac = autocomplete_new(); autocomplete_add(log_ac, "maxsize"); @@ -1458,6 +1470,12 @@ cmd_init(void) resource_ac = autocomplete_new(); autocomplete_add(resource_ac, "set"); autocomplete_add(resource_ac, "off"); + autocomplete_add(resource_ac, "title"); + autocomplete_add(resource_ac, "message"); + + inpblock_ac = autocomplete_new(); + autocomplete_add(inpblock_ac, "timeout"); + autocomplete_add(inpblock_ac, "dynamic"); cmd_history_init(); } @@ -1515,6 +1533,7 @@ cmd_uninit(void) autocomplete_free(occupants_default_ac); autocomplete_free(time_ac); autocomplete_free(resource_ac); + autocomplete_free(inpblock_ac); } gboolean @@ -1660,6 +1679,7 @@ cmd_reset_autocomplete() autocomplete_reset(roster_option_ac); autocomplete_reset(roster_by_ac); autocomplete_reset(group_ac); + autocomplete_reset(titlebar_ac); autocomplete_reset(bookmark_ac); autocomplete_reset(bookmark_property_ac); autocomplete_reset(otr_ac); @@ -1682,6 +1702,7 @@ cmd_reset_autocomplete() autocomplete_reset(occupants_default_ac); autocomplete_reset(time_ac); autocomplete_reset(resource_ac); + autocomplete_reset(inpblock_ac); if (ui_current_win_type() == WIN_CHAT) { ProfChatWin *chatwin = wins_get_current_chat(); @@ -1817,8 +1838,7 @@ cmd_execute_default(const char * inp) if (otr_is_secure(chatwin->barejid)) { char *encrypted = otr_encrypt_message(chatwin->barejid, inp); if (encrypted != NULL) { - gboolean send_state = chat_session_on_message_send(chatwin->barejid); - message_send_chat(chatwin->barejid, chatwin->resource, encrypted, send_state); + message_send_chat(chatwin->barejid, encrypted); otr_free_message(encrypted); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); @@ -1838,8 +1858,7 @@ cmd_execute_default(const char * inp) cons_show_error("Failed to send message."); } } else { - gboolean send_state = chat_session_on_message_send(chatwin->barejid); - message_send_chat(chatwin->barejid, chatwin->resource, inp, send_state); + message_send_chat(chatwin->barejid, inp); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); @@ -1850,8 +1869,7 @@ cmd_execute_default(const char * inp) ui_outgoing_chat_msg("me", chatwin->barejid, inp); } #else - gboolean send_state = chat_session_on_message_send(chatwin->barejid); - message_send_chat(chatwin->barejid, chatwin->resource, inp, send_state); + message_send_chat(chatwin->barejid, inp); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); @@ -1894,7 +1912,7 @@ _cmd_complete_parameters(char *input, int *size) // autocomplete boolean settings gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", - "/flash", "/splash", "/chlog", "/grlog", "/mouse", "/history", "/titlebar", + "/flash", "/splash", "/chlog", "/grlog", "/mouse", "/history", "/vercheck", "/privileges", "/presence", "/wrap" }; for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { @@ -2004,6 +2022,8 @@ _cmd_complete_parameters(char *input, int *size) 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, "/titlebar", _titlebar_autocomplete); + g_hash_table_insert(ac_funcs, "/inpblock", _inpblock_autocomplete); char parsed[*size+1]; i = 0; @@ -2468,6 +2488,16 @@ _resource_autocomplete(char *input, int *size) } } + found = autocomplete_param_with_func(input, size, "/resource title", prefs_autocomplete_boolean_choice); + if (found != NULL) { + return found; + } + + found = autocomplete_param_with_func(input, size, "/resource message", prefs_autocomplete_boolean_choice); + if (found != NULL) { + return found; + } + found = autocomplete_param_with_ac(input, size, "/resource", resource_ac, FALSE); if (found != NULL) { return found; @@ -2477,6 +2507,47 @@ _resource_autocomplete(char *input, int *size) } static char * +_titlebar_autocomplete(char *input, int *size) +{ + char *found = NULL; + + found = autocomplete_param_with_func(input, size, "/titlebar show", prefs_autocomplete_boolean_choice); + if (found != NULL) { + return found; + } + + found = autocomplete_param_with_func(input, size, "/titlebar goodbye", prefs_autocomplete_boolean_choice); + if (found != NULL) { + return found; + } + + found = autocomplete_param_with_ac(input, size, "/titlebar", titlebar_ac, FALSE); + if (found != NULL) { + return found; + } + + return NULL; +} + +static char * +_inpblock_autocomplete(char *input, int *size) +{ + char *found = NULL; + + found = autocomplete_param_with_func(input, size, "/inpblock dynamic", prefs_autocomplete_boolean_choice); + if (found != NULL) { + return found; + } + + found = autocomplete_param_with_ac(input, size, "/inpblock", inpblock_ac, FALSE); + if (found != NULL) { + return found; + } + + return NULL; +} + +static char * _form_autocomplete(char *input, int *size) { ProfWin *current = wins_get_current(); |