promote floating

This commit is contained in:
2026-06-01 14:39:00 +02:00
parent 40230dd8f7
commit 1895a48550
4 changed files with 29 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ public record AppConfig(
"toggle_floating", "toggle_floating",
"new_pane", "new_pane",
"next_floating", "next_floating",
"promote_floating",
"close_pane", "close_pane",
"new_tab", "new_tab",
"previous_tab", "previous_tab",
@@ -98,6 +99,7 @@ public record AppConfig(
Map.entry("toggle_floating", KeyBinding.parse("ALT+F")), Map.entry("toggle_floating", KeyBinding.parse("ALT+F")),
Map.entry("new_pane", KeyBinding.parse("ALT+N")), Map.entry("new_pane", KeyBinding.parse("ALT+N")),
Map.entry("next_floating", KeyBinding.parse("ALT+F12")), Map.entry("next_floating", KeyBinding.parse("ALT+F12")),
Map.entry("promote_floating", KeyBinding.parse("ALT+P")),
Map.entry("close_pane", KeyBinding.parse("ALT+X")), Map.entry("close_pane", KeyBinding.parse("ALT+X")),
Map.entry("new_tab", KeyBinding.parse("ALT+A")), Map.entry("new_tab", KeyBinding.parse("ALT+A")),
Map.entry("previous_tab", KeyBinding.parse("ALT+SHIFT+H")), Map.entry("previous_tab", KeyBinding.parse("ALT+SHIFT+H")),

View File

@@ -139,6 +139,14 @@ public final class Compositor {
layoutVersion++; layoutVersion++;
} }
public void promoteActiveFloating() {
if (isEmpty()) {
return;
}
currentTab().promoteActiveFloating();
layoutVersion++;
}
public void closeActivePane() { public void closeActivePane() {
if (isEmpty()) { if (isEmpty()) {
return; return;

View File

@@ -109,6 +109,9 @@ public final class Main extends Application {
} else if (config.keybindings().get("next_floating").matches(event)) { } else if (config.keybindings().get("next_floating").matches(event)) {
compositor.nextFloatingPane(); compositor.nextFloatingPane();
event.consume(); event.consume();
} else if (config.keybindings().get("promote_floating").matches(event)) {
compositor.promoteActiveFloating();
event.consume();
} else if (config.keybindings().get("close_pane").matches(event)) { } else if (config.keybindings().get("close_pane").matches(event)) {
compositor.closeActivePane(); compositor.closeActivePane();
event.consume(); event.consume();

View File

@@ -222,6 +222,22 @@ final class Tab implements AutoCloseable {
setActive(floating.get((current + 1 + floating.size()) % floating.size())); setActive(floating.get((current + 1 + floating.size()) % floating.size()));
} }
/** Promotes the active floating pane to a tiled pane, joining the tiled row. No-op otherwise. */
void promoteActiveFloating() {
TerminalPane promote = active;
if (!floating.remove(promote)) {
return; // active pane is tiled (or there is none); nothing to promote
}
if (promote == lastFocusedFloating) {
lastFocusedFloating = floating.isEmpty() ? null : floating.get(floating.size() - 1);
}
tiled.add(promote);
if (floating.isEmpty()) {
floatingVisible = false;
}
setActive(promote);
}
void closeActivePane() { void closeActivePane() {
TerminalPane closing = active; TerminalPane closing = active;
boolean wasFloating = floating.remove(closing); boolean wasFloating = floating.remove(closing);