degesch: show active buffers in prompt

This commit is contained in:
Přemysl Eric Janouch 2015-04-15 16:18:43 +02:00
parent 23298f3a0e
commit 51ca5c79e4

View File

@ -1216,6 +1216,31 @@ irc_establish_connection (struct app_context *ctx,
// --- More readline funky stuff -----------------------------------------------
static char *
get_unseen_prefix (struct app_context *ctx)
{
struct str active_buffers;
str_init (&active_buffers);
size_t i = 0;
LIST_FOR_EACH (struct buffer, iter, ctx->buffers)
{
i++;
if (!iter->unseen_messages_count)
continue;
if (active_buffers.len)
str_append_c (&active_buffers, ',');
str_append_printf (&active_buffers, "%zu", i);
}
if (active_buffers.len)
return str_steal (&active_buffers);
str_free (&active_buffers);
return NULL;
}
static void
refresh_prompt (struct app_context *ctx)
{
@ -1229,8 +1254,11 @@ refresh_prompt (struct app_context *ctx)
else
{
str_append_c (&prompt, '[');
// TODO: go through all buffers and prepend the active ones,
// such as "(1,4) "
char *unseen_prefix = get_unseen_prefix (ctx);
if (unseen_prefix)
str_append_printf (&prompt, "(%s) ", unseen_prefix);
free (unseen_prefix);
// TODO: name of the current buffer
// TODO: the channel user mode