add new function to calculate the startLine
This commit is contained in:
@@ -17,7 +17,6 @@ struct
|
|||||||
(* calculate scroll column *)
|
(* calculate scroll column *)
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
val visualScrollColumn = TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
val visualScrollColumn = TextScroll.getScrollColumn (buffer, cursorIdx, windowWidth)
|
||||||
val () = print (Int.toString visualScrollColumn ^ "\n")
|
|
||||||
|
|
||||||
(* move LineGap to first line displayed on screen *)
|
(* move LineGap to first line displayed on screen *)
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|||||||
@@ -17,8 +17,25 @@ struct
|
|||||||
else windowWidth div TC.xSpace
|
else windowWidth div TC.xSpace
|
||||||
in
|
in
|
||||||
if columnDifference < howManyColumnsCanWeFit then 0
|
if columnDifference < howManyColumnsCanWeFit then 0
|
||||||
else
|
else columnDifference - howManyColumnsCanWeFit
|
||||||
columnDifference - howManyColumnsCanWeFit
|
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
else
|
||||||
|
(* cursorLine > prevLineNumber *)
|
||||||
|
let
|
||||||
|
val howManyLinesWeCanFit = windowHeight div TC.ySpace
|
||||||
|
in
|
||||||
|
if prevLineNumber + howManyLinesWeCanFit >= cursorLine then
|
||||||
|
prevLineNumber
|
||||||
|
else
|
||||||
|
let val lineDifference = cursorLine - prevLineNumber
|
||||||
|
in prevLineNumber + lineDifference
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user