progress with viJ to move cursor downwards

This commit is contained in:
2024-10-20 21:30:06 +01:00
parent 47f4d452fe
commit 6b3d322c1c
5 changed files with 188 additions and 29 deletions

View File

@@ -26,15 +26,13 @@ struct
(* move LineGap to cursorIdx, which is necessary for finding newCursorIdx *)
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.viL (buffer, cursorIdx)
val preferredColumn = Cursor.getCursorColumn (buffer, cursorIdx)
(* move LineGap to first line displayed on screen, and build new text *)
val buffer = LineGap.goToLine (startLine, buffer)
val drawMsg = TextBuilder.build
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
val newApp =
AppWith.bufferAndCursorIdx (app, buffer, cursorIdx, preferredColumn)
val newApp = AppWith.bufferAndCursorIdx (app, buffer, cursorIdx)
in
(newApp, drawMsg)
end
@@ -45,14 +43,28 @@ struct
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.viH (buffer, cursorIdx)
val preferredColumn = Cursor.getCursorColumn (buffer, cursorIdx)
val buffer = LineGap.goToLine (startLine, buffer)
val drawMsg = TextBuilder.build
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
val newApp =
AppWith.bufferAndCursorIdx (app, buffer, cursorIdx, preferredColumn)
val newApp = AppWith.bufferAndCursorIdx (app, buffer, cursorIdx)
in
(newApp, drawMsg)
end
fun moveDown (app: app_type) =
let
val {buffer, windowWidth, windowHeight, startLine, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.viJ (buffer, cursorIdx)
val buffer = LineGap.goToLine (startLine, buffer)
val drawMsg = TextBuilder.build
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
val newApp = AppWith.bufferAndCursorIdx (app, buffer, cursorIdx)
in
(newApp, drawMsg)
end
@@ -60,6 +72,7 @@ struct
fun handleChr (app: app_type, chr) =
case chr of
#"h" => moveLeft app
| #"j" => moveDown app
| #"l" => moveRight app
| _ => (app, [])