diff options
author | Kenny Root <kenny@the-b.org> | 2015-10-05 10:52:29 -0700 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2015-10-05 10:52:29 -0700 |
commit | 14318dab67d7c013b1a88861367eecb423010e70 (patch) | |
tree | 12241a5acece2419e8570a9bd27d55627c87fdf6 /app/src/main/java/de/mud/terminal/VDUBuffer.java | |
parent | 4c0ca79b464af40b5a41e39bcd3d7968abde5c9a (diff) | |
parent | a157202db2d7e28aab124eb4d6966bdbe668d75f (diff) | |
download | connectbot-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.
Diffstat (limited to 'app/src/main/java/de/mud/terminal/VDUBuffer.java')
-rw-r--r-- | app/src/main/java/de/mud/terminal/VDUBuffer.java | 13 |
1 files changed, 9 insertions, 4 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); |