improve code to move rightwards in cursor.sml (making it clearer with comments), and improve code to draw cursor at newline in text=builder.sml

This commit is contained in:
2024-10-17 08:40:28 +01:00
parent 0299a9e6b2
commit 19073cb56c
4 changed files with 87 additions and 64 deletions

View File

@@ -326,15 +326,25 @@ struct
else
(* in cursor position, so build cursorAcc
* and call AfterCursor function *)
let
val cursorAcc = buildCursor (posX, posY, fWindowWidth, fWindowHeight, r, g ,b)
in
buildTextStringAfterCursor
( pos + 1, str, acc, startX, posY + ySpace, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl, cursorAcc
)
end
if pos = String.size str - 1 andalso tl = [] then
(* if we are at end of lineGap, we want to build cursorAcc
* at different coordinates than usual *)
let
val cursorAcc =
buildCursor (startX, posY + ySpace, fWindowWidth, fWindowHeight, r, g, b)
in
accToDrawMsg (acc, cursorAcc)
end
else
let
val cursorAcc = buildCursor (posX, posY, fWindowWidth, fWindowHeight, r, g ,b)
in
buildTextStringAfterCursor
( pos + 1, str, acc, startX, posY + ySpace, startX
, windowWidth, windowHeight, fWindowWidth, fWindowHeight
, r, g, b, tl, cursorAcc
)
end
else
accToDrawMsg (acc, cursorAcc)
| #"\r" =>