aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-10 00:23:23 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-10 00:23:23 +0200
commit7c9a1f50da19191209b7f908bc553c98dacb1e47 (patch)
tree725bb0bcac1d42c5e77d2dfbba2cf00d35f7ac56 /degesch.c
parent2ef7323f265ec4b3ee186309a945b601c1e35fd7 (diff)
downloadxK-7c9a1f50da19191209b7f908bc553c98dacb1e47.tar.gz
xK-7c9a1f50da19191209b7f908bc553c98dacb1e47.tar.xz
xK-7c9a1f50da19191209b7f908bc553c98dacb1e47.zip
degesch: add nickname autocompletion
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/degesch.c b/degesch.c
index cfa44a6..7aa9649 100644
--- a/degesch.c
+++ b/degesch.c
@@ -5330,7 +5330,22 @@ static void
complete_nicknames (struct app_context *ctx, struct completion *data,
const char *word, struct str_vector *output)
{
- // TODO; if (data->location == 0) --> add colons to nicknames
+ if (ctx->current_buffer->type != BUFFER_CHANNEL)
+ return;
+ struct channel *channel = ctx->current_buffer->channel;
+
+ // XXX: this is a bit hackish and doesn't respect server case mapping
+ char *mask = xstrdup_printf ("%s*", word);
+ LIST_FOR_EACH (struct channel_user, iter, channel->users)
+ {
+ const char *nickname = iter->user->nickname;
+ if (fnmatch (mask, nickname, 0))
+ continue;
+ str_vector_add_owned (output, data->location == 0
+ ? xstrdup_printf ("%s:", nickname)
+ : xstrdup (nickname));
+ }
+ free (mask);
}
static char **