summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-04-15 16:18:43 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-04-15 21:22:01 +0200
commit51ca5c79e4174a67aa1e50402c28ecf0a06798e4 (patch)
tree76022a04b4a4d2de7673e68239b26d284c4a9221
parent23298f3a0e2426b758de3ad472abc8487ccb37f7 (diff)
downloadxK-51ca5c79e4174a67aa1e50402c28ecf0a06798e4.tar.gz
xK-51ca5c79e4174a67aa1e50402c28ecf0a06798e4.tar.xz
xK-51ca5c79e4174a67aa1e50402c28ecf0a06798e4.zip
degesch: show active buffers in prompt
-rw-r--r--degesch.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/degesch.c b/degesch.c
index 358e592..1786770 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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