diff options
author | Jeremy Klein <jklein24@gmail.com> | 2015-10-02 17:34:22 -0700 |
---|---|---|
committer | Jeremy Klein <jlklein@google.com> | 2015-10-05 10:40:10 -0700 |
commit | a157202db2d7e28aab124eb4d6966bdbe668d75f (patch) | |
tree | 12241a5acece2419e8570a9bd27d55627c87fdf6 /app/src/main/java/de/mud/terminal/VDUBuffer.java | |
parent | 4c0ca79b464af40b5a41e39bcd3d7968abde5c9a (diff) | |
download | connectbot-a157202db2d7e28aab124eb4d6966bdbe668d75f.tar.gz connectbot-a157202db2d7e28aab124eb4d6966bdbe668d75f.tar.bz2 connectbot-a157202db2d7e28aab124eb4d6966bdbe668d75f.zip |
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); |