add functionality to centre text window to cursor

This commit is contained in:
2024-10-30 10:05:16 +00:00
parent f2f305c35d
commit 308d042deb
4 changed files with 139 additions and 1 deletions

View File

@@ -19,6 +19,26 @@ struct
(newApp, drawMsg)
end
fun centreToCursor (app: app_type) =
let
val {buffer, windowWidth, windowHeight, startLine = origLine, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val startLine = TextWindow.getStartLineWithCursorCentered
(buffer, cursorIdx, origLine, windowWidth, windowHeight)
val buffer = LineGap.goToLine (startLine, buffer)
val newApp = AppWith.bufferAndCursorIdx
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
val drawMsg =
TextBuilder.build
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
in
(newApp, drawMsg)
end
fun moveToStart (app: app_type) =
let
val {buffer, windowWidth, windowHeight, startLine, ...} = app
@@ -131,6 +151,7 @@ struct
| #"B" => move (app, count, Cursor.prevWORD)
| #"e" => move (app, count, Cursor.endOfWord)
| #"E" => move (app, count, Cursor.endOfWORD)
| #"z" => centreToCursor app
(* can only move to start or end of line once
* so hardcode count as 1 *)
| #"0" =>