From: Kevin Lamonte Date: Thu, 22 Aug 2019 11:22:24 +0000 (-0500) Subject: #51 complete X-Git-Tag: fanfix-3.0.1^2~53 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=9917c620116aa68ebf5d74afaeec44416b314729;p=fanfix.git #51 complete --- diff --git a/src/jexer/TSplitPane.java b/src/jexer/TSplitPane.java index a9d6cdb..7c85278 100644 --- a/src/jexer/TSplitPane.java +++ b/src/jexer/TSplitPane.java @@ -124,8 +124,6 @@ public class TSplitPane extends TWidget { // Resize me super.onResize(event); - // System.err.println("onResize(): " + toString()); - if (vertical && (split >= getWidth() - 2)) { center(); } else if (!vertical && (split >= getHeight() - 2)) { @@ -172,9 +170,6 @@ public class TSplitPane extends TWidget { this.mouse = mouse; if (inSplitMove && mouse.isMouse1()) { - // DEBUG - // System.err.println(toPrettyString()); - // Stop moving split inSplitMove = false; return; @@ -501,36 +496,29 @@ public class TSplitPane extends TWidget { * 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()); } } } @@ -607,8 +595,6 @@ public class TSplitPane extends TWidget { keep.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, getWidth(), getHeight())); } - - // System.err.println("\nAfter removeSplit():\n" + myParent.toPrettyString()); return keep; } diff --git a/src/jexer/TTerminalWidget.java b/src/jexer/TTerminalWidget.java index 39d761c..b1ff8b9 100644 --- a/src/jexer/TTerminalWidget.java +++ b/src/jexer/TTerminalWidget.java @@ -119,12 +119,7 @@ public class TTerminalWidget extends TScrollableWidget private boolean haveTimer = false; /** - * The last seen scrollback lines. - */ - private List scrollback; - - /** - * The last seen display lines. + * The last seen visible display. */ private List display; @@ -361,7 +356,7 @@ public class TTerminalWidget extends TScrollableWidget 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. @@ -375,7 +370,6 @@ public class TTerminalWidget extends TScrollableWidget } if ((syncEmulator == true) - || (scrollback == null) || (display == null) ) { // We want to minimize the amount of time we have the emulator @@ -392,46 +386,19 @@ public class TTerminalWidget extends TScrollableWidget 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 preceedingBlankLines = new ArrayList(); - int visibleTop = visibleBottom - visibleHeight; - if (visibleTop < 0) { - for (int i = visibleTop; i < 0; i++) { - preceedingBlankLines.add(emulator.getBlankDisplayLine()); - } - visibleTop = 0; - } - assert (visibleTop >= 0); - - List displayLines = new ArrayList(); - displayLines.addAll(scrollback); - displayLines.addAll(display); - - List visibleLines = new ArrayList(); - 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; @@ -471,17 +438,7 @@ public class TTerminalWidget extends TScrollableWidget } } 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); } - } /** @@ -577,6 +534,7 @@ public class TTerminalWidget extends TScrollableWidget || keypress.equals(kbAltPgUp) ) { bigVerticalDecrement(); + dirty = true; return; } if (keypress.equals(kbShiftPgDn) @@ -584,6 +542,7 @@ public class TTerminalWidget extends TScrollableWidget || keypress.equals(kbAltPgDn) ) { bigVerticalIncrement(); + dirty = true; return; } @@ -627,10 +586,12 @@ public class TTerminalWidget extends TScrollableWidget if (emulator.getMouseProtocol() == ECMA48.MouseProtocol.OFF) { if (mouse.isMouseWheelUp()) { verticalDecrement(); + dirty = true; return; } if (mouse.isMouseWheelDown()) { verticalIncrement(); + dirty = true; return; } } @@ -929,20 +890,6 @@ public class TTerminalWidget extends TScrollableWidget return false; } - /** - * Copy a display buffer. - * - * @param buffer the buffer to copy - * @return a deep copy of the buffer's data - */ - private List copyBuffer(final List buffer) { - ArrayList result = new ArrayList(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. diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index ba18989..60bc3e4 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -1475,6 +1475,19 @@ public abstract class TWidget implements Comparable { } } + /** + * 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. * @@ -1605,11 +1618,10 @@ public abstract class TWidget implements Comparable { splitPane.setLeft(this); splitPane.setRight(newWidget); } - splitPane.activate(); if (newWidget != null) { - newWidget.activate(); + newWidget.activateAll(); } else { - activate(); + activateAll(); } assert (parent != null); @@ -1657,11 +1669,10 @@ public abstract class TWidget implements Comparable { splitPane.setTop(this); splitPane.setBottom(newWidget); } - splitPane.activate(); if (newWidget != null) { - newWidget.activate(); + newWidget.activateAll(); } else { - activate(); + activateAll(); } assert (parent != null); diff --git a/src/jexer/tterminal/ECMA48.java b/src/jexer/tterminal/ECMA48.java index c277795..e3e7c92 100644 --- a/src/jexer/tterminal/ECMA48.java +++ b/src/jexer/tterminal/ECMA48.java @@ -1078,6 +1078,64 @@ public class ECMA48 implements Runnable { 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 getVisibleDisplay(final int visibleHeight, + final int scrollBottom) { + + assert (visibleHeight >= 0); + assert (scrollBottom >= 0); + + int visibleBottom = scrollback.size() + display.size() - scrollBottom; + + List preceedingBlankLines = new ArrayList(); + int visibleTop = visibleBottom - visibleHeight; + if (visibleTop < 0) { + for (int i = visibleTop; i < 0; i++) { + preceedingBlankLines.add(getBlankDisplayLine()); + } + visibleTop = 0; + } + assert (visibleTop >= 0); + + List displayLines = new ArrayList(); + displayLines.addAll(scrollback); + displayLines.addAll(display); + + List visibleLines = new ArrayList(); + 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 copyBuffer(final List buffer) { + ArrayList result = new ArrayList(buffer.size()); + for (DisplayLine line: buffer) { + result.add(new DisplayLine(line)); + } + return result; + } + /** * Get the display width. *