From 97936b83a03b3a3f4b6ec0a71d7c99a0b0dcdeca Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Tue, 16 Sep 2025 22:29:19 +0100 Subject: [PATCH] in TextBuilder functions, when we encounter a newline, we want any cursor here to be drawn after a linebreak (after the posX and posY values go to the next line) and not before --- .../text-builder/text-builder-with-cursor.sml | 30 +++++++++--------- .../text-builder-with-highlight.sml | 31 ++++++++++--------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/fcore/text-builder/text-builder-with-cursor.sml b/fcore/text-builder/text-builder-with-cursor.sml index 2273bc0..bd980a4 100644 --- a/fcore/text-builder/text-builder-with-cursor.sml +++ b/fcore/text-builder/text-builder-with-cursor.sml @@ -133,26 +133,26 @@ struct else case String.sub (str, pos) of #"\n" => - let - val acc = - if absIdx = cursorIdx then - Utils.makeCursor (posX, posY, env) :: acc - else - acc - - val nextLineNumber = lineNumber + 1 - in - if nextLineNumber > #lastLineNumber env then - acc - else + if lineNumber + 1 > #lastLineNumber env then + acc + else + let + val posX = #startX env + val posY = posY + TC.ySpace + val acc = + if absIdx = cursorIdx then + Utils.makeCursor (posX, posY, env) :: acc + else + acc + in build ( pos + 1 , str , stl , line , ltl - , #startX env - , posY + TC.ySpace + , posX + , posY , 0 , lineNumber + 1 , absIdx + 1 @@ -160,7 +160,7 @@ struct , env , acc ) - end + end | #" " => let val acc = diff --git a/fcore/text-builder/text-builder-with-highlight.sml b/fcore/text-builder/text-builder-with-highlight.sml index a1dc27a..aba1a14 100644 --- a/fcore/text-builder/text-builder-with-highlight.sml +++ b/fcore/text-builder/text-builder-with-highlight.sml @@ -230,34 +230,35 @@ struct ) end | #"\n" => - let - val acc = - if absIdx = cursorIdx then - Utils.makeCursor (posX, posY, env) :: acc - else - acc - val nextLineNumber = lineNumber + 1 - in - if nextLineNumber > #lastLineNumber env then - acc - else + if lineNumber + 1 > #lastLineNumber env then + acc + else + let + val posX = #startX env + val posY = posY + TC.ySpace + val acc = + if absIdx = cursorIdx then + Utils.makeCursor (posX, posY, env) :: acc + else + acc + in build ( pos + 1 , str , stl , line , ltl - , #startX env - , posY + TC.ySpace + , posX + , posY , 0 - , nextLineNumber + , lineNumber + 1 , absIdx + 1 , cursorIdx , env , acc , searchPos ) - end + end | chr => if column < #scrollColumnStart env then build