promote floating
This commit is contained in:
@@ -38,6 +38,7 @@ public record AppConfig(
|
||||
"toggle_floating",
|
||||
"new_pane",
|
||||
"next_floating",
|
||||
"promote_floating",
|
||||
"close_pane",
|
||||
"new_tab",
|
||||
"previous_tab",
|
||||
@@ -98,6 +99,7 @@ public record AppConfig(
|
||||
Map.entry("toggle_floating", KeyBinding.parse("ALT+F")),
|
||||
Map.entry("new_pane", KeyBinding.parse("ALT+N")),
|
||||
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("new_tab", KeyBinding.parse("ALT+A")),
|
||||
Map.entry("previous_tab", KeyBinding.parse("ALT+SHIFT+H")),
|
||||
|
||||
@@ -139,6 +139,14 @@ public final class Compositor {
|
||||
layoutVersion++;
|
||||
}
|
||||
|
||||
public void promoteActiveFloating() {
|
||||
if (isEmpty()) {
|
||||
return;
|
||||
}
|
||||
currentTab().promoteActiveFloating();
|
||||
layoutVersion++;
|
||||
}
|
||||
|
||||
public void closeActivePane() {
|
||||
if (isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -109,6 +109,9 @@ public final class Main extends Application {
|
||||
} else if (config.keybindings().get("next_floating").matches(event)) {
|
||||
compositor.nextFloatingPane();
|
||||
event.consume();
|
||||
} else if (config.keybindings().get("promote_floating").matches(event)) {
|
||||
compositor.promoteActiveFloating();
|
||||
event.consume();
|
||||
} else if (config.keybindings().get("close_pane").matches(event)) {
|
||||
compositor.closeActivePane();
|
||||
event.consume();
|
||||
|
||||
@@ -222,6 +222,22 @@ final class Tab implements AutoCloseable {
|
||||
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() {
|
||||
TerminalPane closing = active;
|
||||
boolean wasFloating = floating.remove(closing);
|
||||
|
||||
Reference in New Issue
Block a user