add TextScroll function for centering line to cursor, and use it in 'NormalFinish.centreToCursor' function
This commit is contained in:
@@ -128,7 +128,6 @@ struct
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
(* todo: check; the way we get the startLine is almost certainly wrong *)
|
|
||||||
fun centreToCursor (app: app_type) =
|
fun centreToCursor (app: app_type) =
|
||||||
let
|
let
|
||||||
val
|
val
|
||||||
@@ -146,8 +145,7 @@ struct
|
|||||||
|
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
val cursorLine = LineGap.getLineNumberOfIdx (cursorIdx, buffer)
|
val cursorLine = LineGap.getLineNumberOfIdx (cursorIdx, buffer)
|
||||||
val startLine =
|
val startLine = TextScroll.getLineCentre (cursorLine, windowHeight)
|
||||||
TextScroll.getStartLine (prevLineNumber, cursorLine, windowHeight div 2)
|
|
||||||
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
val drawMsg = NormalModeTextBuilder.build
|
val drawMsg = NormalModeTextBuilder.build
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ struct
|
|||||||
(* cursorLine > prevLineNumber *)
|
(* cursorLine > prevLineNumber *)
|
||||||
let
|
let
|
||||||
val howManyLinesWeCanFit = windowHeight div TC.ySpace
|
val howManyLinesWeCanFit = windowHeight div TC.ySpace
|
||||||
val howManyLinesWeCanFit = howManyLinesWeCanFit
|
|
||||||
in
|
in
|
||||||
if cursorLine > prevLineNumber + (howManyLinesWeCanFit - 3) then
|
if cursorLine > prevLineNumber + (howManyLinesWeCanFit - 3) then
|
||||||
(* cursorLine is after the visible part of the screen
|
(* cursorLine is after the visible part of the screen
|
||||||
@@ -43,4 +42,12 @@ struct
|
|||||||
else
|
else
|
||||||
prevLineNumber
|
prevLineNumber
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun getLineCentre (cursorLine, windowHeight) =
|
||||||
|
let
|
||||||
|
val howManyLinesWeCanFit = windowHeight div TC.ySpace
|
||||||
|
val startLine = cursorLine - (howManyLinesWeCanFit div 2)
|
||||||
|
in
|
||||||
|
Int.max (startLine, 0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user