edit.js: vert scroll fixed, but not PgDn; hor scroll is still broken

This commit is contained in:
minjaesong
2021-04-18 17:41:56 +09:00
parent 6a1ce46f7b
commit aede935250

View File

@@ -296,7 +296,7 @@ function cursorMoveRelative(odx, ody) {
else if (cursorCol + dx < 0)
dx = -cursorCol;
if (cursorRow + dy > textbuffer.length)
if (cursorRow + dy > textbuffer.length - 1)
dy = textbuffer.length - cursorRow;
else if (cursorRow + dy < 0)
dy = -cursorRow;
@@ -328,23 +328,25 @@ function cursorMoveRelative(odx, ody) {
// update vertical scroll stats
if (dy != 0) {
if (ny > paintHeight) {
scroll += (ny - paintHeight - scrollPeek);
ny = paintHeight - scrollPeek
let stride = paintHeight - 1 - scrollPeek;
if (ny > stride) {
scroll += ny - stride;
ny = stride;
}
else if (ny < 0) {
let scrollToTop = (scroll - dy <= 0);
if (scrollToTop) {
else if (ny < 0 + scrollPeek) {
scroll += ny - scrollPeek; // ny is less than zero
ny = 1;
// scroll to the top?
if (scroll <= -1) { // scroll of -1 would result to show "Line 0" on screen
scroll = 0;
ny = 0;
}
else {
scroll += ny + paintHeight - scrollPeek; // ny is less than zero
}
ny = 0;
}
}
serial.println(`dY:${dy} nY:${ny} scrY:${scroll} row:${cursorRow}`);
serial.println(`dY:${dy} nY:${ny} scrY:${scroll} row:${cursorRow} | wDim:${paintHeight}R ${paintWidth}C peek:${scrollPeek}`);
// update screendraw
if (oldScroll != scroll) {