mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Pass current window to autocompleters
This commit is contained in:
parent
fb0e065902
commit
cfef64c767
@ -70,38 +70,38 @@
|
|||||||
|
|
||||||
typedef char*(*autocompleter)(char*, int*);
|
typedef char*(*autocompleter)(char*, int*);
|
||||||
|
|
||||||
static gboolean _cmd_execute(const char * const command, const char * const inp);
|
static gboolean _cmd_execute(ProfWin *window, const char * const command, const char * const inp);
|
||||||
|
|
||||||
static char * _cmd_complete_parameters(const char * const input);
|
static char * _cmd_complete_parameters(ProfWin *window, const char * const input);
|
||||||
|
|
||||||
static char * _sub_autocomplete(const char * const input);
|
static char * _sub_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _notify_autocomplete(const char * const input);
|
static char * _notify_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _theme_autocomplete(const char * const input);
|
static char * _theme_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _autoaway_autocomplete(const char * const input);
|
static char * _autoaway_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _autoconnect_autocomplete(const char * const input);
|
static char * _autoconnect_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _account_autocomplete(const char * const input);
|
static char * _account_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _who_autocomplete(const char * const input);
|
static char * _who_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _roster_autocomplete(const char * const input);
|
static char * _roster_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _group_autocomplete(const char * const input);
|
static char * _group_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _bookmark_autocomplete(const char * const input);
|
static char * _bookmark_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _otr_autocomplete(const char * const input);
|
static char * _otr_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _connect_autocomplete(const char * const input);
|
static char * _connect_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _statuses_autocomplete(const char * const input);
|
static char * _statuses_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _alias_autocomplete(const char * const input);
|
static char * _alias_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _join_autocomplete(const char * const input);
|
static char * _join_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _log_autocomplete(const char * const input);
|
static char * _log_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _form_autocomplete(const char * const input);
|
static char * _form_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _form_field_autocomplete(const char * const input);
|
static char * _form_field_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _occupants_autocomplete(const char * const input);
|
static char * _occupants_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _kick_autocomplete(const char * const input);
|
static char * _kick_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _ban_autocomplete(const char * const input);
|
static char * _ban_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _affiliation_autocomplete(const char * const input);
|
static char * _affiliation_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _role_autocomplete(const char * const input);
|
static char * _role_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _resource_autocomplete(const char * const input);
|
static char * _resource_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _titlebar_autocomplete(const char * const input);
|
static char * _titlebar_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _inpblock_autocomplete(const char * const input);
|
static char * _inpblock_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _time_autocomplete(const char * const input);
|
static char * _time_autocomplete(ProfWin *window, const char * const input);
|
||||||
static char * _receipts_autocomplete(const char * const input);
|
static char * _receipts_autocomplete(ProfWin *window, const char * const input);
|
||||||
|
|
||||||
GHashTable *commands = NULL;
|
GHashTable *commands = NULL;
|
||||||
|
|
||||||
@ -1722,7 +1722,7 @@ cmd_alias_remove(char *value)
|
|||||||
|
|
||||||
// Command autocompletion functions
|
// Command autocompletion functions
|
||||||
char*
|
char*
|
||||||
cmd_autocomplete(const char * const input)
|
cmd_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
// autocomplete command
|
// autocomplete command
|
||||||
if ((strncmp(input, "/", 1) == 0) && (!str_contains(input, strlen(input), ' '))) {
|
if ((strncmp(input, "/", 1) == 0) && (!str_contains(input, strlen(input), ' '))) {
|
||||||
@ -1734,7 +1734,7 @@ cmd_autocomplete(const char * const input)
|
|||||||
|
|
||||||
// autocomplete parameters
|
// autocomplete parameters
|
||||||
} else {
|
} else {
|
||||||
char *found = _cmd_complete_parameters(input);
|
char *found = _cmd_complete_parameters(window, input);
|
||||||
if (found) {
|
if (found) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
@ -1744,7 +1744,7 @@ cmd_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_reset_autocomplete()
|
cmd_reset_autocomplete(ProfWin *window)
|
||||||
{
|
{
|
||||||
roster_reset_search_attempts();
|
roster_reset_search_attempts();
|
||||||
muc_invites_reset_ac();
|
muc_invites_reset_ac();
|
||||||
@ -1811,7 +1811,7 @@ cmd_reset_autocomplete()
|
|||||||
autocomplete_reset(inpblock_ac);
|
autocomplete_reset(inpblock_ac);
|
||||||
autocomplete_reset(receipts_ac);
|
autocomplete_reset(receipts_ac);
|
||||||
|
|
||||||
if (ui_current_win_type() == WIN_CHAT) {
|
if (window->type == WIN_CHAT) {
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
PContact contact = roster_get_contact(chatwin->barejid);
|
PContact contact = roster_get_contact(chatwin->barejid);
|
||||||
if (contact) {
|
if (contact) {
|
||||||
@ -1819,13 +1819,13 @@ cmd_reset_autocomplete()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_current_win_type() == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = wins_get_current_muc();
|
ProfMucWin *mucwin = wins_get_current_muc();
|
||||||
muc_autocomplete_reset(mucwin->roomjid);
|
muc_autocomplete_reset(mucwin->roomjid);
|
||||||
muc_jid_autocomplete_reset(mucwin->roomjid);
|
muc_jid_autocomplete_reset(mucwin->roomjid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_current_win_type() == WIN_MUC_CONFIG) {
|
if (window->type == WIN_MUC_CONFIG) {
|
||||||
ProfMucConfWin *confwin = wins_get_current_muc_conf();
|
ProfMucConfWin *confwin = wins_get_current_muc_conf();
|
||||||
if (confwin->form) {
|
if (confwin->form) {
|
||||||
form_reset_autocompleters(confwin->form);
|
form_reset_autocompleters(confwin->form);
|
||||||
@ -1840,7 +1840,7 @@ cmd_reset_autocomplete()
|
|||||||
* continue, FALSE otherwise
|
* continue, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
cmd_process_input(char *inp)
|
cmd_process_input(ProfWin *window, char *inp)
|
||||||
{
|
{
|
||||||
log_debug("Input received: %s", inp);
|
log_debug("Input received: %s", inp);
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
@ -1854,7 +1854,7 @@ cmd_process_input(char *inp)
|
|||||||
} else if (inp[0] == '/') {
|
} else if (inp[0] == '/') {
|
||||||
char *inp_cpy = strdup(inp);
|
char *inp_cpy = strdup(inp);
|
||||||
char *command = strtok(inp_cpy, " ");
|
char *command = strtok(inp_cpy, " ");
|
||||||
result = _cmd_execute(command, inp);
|
result = _cmd_execute(window, command, inp);
|
||||||
free(inp_cpy);
|
free(inp_cpy);
|
||||||
|
|
||||||
// call a default handler if input didn't start with '/'
|
// call a default handler if input didn't start with '/'
|
||||||
@ -1868,18 +1868,18 @@ cmd_process_input(char *inp)
|
|||||||
// Command execution
|
// Command execution
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_execute_connect(const char * const account)
|
cmd_execute_connect(ProfWin *window, const char * const account)
|
||||||
{
|
{
|
||||||
GString *command = g_string_new("/connect ");
|
GString *command = g_string_new("/connect ");
|
||||||
g_string_append(command, account);
|
g_string_append(command, account);
|
||||||
cmd_process_input(command->str);
|
cmd_process_input(window, command->str);
|
||||||
g_string_free(command, TRUE);
|
g_string_free(command, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_execute(const char * const command, const char * const inp)
|
_cmd_execute(ProfWin *window, const char * const command, const char * const inp)
|
||||||
{
|
{
|
||||||
if (g_str_has_prefix(command, "/field") && ui_current_win_type() == WIN_MUC_CONFIG) {
|
if (g_str_has_prefix(command, "/field") && window->type == WIN_MUC_CONFIG) {
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
gchar **args = parse_args_with_freetext(inp, 1, 2, &result);
|
gchar **args = parse_args_with_freetext(inp, 1, 2, &result);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@ -1911,7 +1911,7 @@ _cmd_execute(const char * const command, const char * const inp)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gboolean ran_alias = FALSE;
|
gboolean ran_alias = FALSE;
|
||||||
gboolean alias_result = cmd_execute_alias(inp, &ran_alias);
|
gboolean alias_result = cmd_execute_alias(window, inp, &ran_alias);
|
||||||
if (!ran_alias) {
|
if (!ran_alias) {
|
||||||
return cmd_execute_default(inp);
|
return cmd_execute_default(inp);
|
||||||
} else {
|
} else {
|
||||||
@ -1921,7 +1921,7 @@ _cmd_execute(const char * const command, const char * const inp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_cmd_complete_parameters(const char * const input)
|
_cmd_complete_parameters(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
@ -1939,7 +1939,7 @@ _cmd_complete_parameters(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// autocomplete nickname in chat rooms
|
// autocomplete nickname in chat rooms
|
||||||
if (ui_current_win_type() == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = wins_get_current_muc();
|
ProfMucWin *mucwin = wins_get_current_muc();
|
||||||
Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
|
Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
|
||||||
if (nick_ac) {
|
if (nick_ac) {
|
||||||
@ -2045,9 +2045,9 @@ _cmd_complete_parameters(const char * const input)
|
|||||||
}
|
}
|
||||||
parsed[i] = '\0';
|
parsed[i] = '\0';
|
||||||
|
|
||||||
char * (*ac_func)(const char * const) = g_hash_table_lookup(ac_funcs, parsed);
|
char * (*ac_func)(ProfWin*, const char * const) = g_hash_table_lookup(ac_funcs, parsed);
|
||||||
if (ac_func) {
|
if (ac_func) {
|
||||||
result = ac_func(input);
|
result = ac_func(window, input);
|
||||||
if (result) {
|
if (result) {
|
||||||
g_hash_table_destroy(ac_funcs);
|
g_hash_table_destroy(ac_funcs);
|
||||||
return result;
|
return result;
|
||||||
@ -2056,7 +2056,7 @@ _cmd_complete_parameters(const char * const input)
|
|||||||
g_hash_table_destroy(ac_funcs);
|
g_hash_table_destroy(ac_funcs);
|
||||||
|
|
||||||
if (g_str_has_prefix(input, "/field")) {
|
if (g_str_has_prefix(input, "/field")) {
|
||||||
result = _form_field_autocomplete(input);
|
result = _form_field_autocomplete(window, input);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2066,7 +2066,7 @@ _cmd_complete_parameters(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_sub_autocomplete(const char * const input)
|
_sub_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
result = autocomplete_param_with_func(input, "/sub allow", presence_sub_request_find);
|
result = autocomplete_param_with_func(input, "/sub allow", presence_sub_request_find);
|
||||||
@ -2086,12 +2086,11 @@ _sub_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_who_autocomplete(const char * const input)
|
_who_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
win_type_t win_type = ui_current_win_type();
|
|
||||||
|
|
||||||
if (win_type == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
result = autocomplete_param_with_ac(input, "/who", who_room_ac, TRUE);
|
result = autocomplete_param_with_ac(input, "/who", who_room_ac, TRUE);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
@ -2119,7 +2118,7 @@ _who_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_roster_autocomplete(const char * const input)
|
_roster_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
result = autocomplete_param_with_func(input, "/roster nick", roster_barejid_autocomplete);
|
result = autocomplete_param_with_func(input, "/roster nick", roster_barejid_autocomplete);
|
||||||
@ -2155,7 +2154,7 @@ _roster_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_group_autocomplete(const char * const input)
|
_group_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
result = autocomplete_param_with_func(input, "/group show", roster_group_autocomplete);
|
result = autocomplete_param_with_func(input, "/group show", roster_group_autocomplete);
|
||||||
@ -2188,7 +2187,7 @@ _group_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_bookmark_autocomplete(const char * const input)
|
_bookmark_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
@ -2267,7 +2266,7 @@ _bookmark_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_notify_autocomplete(const char * const input)
|
_notify_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
@ -2330,7 +2329,7 @@ _notify_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_autoaway_autocomplete(const char * const input)
|
_autoaway_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
@ -2352,7 +2351,7 @@ _autoaway_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_log_autocomplete(const char * const input)
|
_log_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
@ -2375,7 +2374,7 @@ _log_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_autoconnect_autocomplete(const char * const input)
|
_autoconnect_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
@ -2393,7 +2392,7 @@ _autoconnect_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_otr_autocomplete(const char * const input)
|
_otr_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
@ -2446,7 +2445,7 @@ _otr_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_theme_autocomplete(const char * const input)
|
_theme_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
if ((strncmp(input, "/theme load ", 12) == 0) && (strlen(input) > 12)) {
|
if ((strncmp(input, "/theme load ", 12) == 0) && (strlen(input) > 12)) {
|
||||||
@ -2475,12 +2474,11 @@ _theme_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_resource_autocomplete(const char * const input)
|
_resource_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
ProfWin *current = wins_get_current();
|
if (window->type == WIN_CHAT) {
|
||||||
if (current && current->type == WIN_CHAT) {
|
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
PContact contact = roster_get_contact(chatwin->barejid);
|
PContact contact = roster_get_contact(chatwin->barejid);
|
||||||
if (contact) {
|
if (contact) {
|
||||||
@ -2511,7 +2509,7 @@ _resource_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_titlebar_autocomplete(const char * const input)
|
_titlebar_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
@ -2534,7 +2532,7 @@ _titlebar_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_inpblock_autocomplete(const char * const input)
|
_inpblock_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
@ -2552,16 +2550,15 @@ _inpblock_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_form_autocomplete(const char * const input)
|
_form_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
ProfWin *current = wins_get_current();
|
if (window->type != WIN_MUC_CONFIG) {
|
||||||
if (current->type != WIN_MUC_CONFIG) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
ProfMucConfWin *confwin = (ProfMucConfWin*)current;
|
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
||||||
DataForm *form = confwin->form;
|
DataForm *form = confwin->form;
|
||||||
if (form) {
|
if (form) {
|
||||||
found = autocomplete_param_with_ac(input, "/form help", form->tag_ac, TRUE);
|
found = autocomplete_param_with_ac(input, "/form help", form->tag_ac, TRUE);
|
||||||
@ -2579,16 +2576,15 @@ _form_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_form_field_autocomplete(const char * const input)
|
_form_field_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
ProfWin *current = wins_get_current();
|
if (window->type != WIN_MUC_CONFIG) {
|
||||||
if (current->type != WIN_MUC_CONFIG) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
ProfMucConfWin *confwin = (ProfMucConfWin*)current;
|
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
||||||
DataForm *form = confwin->form;
|
DataForm *form = confwin->form;
|
||||||
if (form == NULL) {
|
if (form == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2650,7 +2646,7 @@ _form_field_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_occupants_autocomplete(const char * const input)
|
_occupants_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
@ -2688,7 +2684,7 @@ _occupants_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_time_autocomplete(const char * const input)
|
_time_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
@ -2706,11 +2702,11 @@ _time_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_kick_autocomplete(const char * const input)
|
_kick_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
if (ui_current_win_type() == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = wins_get_current_muc();
|
ProfMucWin *mucwin = wins_get_current_muc();
|
||||||
Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
|
Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
|
||||||
|
|
||||||
@ -2726,11 +2722,11 @@ _kick_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_ban_autocomplete(const char * const input)
|
_ban_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
if (ui_current_win_type() == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = wins_get_current_muc();
|
ProfMucWin *mucwin = wins_get_current_muc();
|
||||||
Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid);
|
Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid);
|
||||||
|
|
||||||
@ -2746,11 +2742,11 @@ _ban_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_affiliation_autocomplete(const char * const input)
|
_affiliation_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
if (ui_current_win_type() == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = wins_get_current_muc();
|
ProfMucWin *mucwin = wins_get_current_muc();
|
||||||
gboolean parse_result;
|
gboolean parse_result;
|
||||||
Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid);
|
Autocomplete jid_ac = muc_roster_jid_ac(mucwin->roomjid);
|
||||||
@ -2793,11 +2789,11 @@ _affiliation_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_role_autocomplete(const char * const input)
|
_role_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
if (ui_current_win_type() == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = wins_get_current_muc();
|
ProfMucWin *mucwin = wins_get_current_muc();
|
||||||
gboolean parse_result;
|
gboolean parse_result;
|
||||||
Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
|
Autocomplete nick_ac = muc_roster_ac(mucwin->roomjid);
|
||||||
@ -2840,7 +2836,7 @@ _role_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_statuses_autocomplete(const char * const input)
|
_statuses_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
@ -2868,7 +2864,7 @@ _statuses_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_receipts_autocomplete(const char * const input)
|
_receipts_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
@ -2891,7 +2887,7 @@ _receipts_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_alias_autocomplete(const char * const input)
|
_alias_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
@ -2909,7 +2905,7 @@ _alias_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_connect_autocomplete(const char * const input)
|
_connect_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
@ -2944,7 +2940,7 @@ _connect_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_join_autocomplete(const char * const input)
|
_join_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
@ -2979,7 +2975,7 @@ _join_autocomplete(const char * const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_account_autocomplete(const char * const input)
|
_account_autocomplete(ProfWin *window, const char * const input)
|
||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
@ -38,14 +38,15 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "xmpp/form.h"
|
#include "xmpp/form.h"
|
||||||
|
#include "ui/ui.h"
|
||||||
|
|
||||||
GHashTable *commands;
|
GHashTable *commands;
|
||||||
|
|
||||||
void cmd_init(void);
|
void cmd_init(void);
|
||||||
void cmd_uninit(void);
|
void cmd_uninit(void);
|
||||||
|
|
||||||
char* cmd_autocomplete(const char * const input);
|
char* cmd_autocomplete(ProfWin *window, const char * const input);
|
||||||
void cmd_reset_autocomplete(void);
|
void cmd_reset_autocomplete(ProfWin *window);
|
||||||
void cmd_autocomplete_add(char *value);
|
void cmd_autocomplete_add(char *value);
|
||||||
void cmd_autocomplete_remove(char *value);
|
void cmd_autocomplete_remove(char *value);
|
||||||
void cmd_autocomplete_add_form_fields(DataForm *form);
|
void cmd_autocomplete_add_form_fields(DataForm *form);
|
||||||
@ -53,8 +54,8 @@ void cmd_autocomplete_remove_form_fields(DataForm *form);
|
|||||||
void cmd_alias_add(char *value);
|
void cmd_alias_add(char *value);
|
||||||
void cmd_alias_remove(char *value);
|
void cmd_alias_remove(char *value);
|
||||||
|
|
||||||
gboolean cmd_process_input(char *inp);
|
gboolean cmd_process_input(ProfWin *window, char *inp);
|
||||||
void cmd_execute_connect(const char * const account);
|
void cmd_execute_connect(ProfWin *window, const char * const account);
|
||||||
|
|
||||||
gboolean cmd_exists(char *cmd);
|
gboolean cmd_exists(char *cmd);
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ cmd_execute_default(const char * inp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cmd_execute_alias(const char * const inp, gboolean *ran)
|
cmd_execute_alias(ProfWin *window, const char * const inp, gboolean *ran)
|
||||||
{
|
{
|
||||||
if (inp[0] != '/') {
|
if (inp[0] != '/') {
|
||||||
ran = FALSE;
|
ran = FALSE;
|
||||||
@ -145,7 +145,7 @@ cmd_execute_alias(const char * const inp, gboolean *ran)
|
|||||||
free(alias);
|
free(alias);
|
||||||
if (value) {
|
if (value) {
|
||||||
*ran = TRUE;
|
*ran = TRUE;
|
||||||
return cmd_process_input(value);
|
return cmd_process_input(window, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
*ran = FALSE;
|
*ran = FALSE;
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#ifndef COMMANDS_H
|
#ifndef COMMANDS_H
|
||||||
#define COMMANDS_H
|
#define COMMANDS_H
|
||||||
|
|
||||||
|
#include "ui/ui.h"
|
||||||
|
|
||||||
// Command help strings
|
// Command help strings
|
||||||
typedef struct cmd_help_t {
|
typedef struct cmd_help_t {
|
||||||
const gchar *usage;
|
const gchar *usage;
|
||||||
@ -62,7 +64,7 @@ typedef struct cmd_t {
|
|||||||
CommandHelp help;
|
CommandHelp help;
|
||||||
} Command;
|
} Command;
|
||||||
|
|
||||||
gboolean cmd_execute_alias(const char * const inp, gboolean *ran);
|
gboolean cmd_execute_alias(ProfWin *window, const char * const inp, gboolean *ran);
|
||||||
gboolean cmd_execute_default(const char * inp);
|
gboolean cmd_execute_default(const char * inp);
|
||||||
|
|
||||||
gboolean cmd_about(gchar **args, struct cmd_help_t help);
|
gboolean cmd_about(gchar **args, struct cmd_help_t help);
|
||||||
|
@ -89,7 +89,8 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
|
|||||||
|
|
||||||
line = ui_readline();
|
line = ui_readline();
|
||||||
if (line) {
|
if (line) {
|
||||||
cont = cmd_process_input(line);
|
ProfWin *window = wins_get_current();
|
||||||
|
cont = cmd_process_input(window, line);
|
||||||
free(line);
|
free(line);
|
||||||
line = NULL;
|
line = NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -141,12 +142,13 @@ prof_handle_activity(void)
|
|||||||
static void
|
static void
|
||||||
_connect_default(const char * const account)
|
_connect_default(const char * const account)
|
||||||
{
|
{
|
||||||
|
ProfWin *window = wins_get_current();
|
||||||
if (account) {
|
if (account) {
|
||||||
cmd_execute_connect(account);
|
cmd_execute_connect(window, account);
|
||||||
} else {
|
} else {
|
||||||
char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT);
|
char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT);
|
||||||
if (pref_connect_account) {
|
if (pref_connect_account) {
|
||||||
cmd_execute_connect(pref_connect_account);
|
cmd_execute_connect(window, pref_connect_account);
|
||||||
prefs_free_string(pref_connect_account);
|
prefs_free_string(pref_connect_account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,8 @@ _inp_rl_getc(FILE *stream)
|
|||||||
{
|
{
|
||||||
int ch = rl_getc(stream);
|
int ch = rl_getc(stream);
|
||||||
if (_inp_printable(ch)) {
|
if (_inp_printable(ch)) {
|
||||||
cmd_reset_autocomplete();
|
ProfWin *window = wins_get_current();
|
||||||
|
cmd_reset_autocomplete(window);
|
||||||
}
|
}
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
@ -442,7 +443,8 @@ _inp_rl_tab_handler(int count, int key)
|
|||||||
rl_point = rl_end;
|
rl_point = rl_end;
|
||||||
}
|
}
|
||||||
} else if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
} else if (strncmp(rl_line_buffer, "/", 1) == 0) {
|
||||||
char *result = cmd_autocomplete(rl_line_buffer);
|
ProfWin *window = wins_get_current();
|
||||||
|
char *result = cmd_autocomplete(window, rl_line_buffer);
|
||||||
if (result) {
|
if (result) {
|
||||||
rl_replace_line(result, 0);
|
rl_replace_line(result, 0);
|
||||||
rl_point = rl_end;
|
rl_point = rl_end;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user