mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 18:56:21 +00:00
Added command /wins swap
This commit is contained in:
@@ -347,13 +347,14 @@ static struct cmd_t command_defs[] =
|
||||
NULL } } },
|
||||
|
||||
{ "/wins",
|
||||
cmd_wins, parse_args, 0, 1, NULL,
|
||||
{ "/wins [tidy|prune]", "List or tidy active windows.",
|
||||
{ "/wins [tidy|prune]",
|
||||
"------------------",
|
||||
cmd_wins, parse_args, 0, 3, NULL,
|
||||
{ "/wins [tidy|prune|swap] [source] [target]", "List or tidy active windows.",
|
||||
{ "/wins [tidy|prune] [source] [target]",
|
||||
"------------------------------------",
|
||||
"Passing no argument will list all currently active windows and information about their usage.",
|
||||
"tidy : Shuffle windows so there are no gaps.",
|
||||
"prune : Close all windows with no unread messages, and then tidy as above.",
|
||||
"tidy : Shuffle windows so there are no gaps.",
|
||||
"prune : Close all windows with no unread messages, and then tidy as above.",
|
||||
"swap source target : Swap windows.",
|
||||
NULL } } },
|
||||
|
||||
{ "/sub",
|
||||
@@ -1026,6 +1027,7 @@ cmd_init(void)
|
||||
wins_ac = autocomplete_new();
|
||||
autocomplete_add(wins_ac, "prune");
|
||||
autocomplete_add(wins_ac, "tidy");
|
||||
autocomplete_add(wins_ac, "swap");
|
||||
|
||||
roster_ac = autocomplete_new();
|
||||
autocomplete_add(roster_ac, "add");
|
||||
|
||||
@@ -470,7 +470,27 @@ cmd_wins(gchar **args, struct cmd_help_t help)
|
||||
ui_tidy_wins();
|
||||
} else if (strcmp(args[0], "prune") == 0) {
|
||||
ui_prune_wins();
|
||||
} else if (strcmp(args[0], "swap") == 0) {
|
||||
if ((args[1] == NULL) || (args[2] == NULL)) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
} else {
|
||||
int source_win = atoi(args[1]);
|
||||
int target_win = atoi(args[2]);
|
||||
if ((source_win == 1) || (target_win == 1)) {
|
||||
cons_show("Cannot move console window.");
|
||||
} else if (source_win != target_win) {
|
||||
gboolean swapped = ui_swap_wins(source_win, target_win);
|
||||
if (swapped) {
|
||||
cons_show("Swapped windows %d <-> %d", source_win, target_win);
|
||||
} else {
|
||||
cons_show("Window %d does not exist", source_win);
|
||||
}
|
||||
} else {
|
||||
cons_show("Same source and target window supplied.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user