From 94e3ce55cef9970134ee01ab11b3ba44250a7cc8 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Sun, 3 May 2026 16:50:49 +0900 Subject: [PATCH] zfm: larger scroll peek window --- assets/disk0/tvdos/bin/zfm.js | 10 ++++++---- assets/disk0/tvdos/include/wintex.mjs | 16 ++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/assets/disk0/tvdos/bin/zfm.js b/assets/disk0/tvdos/bin/zfm.js index 63471e9..71d70ab 100644 --- a/assets/disk0/tvdos/bin/zfm.js +++ b/assets/disk0/tvdos/bin/zfm.js @@ -422,6 +422,8 @@ let filenavOninput = (window, event) => { let keycodes = [event[3],event[4],event[5],event[6],event[7],event[8],event[9],event[10]] let keycode = keycodes[0] + let scrollPeek = (LIST_HEIGHT / 3)|0 + if (keyJustHit && keysym == "q") { exit = true } @@ -430,19 +432,19 @@ let filenavOninput = (window, event) => { redraw() // this would double-redraw (hence no panel switching) or something if redraw() is not merely a request to do so } else if (keysym == "") { - [cursor[windowMode], scroll[windowMode]] = win.scrollVert(-1, dirFileList[windowMode].length, LIST_HEIGHT, cursor[windowMode], scroll[windowMode], 1) + [cursor[windowMode], scroll[windowMode]] = win.scrollVert(-1, dirFileList[windowMode].length, LIST_HEIGHT, cursor[windowMode], scroll[windowMode], scrollPeek) drawFilePanel() } else if (keysym == "") { - [cursor[windowMode], scroll[windowMode]] = win.scrollVert(+1, dirFileList[windowMode].length, LIST_HEIGHT, cursor[windowMode], scroll[windowMode], 1) + [cursor[windowMode], scroll[windowMode]] = win.scrollVert(+1, dirFileList[windowMode].length, LIST_HEIGHT, cursor[windowMode], scroll[windowMode], scrollPeek) drawFilePanel() } else if (keysym == "") { - [cursor[windowMode], scroll[windowMode]] = win.scrollVert(-LIST_HEIGHT, dirFileList[windowMode].length, LIST_HEIGHT, cursor[windowMode], scroll[windowMode], 1) + [cursor[windowMode], scroll[windowMode]] = win.scrollVert(-LIST_HEIGHT, dirFileList[windowMode].length, LIST_HEIGHT, cursor[windowMode], scroll[windowMode], scrollPeek) drawFilePanel() } else if (keysym == "") { - [cursor[windowMode], scroll[windowMode]] = win.scrollVert(+LIST_HEIGHT, dirFileList[windowMode].length, LIST_HEIGHT, cursor[windowMode], scroll[windowMode], 1) + [cursor[windowMode], scroll[windowMode]] = win.scrollVert(+LIST_HEIGHT, dirFileList[windowMode].length, LIST_HEIGHT, cursor[windowMode], scroll[windowMode], scrollPeek) drawFilePanel() } else if (keyJustHit && keycode == 66) { // enter diff --git a/assets/disk0/tvdos/include/wintex.mjs b/assets/disk0/tvdos/include/wintex.mjs index 7064dbb..40e5131 100644 --- a/assets/disk0/tvdos/include/wintex.mjs +++ b/assets/disk0/tvdos/include/wintex.mjs @@ -96,8 +96,6 @@ class WindowObject { * @return [new cursor pos, new scroll pos] */ function scrollVert(dy, listSize, listHeight, currentCursorPos, currentScrollPos, scrollPeek) { - let peek = 1 - // clamp dy if (currentCursorPos + dy > listSize - 1) dy = (listSize - 1) - currentCursorPos @@ -108,13 +106,13 @@ function scrollVert(dy, listSize, listHeight, currentCursorPos, currentScrollPos // update vertical scroll stats if (dy != 0) { - let visible = listHeight - 1 - peek + let visible = listHeight - 1 - scrollPeek if (nextRow - currentScrollPos > visible) { currentScrollPos = nextRow - visible } - else if (nextRow - currentScrollPos < 0 + peek) { - currentScrollPos = nextRow - peek // nextRow is less than zero + else if (nextRow - currentScrollPos < 0 + scrollPeek) { + currentScrollPos = nextRow - scrollPeek // nextRow is less than zero } // NOTE: future-proofing here -- scroll clamping is moved outside of go-up/go-down @@ -145,8 +143,6 @@ function scrollVert(dy, listSize, listHeight, currentCursorPos, currentScrollPos * @return [new cursor pos, new scroll pos] */ function scrollHorz(dx, stringSize, stringViewSize, currentCursorPos, currentScrollPos, scrollPeek) { - let peek = 1 - // clamp dx if (currentCursorPos + dx > stringSize - 1) dx = (stringSize - 1) - currentCursorPos @@ -157,13 +153,13 @@ function scrollHorz(dx, stringSize, stringViewSize, currentCursorPos, currentScr // update vertical scroll stats if (dx != 0) { - let visible = stringViewSize - 1 - peek + let visible = stringViewSize - 1 - scrollPeek if (nextCol - currentScrollPos > visible) { currentScrollPos = nextCol - visible } - else if (nextCol - currentScrollPos < 0 + peek) { - currentScrollPos = nextCol - peek // nextCol is less than zero + else if (nextCol - currentScrollPos < 0 + scrollPeek) { + currentScrollPos = nextCol - scrollPeek // nextCol is less than zero } // NOTE: future-proofing here -- scroll clamping is moved outside of go-up/go-down