aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-10-05 10:52:29 -0700
committerKenny Root <kenny@the-b.org>2015-10-05 10:52:29 -0700
commit14318dab67d7c013b1a88861367eecb423010e70 (patch)
tree12241a5acece2419e8570a9bd27d55627c87fdf6
parent4c0ca79b464af40b5a41e39bcd3d7968abde5c9a (diff)
parenta157202db2d7e28aab124eb4d6966bdbe668d75f (diff)
downloadconnectbot-14318dab67d7c013b1a88861367eecb423010e70.tar.gz
connectbot-14318dab67d7c013b1a88861367eecb423010e70.tar.bz2
connectbot-14318dab67d7c013b1a88861367eecb423010e70.zip
Merge pull request #274 from jklein24/cursorjump
Fix bad math in moving the cursor when the window size changes.
-rw-r--r--app/src/main/java/de/mud/terminal/VDUBuffer.java13
-rw-r--r--app/src/main/java/de/mud/terminal/vt320.java20
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 */