From 9b34014af1459e65cff027860ea98cd0895d2a21 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sun, 14 Sep 2025 10:28:42 +0100 Subject: [PATCH] a few bug fixes to NORMAL_SEARCH_MODE: the main one is that we were passing the general searchString to the resize function before, and we were drawing the wrong string because of that; another bug fix is that, on resizing, we have to update the mode to contain the recalculated searchScrollColumn --- fcore/normal-mode/normal-search-finish.sml | 47 +++++++------------ fcore/normal-mode/normal-search-mode-with.sml | 12 +++-- fcore/normal-mode/normal-search-mode.sml | 1 + 3 files changed, 26 insertions(+), 34 deletions(-) diff --git a/fcore/normal-mode/normal-search-finish.sml b/fcore/normal-mode/normal-search-finish.sml index 248a4a8..a5e38b1 100644 --- a/fcore/normal-mode/normal-search-finish.sml +++ b/fcore/normal-mode/normal-search-finish.sml @@ -82,23 +82,30 @@ struct ( app: app_type , newWindowWidth , newWindowHeight + , searchString , searchCursorIdx , tempSearchList , searchScrollColumn ) = let val - { buffer - , cursorIdx - , startLine = prevLineNumber - , searchString - , visualScrollColumn - , ... - } = app + {buffer, cursorIdx, startLine = prevLineNumber, visualScrollColumn, ...} = + app val floatWindowWidth = Real32.fromInt newWindowWidth val floatWindowHeight = Real32.fromInt newWindowHeight + val searchScrollColumn = + TextScroll.getScrollColumnFromString + (searchCursorIdx, newWindowWidth, searchScrollColumn) + + val mode = NORMAL_SEARCH_MODE + { searchString = searchString + , tempSearchList = tempSearchList + , searchCursorIdx = searchCursorIdx + , searchScrollColumn = searchScrollColumn + } + val searchStringPosY = newWindowHeight - TextConstants.ySpace - 5 val initialTextAcc = SearchBar.build @@ -112,28 +119,6 @@ struct , searchScrollColumn ) - val cursor = - let - val xpos = TextConstants.xSpace * (searchCursorIdx + 1) + 5 - val x = Real32.fromInt xpos - val y = Real32.fromInt searchStringPosY - val r: Real32.real = 0.67 - val g: Real32.real = 0.51 - val b: Real32.real = 0.83 - in - PipeCursor.lerp - ( x - , y - , 0.01 - , TextConstants.scale - , floatWindowWidth - , floatWindowHeight - , r - , g - , b - ) - end - val buffer = LineGap.goToIdx (cursorIdx, buffer) val cursorLine = LineGap.getLineNumberOfIdx (cursorIdx, buffer) val startLine = @@ -153,13 +138,13 @@ struct , tempSearchList , searchString , visualScrollColumn - , cursor :: initialTextAcc + , initialTextAcc ) val drawMsg = Vector.concat drawMsg val drawMsg = DrawMsg.DRAW_TEXT drawMsg val msgs = [MailboxType.DRAW drawMsg] in NormalSearchModeWith.bufferAndSize - (app, buffer, newWindowWidth, newWindowHeight, msgs) + (app, mode, buffer, newWindowWidth, newWindowHeight, msgs) end end diff --git a/fcore/normal-mode/normal-search-mode-with.sml b/fcore/normal-mode/normal-search-mode-with.sml index 1495b2e..fdbc0a5 100644 --- a/fcore/normal-mode/normal-search-mode-with.sml +++ b/fcore/normal-mode/normal-search-mode-with.sml @@ -102,10 +102,16 @@ struct end fun bufferAndSize - (app: app_type, newBuffer, newWindowWidth, newWindowHeight, newMsgs) = + ( app: app_type + , newMode + , newBuffer + , newWindowWidth + , newWindowHeight + , newMsgs + ) = let val - { mode + { mode = _ , windowWidth = _ , windowHeight = _ , msgs = _ @@ -118,7 +124,7 @@ struct , visualScrollColumn } = app in - { mode = mode + { mode = newMode , buffer = newBuffer , windowWidth = newWindowWidth , windowHeight = newWindowHeight diff --git a/fcore/normal-mode/normal-search-mode.sml b/fcore/normal-mode/normal-search-mode.sml index df763d0..722e0bd 100644 --- a/fcore/normal-mode/normal-search-mode.sml +++ b/fcore/normal-mode/normal-search-mode.sml @@ -213,6 +213,7 @@ struct ( app , width , height + , searchString , searchCursorIdx , tempSearchList , searchScrollColumn