what is happening ??
This commit is contained in:
@@ -21,20 +21,20 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public final class Main extends Application {
|
public final class Main extends Application {
|
||||||
private TerminalWorkspace workspace;
|
private Compositor compositor;
|
||||||
private TerminalCanvasView terminalView;
|
private TerminalMetrics metrics;
|
||||||
private AppConfig config;
|
private AppConfig config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) {
|
public void start(Stage stage) {
|
||||||
config = AppConfig.load();
|
config = AppConfig.load();
|
||||||
|
|
||||||
workspace = new TerminalWorkspace(config);
|
metrics = new TerminalMetrics(config.fontFamily(), config.fontSize());
|
||||||
terminalView = new TerminalCanvasView(workspace, config);
|
compositor = new Compositor(config, metrics);
|
||||||
|
|
||||||
StackPane root = new StackPane(terminalView.canvas());
|
StackPane root = new StackPane(compositor.canvas());
|
||||||
terminalView.canvas().widthProperty().bind(root.widthProperty());
|
compositor.canvas().widthProperty().bind(root.widthProperty());
|
||||||
terminalView.canvas().heightProperty().bind(root.heightProperty());
|
compositor.canvas().heightProperty().bind(root.heightProperty());
|
||||||
|
|
||||||
Scene scene = new Scene(root, config.windowWidth(), config.windowHeight());
|
Scene scene = new Scene(root, config.windowWidth(), config.windowHeight());
|
||||||
scene.addEventFilter(KeyEvent.KEY_PRESSED, this::handlePressed);
|
scene.addEventFilter(KeyEvent.KEY_PRESSED, this::handlePressed);
|
||||||
@@ -43,57 +43,57 @@ public final class Main extends Application {
|
|||||||
new AnimationTimer() {
|
new AnimationTimer() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(long now) {
|
public void handle(long now) {
|
||||||
terminalView.render();
|
compositor.render();
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
stage.setTitle("jprototerm");
|
stage.setTitle("jprototerm");
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setOnCloseRequest(event -> {
|
stage.setOnCloseRequest(event -> {
|
||||||
workspace.close();
|
compositor.close();
|
||||||
});
|
});
|
||||||
stage.show();
|
stage.show();
|
||||||
terminalView.canvas().requestFocus();
|
compositor.canvas().requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePressed(KeyEvent event) {
|
private void handlePressed(KeyEvent event) {
|
||||||
if (config.keybindings().get("navigate_left").matches(event)) {
|
if (config.keybindings().get("navigate_left").matches(event)) {
|
||||||
workspace.navigate(Direction.LEFT);
|
compositor.navigate(Direction.LEFT);
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("navigate_down").matches(event)) {
|
} else if (config.keybindings().get("navigate_down").matches(event)) {
|
||||||
workspace.navigate(Direction.DOWN);
|
compositor.navigate(Direction.DOWN);
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("navigate_up").matches(event)) {
|
} else if (config.keybindings().get("navigate_up").matches(event)) {
|
||||||
workspace.navigate(Direction.UP);
|
compositor.navigate(Direction.UP);
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("navigate_right").matches(event)) {
|
} else if (config.keybindings().get("navigate_right").matches(event)) {
|
||||||
workspace.navigate(Direction.RIGHT);
|
compositor.navigate(Direction.RIGHT);
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("toggle_floating").matches(event)) {
|
} else if (config.keybindings().get("toggle_floating").matches(event)) {
|
||||||
workspace.toggleFloating();
|
compositor.toggleFloating();
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("new_pane").matches(event)) {
|
} else if (config.keybindings().get("new_pane").matches(event)) {
|
||||||
workspace.createPane();
|
compositor.createPane();
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("next_floating").matches(event)) {
|
} else if (config.keybindings().get("next_floating").matches(event)) {
|
||||||
workspace.nextFloatingPane();
|
compositor.nextFloatingPane();
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("close_pane").matches(event)) {
|
} else if (config.keybindings().get("close_pane").matches(event)) {
|
||||||
workspace.closeActivePane();
|
compositor.closeActivePane();
|
||||||
event.consume();
|
event.consume();
|
||||||
if (workspace.isEmpty()) {
|
if (compositor.isEmpty()) {
|
||||||
// Closing the last pane quits the app.
|
// Closing the last pane quits the app.
|
||||||
workspace.close();
|
compositor.close();
|
||||||
Platform.exit();
|
Platform.exit();
|
||||||
}
|
}
|
||||||
} else if (config.keybindings().get("new_tab").matches(event)) {
|
} else if (config.keybindings().get("new_tab").matches(event)) {
|
||||||
workspace.newTab();
|
compositor.newTab();
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("previous_tab").matches(event)) {
|
} else if (config.keybindings().get("previous_tab").matches(event)) {
|
||||||
workspace.previousTab();
|
compositor.previousTab();
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("next_tab").matches(event)) {
|
} else if (config.keybindings().get("next_tab").matches(event)) {
|
||||||
workspace.nextTab();
|
compositor.nextTab();
|
||||||
event.consume();
|
event.consume();
|
||||||
} else if (config.keybindings().get("open_font_selector").matches(event)) {
|
} else if (config.keybindings().get("open_font_selector").matches(event)) {
|
||||||
openFontSelector();
|
openFontSelector();
|
||||||
@@ -104,7 +104,7 @@ public final class Main extends Application {
|
|||||||
} else {
|
} else {
|
||||||
String encoded = KeyEncoder.encode(event);
|
String encoded = KeyEncoder.encode(event);
|
||||||
if (encoded != null) {
|
if (encoded != null) {
|
||||||
workspace.activePane().send(encoded);
|
compositor.activePane().send(encoded);
|
||||||
event.consume();
|
event.consume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ public final class Main extends Application {
|
|||||||
|
|
||||||
String text = event.getCharacter();
|
String text = event.getCharacter();
|
||||||
if (text != null && !text.isEmpty() && text.charAt(0) >= 0x20 && text.charAt(0) != 0x7f) {
|
if (text != null && !text.isEmpty() && text.charAt(0) >= 0x20 && text.charAt(0) != 0x7f) {
|
||||||
workspace.activePane().send(text);
|
compositor.activePane().send(text);
|
||||||
event.consume();
|
event.consume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,18 +160,18 @@ public final class Main extends Application {
|
|||||||
double selectedSize = size.getValue();
|
double selectedSize = size.getValue();
|
||||||
config = config.withFont(selectedFamily.trim(), selectedSize);
|
config = config.withFont(selectedFamily.trim(), selectedSize);
|
||||||
config.save();
|
config.save();
|
||||||
terminalView.setFont(config.fontFamily(), config.fontSize());
|
compositor.setFont(config.fontFamily(), config.fontSize());
|
||||||
terminalView.canvas().requestFocus();
|
compositor.canvas().requestFocus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openScrollbackInEditor() {
|
private void openScrollbackInEditor() {
|
||||||
try {
|
try {
|
||||||
Path file = Files.createTempFile("jprototerm-scrollback-", ".txt");
|
Path file = Files.createTempFile("jprototerm-scrollback-", ".txt");
|
||||||
Files.writeString(file, workspace.activePane().scrollbackText());
|
Files.writeString(file, compositor.activePane().scrollbackText());
|
||||||
file.toFile().deleteOnExit();
|
file.toFile().deleteOnExit();
|
||||||
|
|
||||||
workspace.activePane().send(scrollbackEditorCommand(file) + "\r");
|
compositor.activePane().send(scrollbackEditorCommand(file) + "\r");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.err.println("Could not open scrollback in editor: " + ex.getMessage());
|
System.err.println("Could not open scrollback in editor: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user