From 2a332f543acf7ac45de2ae60588c96222113cf3b Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 13 Sep 2025 05:24:51 +0100 Subject: [PATCH] minor adjustment to vertical TextScroll: we shouldn't need to move the cursor to the very line in the visible area, or the ver first line in the visible area, to scroll. We scroll if the cursorLine is some distance close to either edge instead. --- fcore/text-scroll.sml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fcore/text-scroll.sml b/fcore/text-scroll.sml index 0732f21..6bc71c5 100644 --- a/fcore/text-scroll.sml +++ b/fcore/text-scroll.sml @@ -26,18 +26,20 @@ struct end fun getStartLine (prevLineNumber, cursorLine, windowHeight) = - if cursorLine <= prevLineNumber then - (* if cursorLine is prior or same as prevLineNumber, - * then use cursorLine as scroll-line-start *) - cursorLine + if cursorLine <= (prevLineNumber + 3) then + (* cursorLine is prior to or same as prevLineNumber, + * so use cursorLine to calculate the start line we want. *) + Int.max (cursorLine - 3, 0) else (* cursorLine > prevLineNumber *) let val howManyLinesWeCanFit = windowHeight div TC.ySpace - val howManyLinesWeCanFit = howManyLinesWeCanFit - 2 + val howManyLinesWeCanFit = howManyLinesWeCanFit in - if cursorLine > prevLineNumber + howManyLinesWeCanFit then - cursorLine - howManyLinesWeCanFit + if cursorLine > prevLineNumber + (howManyLinesWeCanFit - 3) then + (* cursorLine is after the visible part of the screen + * so return the mimimum line where cursorLine is visible *) + cursorLine - howManyLinesWeCanFit + 3 else prevLineNumber end