diff options
author | cos <cos> | 2013-05-24 18:55:31 +0200 |
---|---|---|
committer | cos <cos> | 2013-05-26 20:31:42 +0200 |
commit | d3793dba2a57d2512ca0a7987b3385986ec2c9ea (patch) | |
tree | 953a2510d92495a9625878c7954d9d6c7af4b3d7 /src/group.c | |
parent | 472a958a2ce149313239fb5eb4244f7607887b31 (diff) | |
download | ratpoison-d3793dba2a57d2512ca0a7987b3385986ec2c9ea.zip |
Adapt group bar to be updated on group number or name change.cr/implement_gnumber-with_winliststyle
Diffstat (limited to 'src/group.c')
-rw-r--r-- | src/group.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/group.c b/src/group.c index e882e8d..2bbfead 100644 --- a/src/group.c +++ b/src/group.c @@ -66,6 +66,61 @@ group_get_numset(void) 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 = '-'; + + /* A hack, pad the group with a space at the beginning and end + if there is no delimiter. */ + if (!delim) + sbuf_concat (buffer, " "); + + fmt = xsprintf ("%d%c%s", cur->number, separator, cur->name); + sbuf_concat (buffer, fmt); + free (fmt); + + /* A hack, pad the group with a space at the beginning and end + if there is no delimiter. */ + if (!delim) + sbuf_concat (buffer, " "); + + /* Only put the delimiter between the group, and not after the the last + group. */ + if (delim && 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) { |