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.

This commit is contained in:
2025-09-13 05:24:51 +01:00
parent 668dd07699
commit 2a332f543a

View File

@@ -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