From 21e12addf34538286e4980326380cc748e48e99f Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Tue, 23 Sep 2025 09:16:02 +0100 Subject: [PATCH] in text builders, check when on newline if this is the second last character in the file, and draw it on a newline if so. This is to align with the design decision that we want the second-last character to be selectable --- fcore/text-builder/text-builder-with-cursor.sml | 10 ++++++++++ fcore/text-builder/text-builder-with-highlight.sml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/fcore/text-builder/text-builder-with-cursor.sml b/fcore/text-builder/text-builder-with-cursor.sml index 48c5863..cc9b3a6 100644 --- a/fcore/text-builder/text-builder-with-cursor.sml +++ b/fcore/text-builder/text-builder-with-cursor.sml @@ -3,6 +3,11 @@ struct structure TC = TextConstants structure Utils = TextBuilderUtils + fun isSecondLastChr (pos, str, tl) = + case tl of + [] => pos = String.size str - 2 + | _ => false + fun goToFirstLineAfter (stl, ltl, posY, lineNumber, absIdx, cursorIdx, env, acc) = case (stl, ltl) of @@ -135,6 +140,11 @@ struct #"\n" => if lineNumber + 1 > #lastLineNumber env then acc + else if isSecondLastChr (pos, str, stl) then + if absIdx = cursorIdx then + Utils.makeCursor (#startX env, posY + TC.ySpace, env) :: acc + else + acc else let val acc = diff --git a/fcore/text-builder/text-builder-with-highlight.sml b/fcore/text-builder/text-builder-with-highlight.sml index ce8daea..b038b0c 100644 --- a/fcore/text-builder/text-builder-with-highlight.sml +++ b/fcore/text-builder/text-builder-with-highlight.sml @@ -3,6 +3,11 @@ struct structure TC = TextConstants structure Utils = TextBuilderUtils + fun isSecondLastChr (pos, str, tl) = + case tl of + [] => pos = String.size str - 2 + | _ => false + fun goToFirstLineAfter (stl, ltl, posY, lineNumber, absIdx, cursorIdx, env, acc, searchPos) = case (stl, ltl) of @@ -232,6 +237,11 @@ struct | #"\n" => if lineNumber + 1 > #lastLineNumber env then acc + else if isSecondLastChr (pos, str, stl) then + if absIdx = cursorIdx then + Utils.makeCursor (#startX env, posY + TC.ySpace, env) :: acc + else + acc else let val acc =