// Resize me
super.onResize(event);
- // System.err.println("onResize(): " + toString());
-
if (vertical && (split >= getWidth() - 2)) {
center();
} else if (!vertical && (split >= getHeight() - 2)) {
this.mouse = mouse;
if (inSplitMove && mouse.isMouse1()) {
- // DEBUG
- // System.err.println(toPrettyString());
-
// Stop moving split
inSplitMove = false;
return;
* Layout the two child widgets.
*/
private void layoutChildren() {
-
- // System.err.println("layoutChildren(): " + toString());
-
if (vertical) {
if (left != null) {
left.setDimensions(0, 0, split, getHeight());
left.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
left.getWidth(), left.getHeight()));
- // System.err.println(" move/size left: " + left.toString());
}
if (right != null) {
right.setDimensions(split + 1, 0, getWidth() - split - 1,
getHeight());
right.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
right.getWidth(), right.getHeight()));
- // System.err.println(" move/size right: " + right.toString());
}
} else {
if (top != null) {
top.setDimensions(0, 0, getWidth(), split);
top.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
top.getWidth(), top.getHeight()));
- // System.err.println(" move/size top: " + top.toString());
}
if (bottom != null) {
bottom.setDimensions(0, split + 1, getWidth(),
getHeight() - split - 1);
bottom.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
bottom.getWidth(), bottom.getHeight()));
- // System.err.println(" move/size bottom: " + bottom.toString());
}
}
}
keep.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, getWidth(),
getHeight()));
}
-
- // System.err.println("\nAfter removeSplit():\n" + myParent.toPrettyString());
return keep;
}
private boolean haveTimer = false;
/**
- * The last seen scrollback lines.
- */
- private List<DisplayLine> scrollback;
-
- /**
- * The last seen display lines.
+ * The last seen visible display.
*/
private List<DisplayLine> display;
int width = getDisplayWidth();
boolean syncEmulator = false;
- if ((System.currentTimeMillis() - lastUpdateTime >= 25)
+ if ((System.currentTimeMillis() - lastUpdateTime >= 20)
&& (dirty == true)
) {
// Too much time has passed, draw it all.
}
if ((syncEmulator == true)
- || (scrollback == null)
|| (display == null)
) {
// We want to minimize the amount of time we have the emulator
return;
}
- if ((scrollback == null) || emulator.isReading()) {
- scrollback = copyBuffer(emulator.getScrollbackBuffer());
- display = copyBuffer(emulator.getDisplayBuffer());
+ if ((display == null) || emulator.isReading()) {
+ display = emulator.getVisibleDisplay(getHeight(),
+ -getVerticalValue());
+ assert (display.size() == getHeight());
}
width = emulator.getWidth();
}
dirty = false;
}
- // Put together the visible rows
- int visibleHeight = getHeight();
- int visibleBottom = scrollback.size() + display.size()
- + getVerticalValue();
- assert (visibleBottom >= 0);
-
- List<DisplayLine> preceedingBlankLines = new ArrayList<DisplayLine>();
- int visibleTop = visibleBottom - visibleHeight;
- if (visibleTop < 0) {
- for (int i = visibleTop; i < 0; i++) {
- preceedingBlankLines.add(emulator.getBlankDisplayLine());
- }
- visibleTop = 0;
- }
- assert (visibleTop >= 0);
-
- List<DisplayLine> displayLines = new ArrayList<DisplayLine>();
- displayLines.addAll(scrollback);
- displayLines.addAll(display);
-
- List<DisplayLine> visibleLines = new ArrayList<DisplayLine>();
- visibleLines.addAll(preceedingBlankLines);
- visibleLines.addAll(displayLines.subList(visibleTop,
- visibleBottom));
-
- visibleHeight -= visibleLines.size();
- assert (visibleHeight >= 0);
-
// Now draw the emulator screen
int row = 0;
- for (DisplayLine line: visibleLines) {
+ for (DisplayLine line: display) {
int widthMax = width;
if (line.isDoubleWidth()) {
widthMax /= 2;
}
}
row++;
- if (row == getHeight()) {
- // Don't overwrite the box edge
- break;
- }
- }
- CellAttributes background = new CellAttributes();
- // Fill in the blank lines on bottom
- for (int i = 0; i < visibleHeight; i++) {
- hLineXY(0, i + row, getWidth(), ' ', background);
}
-
}
/**
|| keypress.equals(kbAltPgUp)
) {
bigVerticalDecrement();
+ dirty = true;
return;
}
if (keypress.equals(kbShiftPgDn)
|| keypress.equals(kbAltPgDn)
) {
bigVerticalIncrement();
+ dirty = true;
return;
}
if (emulator.getMouseProtocol() == ECMA48.MouseProtocol.OFF) {
if (mouse.isMouseWheelUp()) {
verticalDecrement();
+ dirty = true;
return;
}
if (mouse.isMouseWheelDown()) {
verticalIncrement();
+ dirty = true;
return;
}
}
return false;
}
- /**
- * Copy a display buffer.
- *
- * @param buffer the buffer to copy
- * @return a deep copy of the buffer's data
- */
- private List<DisplayLine> copyBuffer(final List<DisplayLine> buffer) {
- ArrayList<DisplayLine> result = new ArrayList<DisplayLine>(buffer.size());
- for (DisplayLine line: buffer) {
- result.add(new DisplayLine(line));
- }
- return result;
- }
-
/**
* Draw glyphs for a double-width or double-height VT100 cell to two
* screen cells.
}
}
+ /**
+ * Make this widget, all of its parents, the active child.
+ */
+ public final void activateAll() {
+ activate();
+ if (parent == this) {
+ return;
+ }
+ if (parent != null) {
+ parent.activateAll();
+ }
+ }
+
/**
* Switch the active widget with the next in the tab order.
*
splitPane.setLeft(this);
splitPane.setRight(newWidget);
}
- splitPane.activate();
if (newWidget != null) {
- newWidget.activate();
+ newWidget.activateAll();
} else {
- activate();
+ activateAll();
}
assert (parent != null);
splitPane.setTop(this);
splitPane.setBottom(newWidget);
}
- splitPane.activate();
if (newWidget != null) {
- newWidget.activate();
+ newWidget.activateAll();
} else {
- activate();
+ activateAll();
}
assert (parent != null);
return display;
}
+ /**
+ * Get the visible display + scrollback buffer, offset by a specified
+ * number of rows from the bottom.
+ *
+ * @param visibleHeight the total height of the display to show
+ * @param scrollBottom the number of rows from the bottom to scroll back
+ * @return a copy of the display + scrollback buffers
+ */
+ public final List<DisplayLine> getVisibleDisplay(final int visibleHeight,
+ final int scrollBottom) {
+
+ assert (visibleHeight >= 0);
+ assert (scrollBottom >= 0);
+
+ int visibleBottom = scrollback.size() + display.size() - scrollBottom;
+
+ List<DisplayLine> preceedingBlankLines = new ArrayList<DisplayLine>();
+ int visibleTop = visibleBottom - visibleHeight;
+ if (visibleTop < 0) {
+ for (int i = visibleTop; i < 0; i++) {
+ preceedingBlankLines.add(getBlankDisplayLine());
+ }
+ visibleTop = 0;
+ }
+ assert (visibleTop >= 0);
+
+ List<DisplayLine> displayLines = new ArrayList<DisplayLine>();
+ displayLines.addAll(scrollback);
+ displayLines.addAll(display);
+
+ List<DisplayLine> visibleLines = new ArrayList<DisplayLine>();
+ visibleLines.addAll(preceedingBlankLines);
+ visibleLines.addAll(displayLines.subList(visibleTop, visibleBottom));
+
+ // Fill in the blank lines on bottom
+ int bottomBlankLines = visibleHeight - visibleLines.size();
+ assert (bottomBlankLines >= 0);
+ for (int i = 0; i < bottomBlankLines; i++) {
+ visibleLines.add(getBlankDisplayLine());
+ }
+
+ return copyBuffer(visibleLines);
+ }
+
+ /**
+ * Copy a display buffer.
+ *
+ * @param buffer the buffer to copy
+ * @return a deep copy of the buffer's data
+ */
+ private List<DisplayLine> copyBuffer(final List<DisplayLine> buffer) {
+ ArrayList<DisplayLine> result = new ArrayList<DisplayLine>(buffer.size());
+ for (DisplayLine line: buffer) {
+ result.add(new DisplayLine(line));
+ }
+ return result;
+ }
+
/**
* Get the display width.
*