implement equivalent of vi's 'e' command

This commit is contained in:
2024-10-24 12:29:43 +01:00
parent 15ff3a111a
commit 1f9b01c858
3 changed files with 163 additions and 0 deletions

View File

@@ -149,6 +149,22 @@ struct
(newApp, drawMsg)
end
fun endOfWord (app: app_type) =
let
val {buffer, windowWidth, windowHeight, startLine, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val cursorIdx = Cursor.endOfWord (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
@@ -159,6 +175,7 @@ struct
| #"$" => moveToLineEnd app
| #"w" => nextWord app
| #"b" => prevWord app
| #"e" => endOfWord app
| _ => (app, [])
fun update (app, msg) =