diff --git a/src/main/java/com/gregor/jprototerm/AppConfig.java b/src/main/java/com/gregor/jprototerm/AppConfig.java index 1e4a580..33a7d02 100644 --- a/src/main/java/com/gregor/jprototerm/AppConfig.java +++ b/src/main/java/com/gregor/jprototerm/AppConfig.java @@ -36,7 +36,7 @@ public record AppConfig( "navigate_up", "navigate_right", "toggle_floating", - "new_floating", + "new_pane", "next_floating", "close_pane", "open_font_selector", @@ -92,7 +92,7 @@ public record AppConfig( "navigate_up", KeyBinding.parse("ALT+K"), "navigate_right", KeyBinding.parse("ALT+L"), "toggle_floating", KeyBinding.parse("ALT+F"), - "new_floating", KeyBinding.parse("ALT+SHIFT+F"), + "new_pane", KeyBinding.parse("ALT+N"), "next_floating", KeyBinding.parse("ALT+F12"), "close_pane", KeyBinding.parse("ALT+X"), "open_font_selector", KeyBinding.parse("ALT+T"), diff --git a/src/main/java/com/gregor/jprototerm/Main.java b/src/main/java/com/gregor/jprototerm/Main.java index a4c8816..d0bd7bd 100644 --- a/src/main/java/com/gregor/jprototerm/Main.java +++ b/src/main/java/com/gregor/jprototerm/Main.java @@ -71,8 +71,8 @@ public final class Main extends Application { } else if (config.keybindings().get("toggle_floating").matches(event)) { workspace.toggleFloating(); event.consume(); - } else if (config.keybindings().get("new_floating").matches(event)) { - workspace.createFloatingPane(); + } else if (config.keybindings().get("new_pane").matches(event)) { + workspace.createPane(); event.consume(); } else if (config.keybindings().get("next_floating").matches(event)) { workspace.nextFloatingPane(); diff --git a/src/main/java/com/gregor/jprototerm/TerminalWorkspace.java b/src/main/java/com/gregor/jprototerm/TerminalWorkspace.java index 1360cc5..18130f3 100644 --- a/src/main/java/com/gregor/jprototerm/TerminalWorkspace.java +++ b/src/main/java/com/gregor/jprototerm/TerminalWorkspace.java @@ -131,6 +131,25 @@ public final class TerminalWorkspace implements AutoCloseable { version++; } + /** + * "New pane": adds a floating pane while floating panes are shown, otherwise adds a + * tiled pane (the tiled row is redistributed equally by the layout). + */ + public void createPane() { + if (anyFloatingVisible()) { + createFloatingPane(); + } else { + TerminalPane pane = openPane(false); + panes.add(pane); + activeIndex = panes.size() - 1; + version++; + } + } + + private boolean anyFloatingVisible() { + return panes.stream().anyMatch(pane -> pane.floating() && pane.visible()); + } + public void nextFloatingPane() { TerminalPane next = nextFloatingAfter(activeIndex); next.setVisible(true);