mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Allow /wins swap to move to empty position
This commit is contained in:
parent
547b6cf4da
commit
e9ddbab585
@ -478,6 +478,8 @@ cmd_wins(gchar **args, struct cmd_help_t help)
|
||||
int target_win = atoi(args[2]);
|
||||
if ((source_win == 1) || (target_win == 1)) {
|
||||
cons_show("Cannot move console window.");
|
||||
} else if (source_win == 10 || target_win == 10) {
|
||||
cons_show("Window 10 does not exist");
|
||||
} else if (source_win != target_win) {
|
||||
gboolean swapped = ui_swap_wins(source_win, target_win);
|
||||
if (swapped) {
|
||||
|
@ -691,7 +691,6 @@ static gboolean
|
||||
_ui_switch_win(const int i)
|
||||
{
|
||||
if (ui_win_exists(i)) {
|
||||
ui_current_page_off();
|
||||
ProfWin *new_current = wins_get_by_num(i);
|
||||
wins_set_current_by_num(i);
|
||||
ui_current_page_off();
|
||||
|
@ -394,6 +394,7 @@ wins_swap(int source_win, int target_win)
|
||||
if (source != NULL) {
|
||||
ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win));
|
||||
|
||||
// target window empty
|
||||
if (target == NULL) {
|
||||
g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
|
||||
status_bar_inactive(source_win);
|
||||
@ -407,8 +408,27 @@ wins_swap(int source_win, int target_win)
|
||||
ui_switch_win(1);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
// target window occupied
|
||||
} else {
|
||||
return FALSE;
|
||||
g_hash_table_steal(windows, GINT_TO_POINTER(source_win));
|
||||
g_hash_table_steal(windows, GINT_TO_POINTER(target_win));
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(source_win), target);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source);
|
||||
if (source->unread > 0) {
|
||||
status_bar_new(target_win);
|
||||
} else {
|
||||
status_bar_active(target_win);
|
||||
}
|
||||
if (target->unread > 0) {
|
||||
status_bar_new(source_win);
|
||||
} else {
|
||||
status_bar_active(source_win);
|
||||
}
|
||||
if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
|
||||
ui_switch_win(1);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
} else {
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user