diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-04-15 16:18:43 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-04-15 21:22:01 +0200 |
commit | 51ca5c79e4174a67aa1e50402c28ecf0a06798e4 (patch) | |
tree | 76022a04b4a4d2de7673e68239b26d284c4a9221 | |
parent | 23298f3a0e2426b758de3ad472abc8487ccb37f7 (diff) | |
download | xK-51ca5c79e4174a67aa1e50402c28ecf0a06798e4.tar.gz xK-51ca5c79e4174a67aa1e50402c28ecf0a06798e4.tar.xz xK-51ca5c79e4174a67aa1e50402c28ecf0a06798e4.zip |
degesch: show active buffers in prompt
-rw-r--r-- | degesch.c | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -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 |