implement nextWord in cursor.sml (vi's lowercase w)

This commit is contained in:
2024-10-23 04:31:34 +01:00
parent a454524ecc
commit 80cdcdccd6
3 changed files with 155 additions and 0 deletions

View File

@@ -116,6 +116,22 @@ struct
in
(newApp, drawMsg)
end
fun nextWord (app: app_type) =
let
val {buffer, windowWidth, windowHeight, startLine, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.nextWord (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
@@ -125,6 +141,7 @@ struct
| #"l" => moveRight app
| #"0" => moveToLineStart app
| #"$" => moveToLineEnd app
| #"w" => nextWord app
| _ => (app, [])
fun update (app, msg) =