X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Ftterminal%2FECMA48.java;h=5a30d37454af62d5f4c519e31e47924b2dd31593;hb=1d99a38f2b0f1f6674a21ba8b17be28bc7a34035;hp=46952da4b19066ce96b8dab768074e054e5e3665;hpb=be72cb5ccbd42fe304c0acafc380c5636f0d03a2;p=fanfix.git diff --git a/src/jexer/tterminal/ECMA48.java b/src/jexer/tterminal/ECMA48.java index 46952da..5a30d37 100644 --- a/src/jexer/tterminal/ECMA48.java +++ b/src/jexer/tterminal/ECMA48.java @@ -204,7 +204,7 @@ public class ECMA48 implements Runnable { * * @param str string to send */ - private void writeRemote(final String str) { + public void writeRemote(final String str) { if (stopReaderThread) { // Reader hit EOF, bail out now. close(); @@ -221,6 +221,7 @@ public class ECMA48 implements Runnable { return; } try { + outputStream.flush(); for (int i = 0; i < str.length(); i++) { outputStream.write(str.charAt(i)); } @@ -235,6 +236,7 @@ public class ECMA48 implements Runnable { return; } try { + output.flush(); output.write(str); output.flush(); } catch (IOException e) { @@ -538,6 +540,22 @@ public class ECMA48 implements Runnable { return width; } + /** + * Set the display width. + * + * @param width the new width + */ + public final void setWidth(final int width) { + this.width = width; + rightMargin = width - 1; + if (currentState.cursorX >= width) { + currentState.cursorX = width - 1; + } + if (savedState.cursorX >= width) { + savedState.cursorX = width - 1; + } + } + /** * Physical display height. We start at 80x24, but the user can resize * us bigger/smaller. @@ -553,6 +571,33 @@ public class ECMA48 implements Runnable { return height; } + /** + * Set the display height. + * + * @param height the new height + */ + public final void setHeight(final int height) { + this.height = height; + scrollRegionBottom = height - 1; + if (scrollRegionTop >= scrollRegionBottom) { + scrollRegionTop = 0; + } + if (currentState.cursorY >= height) { + currentState.cursorY = height - 1; + } + if (savedState.cursorY >= height) { + savedState.cursorY = height - 1; + } + while (display.size() < height) { + DisplayLine line = new DisplayLine(currentState.attr); + line.setReverseColor(reverseVideo); + display.add(line); + } + while (display.size() > height) { + scrollback.add(display.remove(0)); + } + } + /** * Top margin of the scrolling region. */