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/actions.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/actions.c')
-rw-r--r-- | src/actions.c | 79 |
1 files changed, 24 insertions, 55 deletions
diff --git a/src/actions.c b/src/actions.c index 20f4063..3f9691e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -5118,9 +5118,8 @@ cmd_gnumber (int interactive UNUSED, struct cmdarg **args) /* resort the the window in the list */ group_resort_group (g); -/* FIXME Implement updating of groups bar. */ -// /* Update the window list. */ -// update_window_names (win->win->scr, defaults.window_fmt); + /* Update the group list. */ + update_group_names (current_screen()); } return cmdret_new (RET_SUCCESS, NULL); @@ -5132,6 +5131,10 @@ cmd_grename (int interactive UNUSED, struct cmdarg **args) if (groups_find_group_by_name (ARG_STRING (0), 1)) return cmdret_new (RET_FAILURE, "grename: duplicate group name"); group_rename (rp_current_group, ARG_STRING(0)); + + /* Update the group list. */ + update_group_names (current_screen()); + return cmdret_new (RET_SUCCESS, NULL); } @@ -5154,65 +5157,31 @@ cmd_gselect (int interactive, struct cmdarg **args) cmdret * cmd_groups (int interactive, struct cmdarg **args UNUSED) { - rp_group *cur; - int mark_start = 0, mark_end = 0; - struct sbuf *buffer; - rp_group *last; - - last = group_last_group (); - buffer = sbuf_new (0); - - /* 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)); - - /* Pad start of group name with a space for row - style. non-Interactive always gets a column.*/ - if (defaults.window_list_style == STYLE_ROW && interactive) - sbuf_concat (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); - - /* Pad end of group name with a space for row style. */ - if (defaults.window_list_style == STYLE_ROW && interactive) - { - sbuf_concat (buffer, " "); - } - else - { - if (cur->node.next != &rp_groups) - sbuf_concat (buffer, "\n"); - } - - if (cur == rp_current_group) - mark_end = strlen (sbuf_get (buffer)); - } + struct sbuf *group_list = NULL; + int dummy; + rp_screen *s; - /* Display it or return it. */ if (interactive) { - marked_message (sbuf_get (buffer), mark_start, mark_end); - sbuf_free (buffer); + s = current_screen (); + /* This is a yukky hack. If the bar already hidden then show the + bar. This handles the case when msgwait is 0 (the bar sticks) + and the user uses this command to toggle the bar on and + off. OR the timeout is >0 then show the bar. Which means, + always show the bar if msgwait is >0 which fixes the case + when a command in the prefix hook displays the bar. */ + if (!hide_bar (s) || defaults.bar_timeout > 0) show_group_bar (s); + return cmdret_new (RET_SUCCESS, NULL); } else { - cmdret *ret = cmdret_new (RET_SUCCESS, "%s", sbuf_get(buffer)); - sbuf_free(buffer); + cmdret *ret; + + group_list = sbuf_new (0); + get_group_list ("\n", group_list, &dummy, &dummy); + ret = cmdret_new (RET_SUCCESS, "%s", sbuf_get (group_list)); + sbuf_free (group_list); return ret; } } |