improve terminal resizing behaviour

This commit is contained in:
Craig Raw 2022-11-09 12:15:12 +02:00
parent ea64fa0f85
commit fd0fe1110d
2 changed files with 14 additions and 15 deletions

View file

@ -57,6 +57,10 @@ public class SparrowTerminal extends Application {
this.gui = new SparrowTextGui(this, screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
EventManager.get().register(gui);
terminal.addResizeListener((terminal1, newSize) -> {
gui.handleResize();
});
sparrowTerminal = this;
try {

View file

@ -1,7 +1,6 @@
package com.sparrowwallet.sparrow.terminal;
import com.google.common.eventbus.Subscribe;
import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.TextColor;
import com.googlecode.lanterna.gui2.*;
import com.googlecode.lanterna.screen.Screen;
@ -15,11 +14,12 @@ import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.util.Duration;
import java.util.Objects;
public class SparrowTextGui extends MultiWindowTextGUI {
private final BasicWindow mainWindow;
private final Panel titleBar;
private final Panel statusBar;
private final Label connectedLabel;
private final Label statusLabel;
private final ProgressBar statusProgress;
@ -36,7 +36,7 @@ public class SparrowTextGui extends MultiWindowTextGUI {
Panel panel = new Panel(new BorderLayout());
Panel titleBar = new Panel(new GridLayout(2));
titleBar = new Panel(new GridLayout(2));
new Label("Sparrow Terminal").addTo(titleBar);
this.connectedLabel = new Label("Disconnected");
titleBar.addComponent(connectedLabel, GridLayout.createLayoutData(GridLayout.Alignment.END, GridLayout.Alignment.CENTER, true, false));
@ -44,7 +44,7 @@ public class SparrowTextGui extends MultiWindowTextGUI {
panel.addComponent(new EmptySpace(TextColor.ANSI.BLUE));
Panel statusBar = new Panel(new GridLayout(2));
statusBar = new Panel(new GridLayout(2));
this.statusLabel = new Label("").addTo(statusBar);
this.statusProgress = new ProgressBar(0, 100, 10);
statusBar.addComponent(statusProgress, GridLayout.createLayoutData(GridLayout.Alignment.END, GridLayout.Alignment.CENTER, true, false));
@ -55,18 +55,13 @@ public class SparrowTextGui extends MultiWindowTextGUI {
panel.addComponent(statusBar, BorderLayout.Location.BOTTOM);
getBackgroundPane().setComponent(panel);
getMainWindow().addWindowListener(new WindowListenerAdapter() {
@Override
public void onResized(Window window, TerminalSize oldSize, TerminalSize newSize) {
if(!Objects.equals(oldSize, newSize)) {
AppServices.get().start();
}
public void handleResize() {
titleBar.invalidate();
statusBar.invalidate();
}
}
});
AppServices.get().start();
}
public BasicWindow getMainWindow() {
return mainWindow;