add functionality to move to end of line

This commit is contained in:
2024-10-30 10:54:55 +00:00
parent 308d042deb
commit 601a341992
4 changed files with 35 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ struct
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val startLine = TextWindow.getStartLineWithCursorCentered
(buffer, cursorIdx, origLine, windowWidth, windowHeight)
(buffer, cursorIdx, origLine, windowWidth, windowHeight div 2)
val buffer = LineGap.goToLine (startLine, buffer)
@@ -41,7 +41,7 @@ struct
fun moveToStart (app: app_type) =
let
val {buffer, windowWidth, windowHeight, startLine, ...} = app
val {buffer, windowWidth, windowHeight, ...} = app
val cursorIdx = 0
val startLine = 0
@@ -58,6 +58,32 @@ struct
(newApp, drawMsg)
end
fun moveToEnd (app: app_type) =
let
val {buffer, windowWidth, windowHeight, ...} = app
val buffer = LineGap.goToEnd buffer
val {line = bufferLine, idx = bufferIdx, ...} = buffer
val bufferIdx = bufferIdx - 1
val bufferLine = bufferLine - 1
val buffer = LineGap.goToIdx (bufferIdx, buffer)
val bufferLine = TextWindow.getStartLineWithCursorCentered
(buffer, bufferIdx, bufferLine, windowWidth, windowHeight)
val buffer = LineGap.goToLine (bufferLine, buffer)
val drawMsg =
TextBuilder.build
(bufferLine, bufferIdx, buffer, windowWidth, windowHeight)
val mode = NORMAL_MODE ""
val newApp = AppWith.bufferAndCursorIdx
(app, buffer, bufferIdx, mode, bufferLine)
in
(newApp, drawMsg)
end
fun helpMove (app: app_type, buffer, cursorIdx, count, fMove) =
if count = 0 then
let
@@ -181,6 +207,11 @@ struct
move (app, 1, Cursor.vi0)
| #"$" => move (app, 1, Cursor.viDlr)
| #"^" => firstNonSpaceChr app
| #"G" =>
(* if str has a size larger than 0,
* interpret as "go to line" command;
* else, interpret as a command to move to end *)
moveToEnd app
(* multi-char commands which can be appended *)
| #"t" => appendChr (app, chr, str)
| #"T" => appendChr (app, chr, str)