retrofit from XtermWM

This commit is contained in:
Kevin Lamonte 2020-06-07 05:53:35 -05:00
parent fc1a754bfc
commit cdc48c3b53
5 changed files with 68 additions and 4 deletions

View file

@ -3982,6 +3982,9 @@ public class TApplication implements Runnable {
public final TTerminalWindow openTerminal(final int x, final int y,
final int flags, final String [] command) {
if (command.length == 0) {
return new TTerminalWindow(this, x, y, flags);
}
return new TTerminalWindow(this, x, y, flags, command);
}

View file

@ -647,6 +647,45 @@ public class TSplitPane extends TWidget {
}
}
/**
* Get whether or not this is a vertical split.
*
* @return if true, this is a vertical split
*/
public boolean isVertical() {
return vertical;
}
/**
* Get whether or not this is a horizontal split.
*
* @return if true, this is a horizontal split
*/
public boolean isHorizontal() {
return !vertical;
}
/**
* Get the split location.
*
* @return the row of the divider for a horizontal, or the column for a
* vertical split
*/
public int getSplit() {
return split;
}
/**
* Set the split location.
*
* @param split the row of the divider for a horizontal, or the column
* for a vertical split
*/
public void setSplit(final int split) {
this.split = split;
layoutChildren();
}
/**
* Recenter the split to the middle of this split pane.
*/

View file

@ -241,6 +241,10 @@ public class TTerminalWidget extends TScrollableWidget
this.closeAction = closeAction;
// Save the external command line that can be used to recreate this
// terminal, not the fully-processed command line.
commandLine = command;
String [] fullCommand;
// Spawn a shell and pass its I/O to the other constructor.
@ -348,6 +352,9 @@ public class TTerminalWidget extends TScrollableWidget
return;
}
// Save an empty command line.
commandLine = new String[0];
String cmdShellWindows = "cmd.exe";
// You cannot run a login shell in a bare Process interactively, due
@ -937,9 +944,6 @@ public class TTerminalWidget extends TScrollableWidget
* @param command the command line to execute
*/
private void spawnShell(final String [] command) {
commandLine = command;
/*
System.err.printf("spawnShell(): '%s'\n",
stringArrayToString(command));

View file

@ -1194,6 +1194,24 @@ public class TWindow extends TWidget {
}
}
/**
* Move the window as needed to ensure it is visible on screen.
*/
public void ensureOnScreen() {
if (getX() < 0) {
setX(0);
}
if (getY() < getApplication().getDesktopTop()) {
setY(getApplication().getDesktopTop());
}
while (getX() + getWidth() > getScreen().getWidth()) {
setX(getX() - 1);
}
while (getY() + getHeight() > getApplication().getDesktopBottom()) {
setY(getY() - 1);
}
}
/**
* Maximize window.
*/

View file

@ -390,7 +390,7 @@ public class Cell extends CellAttributes {
// Either both objects have their image inverted, or neither do.
// Now if the images are identical the cells are the same
// visually.
if (image.equals(that.image)
if ((imageHashCode == that.imageHashCode)
&& (background.equals(that.background))
) {
return true;