add implementation of viK, completing hjkl movement keys

This commit is contained in:
2024-10-21 01:34:54 +01:00
parent d8e1c9d0fd
commit e08f2c4f77
3 changed files with 276 additions and 71 deletions

View File

@@ -69,10 +69,27 @@ struct
(newApp, drawMsg)
end
fun moveUp (app: app_type) =
let
val {buffer, windowWidth, windowHeight, startLine, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.viK (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
fun handleChr (app: app_type, chr) =
case chr of
#"h" => moveLeft app
| #"j" => moveDown app
| #"k" => moveUp app
| #"l" => moveRight app
| _ => (app, [])