summaryrefslogtreecommitdiff
path: root/src/group.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/group.c')
-rw-r--r--src/group.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/group.c b/src/group.c
index cca95a2..f45877f 100644
--- a/src/group.c
+++ b/src/group.c
@@ -66,6 +66,51 @@ group_get_numset()
return group_numset;
}
+/* get the group list and store it in buffer delimiting each window
+ with delim. mark_start and mark_end will be filled with the text
+ positions for the start and end of the current window. */
+void
+get_group_list (char *delim, struct sbuf *buffer,
+ int *mark_start, int *mark_end)
+{
+ rp_group *cur;
+
+ if (buffer == NULL) return;
+
+ sbuf_clear (buffer);
+
+ rp_group *last;
+
+ last = group_last_group ();
+
+ /* Generate the string. */
+ list_for_each_entry (cur, &rp_groups, node)
+ {
+ char *fmt;
+ char separator;
+
+ if (cur == rp_current_group)
+ *mark_start = strlen (sbuf_get (buffer));
+
+ if(cur == rp_current_group)
+ separator = '*';
+ else if(cur == last)
+ separator = '+';
+ else
+ separator = '-';
+
+ fmt = xsprintf ("%d%c%s", cur->number, separator, cur->name);
+ sbuf_concat (buffer, fmt);
+ free (fmt);
+
+ if (cur->node.next != &rp_groups)
+ sbuf_concat (buffer, delim);
+
+ if (cur == rp_current_group)
+ *mark_end = strlen (sbuf_get (buffer));
+ }
+}
+
rp_group *
group_new (int number, char *name)
{