From 564bde5c42170592fdeed845e19fd102ae2865aa Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Sun, 7 Jun 2009 05:31:48 +0000 Subject: Fix resizing bug caused by removing all the unnecessary allocations in mud.de code git-svn-id: https://connectbot.googlecode.com/svn/trunk/connectbot@272 df292f66-193f-0410-a5fc-6d59da041ff2 --- src/de/mud/terminal/VDUBuffer.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/de/mud/terminal') diff --git a/src/de/mud/terminal/VDUBuffer.java b/src/de/mud/terminal/VDUBuffer.java index 60c73f4..f9940c3 100644 --- a/src/de/mud/terminal/VDUBuffer.java +++ b/src/de/mud/terminal/VDUBuffer.java @@ -733,7 +733,7 @@ public class VDUBuffer { public void setScreenSize(int w, int h, boolean broadcast) { char cbuf[][]; int abuf[][]; - int bsize = bufSize; + int maxSize = bufSize; if (w < 1 || h < 1) return; @@ -759,17 +759,22 @@ public class VDUBuffer { cbuf = new char[bufSize][w]; abuf = new int[bufSize][w]; - + for (int i = 0; i < bufSize; i++) { - Arrays.fill(cbuf[i], ' '); - } + Arrays.fill(cbuf[i], ' '); + } + + if (bufSize < maxSize) + maxSize = bufSize; + int rowLength; if (charArray != null && charAttributes != null) { - for (int i = 0; i < bsize && i < bufSize; i++) { + for (int i = 0; i < maxSize && charArray[i] != null; i++) { + rowLength = charArray[i].length; System.arraycopy(charArray[i], 0, cbuf[i], 0, - w < width ? w : width); + w < rowLength ? w : rowLength); System.arraycopy(charAttributes[i], 0, abuf[i], 0, - w < width ? w : width); + w < rowLength ? w : rowLength); } } -- cgit v1.2.3