1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Added autocomplete for nicknames in MUC input text

issue #321
This commit is contained in:
James Booth 2014-07-09 00:35:43 +01:00
parent 06caa0c4f1
commit 4b14c0c484
3 changed files with 36 additions and 1 deletions

View File

@ -29,6 +29,7 @@
#include "common.h"
#include "jid.h"
#include "tools/autocomplete.h"
#include "ui/ui.h"
typedef struct _muc_room_t {
char *room; // e.g. test@conference.server
@ -567,6 +568,32 @@ muc_complete_roster_nick_change(const char * const room,
return NULL;
}
void
muc_autocomplete(char *input, int *size)
{
char *recipient = ui_current_recipient();
Autocomplete nick_ac = muc_get_roster_ac(recipient);
if (nick_ac != NULL) {
input[*size] = '\0';
gchar *last_space = g_strrstr(input, " ");
char *result = NULL;
if (last_space == NULL) {
result = autocomplete_complete(nick_ac, input);
} else {
int len = (last_space - input);
cons_debug("SIZE: %d", len);
char *start_str = strndup(input, len);
result = autocomplete_param_with_ac(input, size, start_str, nick_ac);
free(start_str);
}
if (result != NULL) {
ui_replace_input(input, result, size);
g_free(result);
return;
}
}
}
static void
_free_room(ChatRoom *room)
{

View File

@ -76,4 +76,6 @@ char * muc_get_subject(const char * const room);
void muc_add_pending_broadcast(const char * const room, const char * const message);
GList * muc_get_pending_broadcasts(const char * const room);
void muc_autocomplete(char *input, int *size);
#endif

View File

@ -39,6 +39,7 @@
#include "config/preferences.h"
#include "config/theme.h"
#include "log.h"
#include "muc.h"
#include "profanity.h"
#include "roster_list.h"
#include "ui/ui.h"
@ -511,7 +512,12 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
return 1;
case 9: // tab
if ((strncmp(input, "/", 1) != 0) && (ui_current_win_type() == WIN_MUC)) {
cons_debug("MUC AC");
muc_autocomplete(input, size);
} else {
cmd_autocomplete(input, size);
}
return 1;
default: