diff options
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/actions.c b/src/actions.c index e31df72..d847fa7 100644 --- a/src/actions.c +++ b/src/actions.c @@ -79,6 +79,9 @@ static cmdret * set_historyexpansion (struct cmdarg **args); LIST_HEAD(set_vars); +/* FIXME This variable should really be kept static for group.c */ +extern struct numset *group_numset; + static void add_set_var (char *name, cmdret * (*fn)(struct cmdarg **), int nargs, ...) { @@ -261,6 +264,9 @@ init_user_commands(void) "Name: ", arg_STRING); add_command ("gnewbg", cmd_gnewbg, 1, 1, 1, "Name: ", arg_STRING); + add_command ("gnumber", cmd_gnumber, 2, 1, 1, + "Number: ", arg_NUMBER, + "Number: ", arg_NUMBER); add_command ("grename", cmd_grename, 1, 1, 1, "Change group name to: ", arg_REST); add_command ("gnext", cmd_gnext, 0, 0, 0); @@ -5077,6 +5083,59 @@ cmd_gnewbg (int interactive UNUSED, struct cmdarg **args) } cmdret * +cmd_gnumber (int interactive UNUSED, struct cmdarg **args) +{ + int old_number, new_number; + rp_group *other_g, *g; + +/* FIXME Implement this. */ +// if (args[0] == NULL) +// { +// /* XXX: Fix this. */ +// print_window_information (rp_current_group, current_window()); +// return cmdret_new (RET_SUCCESS, NULL); +// } + + /* Gather the args. */ + new_number = ARG(0,number); + if (args[1]) + g = groups_find_group_by_number (ARG(1,number)); + else + g = rp_current_group; + + /* Make the switch. */ + if ( new_number >= 0 && g) + { + /* Find other window with same number and give it old number. */ + other_g = groups_find_group_by_number (new_number); + if (other_g != NULL) + { + old_number = g->number; + other_g->number = old_number; + + /* Resort the window in the list */ + group_resort_group (other_g); + } + else + { + numset_release (group_numset, g->number); + } + + g->number = new_number; + numset_add_num (group_numset, new_number); + + /* 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); + } + + return cmdret_new (RET_SUCCESS, NULL); +} + +cmdret * cmd_grename (int interactive UNUSED, struct cmdarg **args) { if (groups_find_group_by_name (ARG_STRING (0), 1)) |