pass 'maxLength' value to TextScroll function so that we can prevent scrolling past the bottom of the file (unless we want to od so by centtering the screen)

This commit is contained in:
2025-09-19 23:17:28 +01:00
parent d3fa4d08bf
commit 090e7ccea2
4 changed files with 28 additions and 10 deletions

View File

@@ -37,7 +37,7 @@ struct
fun getScrollColumnFromString (cursorIdx, windowWidth, prevScrollColumn) =
calculateScrollColumn (0, cursorIdx, windowWidth, prevScrollColumn)
fun getStartLine (prevLineNumber, cursorLine, windowHeight) =
fun getStartLine (prevLineNumber, cursorLine, windowHeight, totalLines) =
if cursorLine <= (prevLineNumber + 3) then
(* cursorLine is prior to or same as prevLineNumber,
* so use cursorLine to calculate the start line we want. *)
@@ -50,7 +50,10 @@ struct
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
if cursorLine >= totalLines - 3 then
Int.max (totalLines - howManyLinesWeCanFit, 0)
else
cursorLine - howManyLinesWeCanFit + 3
else
prevLineNumber
end