diff options
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/de/mud/terminal/VDUBuffer.java | 13 | ||||
-rw-r--r-- | app/src/main/java/de/mud/terminal/vt320.java | 20 |
2 files changed, 14 insertions, 19 deletions
diff --git a/app/src/main/java/de/mud/terminal/VDUBuffer.java b/app/src/main/java/de/mud/terminal/VDUBuffer.java index 93e3ccf..f1d97ea 100644 --- a/app/src/main/java/de/mud/terminal/VDUBuffer.java +++ b/app/src/main/java/de/mud/terminal/VDUBuffer.java @@ -731,6 +731,7 @@ public class VDUBuffer { char cbuf[][]; int abuf[][]; int maxSize = bufSize; + int oldAbsR = screenBase + getCursorRow(); if (w < 1 || h < 1) return; @@ -778,14 +779,18 @@ public class VDUBuffer { int C = getCursorColumn(); if (C < 0) C = 0; - else if (C >= width) - C = width - 1; + else if (C >= w) + C = w - 1; int R = getCursorRow(); + // If the screen size has grown and now there are more rows on the screen, + // slide the cursor down to the end of the text. + if (R + screenBase <= oldAbsR) + R = oldAbsR - screenBase; if (R < 0) R = 0; - else if (R >= height) - R = height - 1; + else if (R >= h) + R = h - 1; setCursorPosition(C, R); diff --git a/app/src/main/java/de/mud/terminal/vt320.java b/app/src/main/java/de/mud/terminal/vt320.java index ab4a90d..dc95bea 100644 --- a/app/src/main/java/de/mud/terminal/vt320.java +++ b/app/src/main/java/de/mud/terminal/vt320.java @@ -162,23 +162,13 @@ public void setScreenSize(int c, int r, boolean broadcast) { super.setScreenSize(c,r,false); - boolean cursorChanged = false; - - // Don't let the cursor go off the screen. - if (C >= c) { - C = c - 1; - cursorChanged = true; - } - + // Don't let the cursor go off the screen. Scroll down if needed. if (R >= r) { - R = r - 1; - cursorChanged = true; - } - - if (cursorChanged) { - setCursorPosition(C, R); - redraw(); + screenBase += R - (r - 1); + setWindowBase(screenBase); } + R = getCursorRow(); + C = getCursorColumn(); if (broadcast) { setWindowSize(c, r); /* broadcast up */ |