From 06106f5de8d56c1e5ed039ad062c1dcf0d57f474 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Wed, 8 Oct 2025 05:40:29 +0100 Subject: [PATCH] remove 'searchString' field from app_type, because the same role is fulfilled by new 'dfa' field --- fcore/app-type.sml | 2 - fcore/normal-mode/make-normal-delete.sml | 69 +++++++++---------- fcore/normal-mode/normal-finish.sml | 10 ++- fcore/normal-mode/normal-mode-with.sml | 20 +----- fcore/normal-mode/normal-mode.sml | 8 +-- fcore/normal-mode/normal-search-mode-with.sml | 9 --- fcore/normal-mode/normal-search-mode.sml | 4 +- fcore/normal-mode/normal-yank.sml | 4 +- fcore/search-list/search-list.sml | 4 +- 9 files changed, 46 insertions(+), 84 deletions(-) diff --git a/fcore/app-type.sml b/fcore/app-type.sml index ea9a08a..869b1da 100644 --- a/fcore/app-type.sml +++ b/fcore/app-type.sml @@ -15,7 +15,6 @@ struct , buffer: LineGap.t , bufferModifyTime: Time.time , searchList: PersistentVector.t - , searchString: string , windowWidth: int , windowHeight: int (* line to start drawing from *) @@ -35,7 +34,6 @@ struct , buffer = buffer , bufferModifyTime = time , searchList = SearchList.empty - , searchString = "" , windowWidth = windowWidth , windowHeight = windowHeight , startLine = 0 diff --git a/fcore/normal-mode/make-normal-delete.sml b/fcore/normal-mode/make-normal-delete.sml index ee029de..22a0126 100644 --- a/fcore/normal-mode/make-normal-delete.sml +++ b/fcore/normal-mode/make-normal-delete.sml @@ -12,13 +12,12 @@ struct fun finishAfterDeletingBuffer (app: app_type, low, buffer, time, msgs) = let val buffer = LineGap.goToIdx (low, buffer) - val searchString = #searchString app val buffer = LineGap.goToStart buffer - val msgs = SEARCH (buffer, searchString, time) :: msgs + val msgs = SEARCH (buffer, raise Fail "searchString", time) :: msgs val buffer = LineGap.goToIdx (low - 1111, buffer) val (buffer, searchList) = - SearchList.buildRange (buffer, searchString, low + 1111, #dfa app) + SearchList.buildRange (buffer, low + 1111, #dfa app) val buffer = LineGap.goToIdx (low, buffer) in @@ -236,13 +235,12 @@ struct val buffer = LineGap.delete (low, length, buffer) val buffer = LineGap.goToStart buffer - val searchString = #searchString app - val initialMsg = SEARCH (buffer, searchString, time) :: initialMsg + val initialMsg = + SEARCH (buffer, raise Fail "searchString", time) :: initialMsg val buffer = LineGap.goToIdx (cursorIdx - 1111, buffer) val (buffer, searchList) = - SearchList.buildRange - (buffer, searchString, cursorIdx + 1111, #dfa app) + SearchList.buildRange (buffer, cursorIdx + 1111, #dfa app) (* If we have deleted from the buffer so that cursorIdx * is no longer a valid idx, @@ -377,7 +375,7 @@ struct fun deleteToEndOfPrevWord (app: app_type, count, time) = let - val {buffer, cursorIdx, searchString, ...} = app + val {buffer, cursorIdx, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val low = Cursor.endOfPrevWord (buffer, cursorIdx, count) @@ -389,7 +387,7 @@ struct fun deleteToEndOfPrevWORD (app: app_type, count, time) = let - val {buffer, cursorIdx, searchString, ...} = app + val {buffer, cursorIdx, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val low = Cursor.endOfPrevWORD (buffer, cursorIdx, count) @@ -636,15 +634,7 @@ struct fun deleteToFirstNonSpaceChr (app: app_type, time) = let - val - { buffer - , cursorIdx - , windowWidth - , windowHeight - , startLine - , searchString - , ... - } = app + val {buffer, cursorIdx, windowWidth, windowHeight, startLine, ...} = app (* move LineGap and buffer to start of line *) val buffer = LineGap.goToIdx (cursorIdx, buffer) @@ -706,8 +696,7 @@ struct fun deleteToStart (app: app_type, time) : AppType.app_type = let - val {cursorIdx, buffer, windowWidth, windowHeight, searchString, dfa, ...} = - app + val {cursorIdx, buffer, windowWidth, windowHeight, dfa, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val cursorIdx = Cursor.viDlrForDelete (buffer, cursorIdx, 1) @@ -716,11 +705,12 @@ struct val buffer = LineGap.delete (0, cursorIdx, buffer) val buffer = LineGap.goToStart buffer - val initialMsg = SEARCH (buffer, #searchString app, time) :: initialMsg + val initialMsg = + SEARCH (buffer, raise Fail "searchString", time) :: initialMsg val buffer = LineGap.goToIdx (cursorIdx - 1111, buffer) val (buffer, searchList) = - SearchList.buildRange (buffer, searchString, cursorIdx + 1111, dfa) + SearchList.buildRange (buffer, cursorIdx + 1111, dfa) val cursorIdx = 0 val startLine = 0 @@ -757,18 +747,18 @@ struct fun helpDeleteToMatch (app: app_type, low, high, time) = let - val {buffer, searchString, dfa, ...} = app + val {buffer, dfa, ...} = app val buffer = LineGap.goToIdx (high, buffer) val length = high - low val initialMsg = Fn.initMsgs (low, length, buffer) val buffer = LineGap.delete (low, length, buffer) val buffer = LineGap.goToStart buffer - val initialMsg = SEARCH (buffer, searchString, time) :: initialMsg + val initialMsg = + SEARCH (buffer, raise Fail "searchString", time) :: initialMsg val buffer = LineGap.goToIdx (low - 1111, buffer) - val (buffer, searchList) = - SearchList.buildRange (buffer, searchString, low + 1111, dfa) + val (buffer, searchList) = SearchList.buildRange (buffer, low + 1111, dfa) val buffer = LineGap.goToIdx (low, buffer) in @@ -805,7 +795,7 @@ struct fun deleteInsideWord (app: app_type, time) = let - val {buffer, cursorIdx, searchString, dfa, ...} = app + val {buffer, cursorIdx, dfa, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val low = Cursor.prevWordStrict (buffer, cursorIdx, 1) @@ -823,11 +813,12 @@ struct val buffer = LineGap.delete (low, length, buffer) val buffer = LineGap.goToStart buffer - val initialMsg = SEARCH (buffer, searchString, time) :: initialMsg + val initialMsg = + SEARCH (buffer, raise Fail "searchString", time) :: initialMsg val buffer = LineGap.goToIdx (low - 1111, buffer) val (buffer, searchList) = - SearchList.buildRange (buffer, searchString, low + 1111, dfa) + SearchList.buildRange (buffer, low + 1111, dfa) val buffer = LineGap.goToIdx (low, buffer) in @@ -840,7 +831,7 @@ struct fun deleteInsideWORD (app: app_type, time) = let - val {buffer, cursorIdx, searchString, dfa, ...} = app + val {buffer, cursorIdx, dfa, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val low = Cursor.prevWORDStrict (buffer, cursorIdx, 1) @@ -855,11 +846,12 @@ struct val buffer = LineGap.delete (low, length, buffer) val buffer = LineGap.goToStart buffer - val initialMsg = SEARCH (buffer, searchString, time) :: initialMsg + val initialMsg = + SEARCH (buffer, raise Fail "searchString", time) :: initialMsg val buffer = LineGap.goToIdx (low - 1111, buffer) val (buffer, searchList) = - SearchList.buildRange (buffer, searchString, low + 1111, dfa) + SearchList.buildRange (buffer, low + 1111, dfa) val buffer = LineGap.goToIdx (low, buffer) in @@ -875,7 +867,7 @@ struct NormalFinish.clearMode app else let - val {cursorIdx, buffer, searchString, dfa, ...} = app + val {cursorIdx, buffer, dfa, ...} = app val low = origLow + 1 val length = high - low @@ -884,11 +876,12 @@ struct val buffer = LineGap.delete (low, length, buffer) val buffer = LineGap.goToStart buffer - val initialMsg = SEARCH (buffer, searchString, time) :: initialMsg + val initialMsg = + SEARCH (buffer, raise Fail "searchString", time) :: initialMsg val buffer = LineGap.goToIdx (low - 1111, buffer) val (buffer, searchList) = - SearchList.buildRange (buffer, searchString, low + 1111, dfa) + SearchList.buildRange (buffer, low + 1111, dfa) val buffer = LineGap.goToIdx (origLow, buffer) in @@ -996,13 +989,13 @@ struct else low - val searchString = #searchString app val buffer = LineGap.goToStart buffer - val initialMsg = SEARCH (buffer, searchString, time) :: initialMsg + val initialMsg = + SEARCH (buffer, raise Fail "searchString", time) :: initialMsg val buffer = LineGap.goToIdx (low - 1111, buffer) val (buffer, searchList) = - SearchList.buildRange (buffer, searchString, low + 1111, dfa) + SearchList.buildRange (buffer, low + 1111, dfa) val buffer = LineGap.goToIdx (low, buffer) in diff --git a/fcore/normal-mode/normal-finish.sml b/fcore/normal-mode/normal-finish.sml index 4887094..e2be005 100644 --- a/fcore/normal-mode/normal-finish.sml +++ b/fcore/normal-mode/normal-finish.sml @@ -15,7 +15,6 @@ struct val { windowWidth , windowHeight - , searchString , visualScrollColumn = prevScrollColumn , startLine = prevLineNumber , ... @@ -69,9 +68,10 @@ struct in if searchTime >= #bufferModifyTime app then let - val {buffer, searchString, cursorIdx, bufferModifyTime, ...} = app - val app = NormalModeWith.searchList - (app, searchList, buffer, searchString, bufferModifyTime) + val {buffer, cursorIdx, bufferModifyTime, ...} = app + val app = + NormalModeWith.searchList + (app, searchList, buffer, bufferModifyTime) in buildTextAndClear (app, buffer, cursorIdx, searchList, [], bufferModifyTime) @@ -89,7 +89,6 @@ struct , startLine , cursorIdx , searchList - , searchString , bufferModifyTime , visualScrollColumn = prevScrollColumn , ... @@ -136,7 +135,6 @@ struct , startLine = prevLineNumber , cursorIdx , searchList - , searchString , bufferModifyTime , visualScrollColumn , ... diff --git a/fcore/normal-mode/normal-mode-with.sml b/fcore/normal-mode/normal-mode-with.sml index 17bb3ee..be7a178 100644 --- a/fcore/normal-mode/normal-mode-with.sml +++ b/fcore/normal-mode/normal-mode-with.sml @@ -13,7 +13,6 @@ struct , windowHeight , searchList , visualScrollColumn - , searchString , startLine , cursorIdx , dfa @@ -27,7 +26,6 @@ struct , windowHeight = windowHeight , searchList = searchList , visualScrollColumn = visualScrollColumn - , searchString = searchString , startLine = startLine , cursorIdx = cursorIdx , dfa = dfa @@ -54,7 +52,6 @@ struct , searchList = _ , visualScrollColumn = _ , msgs = _ - , searchString , startLine , cursorIdx , dfa @@ -68,7 +65,6 @@ struct , searchList = newSearchList , visualScrollColumn = newVisualScrollColumn , msgs = newMsgs - , searchString = searchString , startLine = startLine , cursorIdx = cursorIdx , dfa = dfa @@ -96,7 +92,6 @@ struct , searchList = _ , visualScrollColumn = _ , msgs = _ - , searchString , windowWidth , windowHeight , dfa @@ -110,7 +105,6 @@ struct , searchList = newSearchList , visualScrollColumn = newVisualScrollColumn , msgs = newMsgs - , searchString = searchString , windowWidth = windowWidth , windowHeight = windowHeight , dfa = dfa @@ -125,7 +119,6 @@ struct , buffer , bufferModifyTime , searchList - , searchString , cursorIdx , windowWidth , windowHeight @@ -139,7 +132,6 @@ struct , buffer = buffer , bufferModifyTime = bufferModifyTime , searchList = searchList - , searchString = searchString , cursorIdx = cursorIdx , windowWidth = windowWidth , windowHeight = windowHeight @@ -157,7 +149,6 @@ struct , buffer = _ , bufferModifyTime , searchList - , searchString , cursorIdx , windowWidth , windowHeight @@ -171,7 +162,6 @@ struct , buffer = newBuffer , bufferModifyTime = bufferModifyTime , searchList = searchList - , searchString = searchString , cursorIdx = cursorIdx , windowWidth = windowWidth , windowHeight = windowHeight @@ -181,19 +171,12 @@ struct } end - fun searchList - ( app: app_type - , newSearchList - , newBuffer - , newSearchString - , newBufferModifyTime - ) = + fun searchList (app: app_type, newSearchList, newBuffer, newBufferModifyTime) = let val { searchList = _ , buffer = _ , bufferModifyTime - , searchString = _ , msgs , mode , cursorIdx @@ -207,7 +190,6 @@ struct { searchList = newSearchList , buffer = newBuffer , bufferModifyTime = newBufferModifyTime - , searchString = newSearchString , msgs = msgs , mode = mode , cursorIdx = cursorIdx diff --git a/fcore/normal-mode/normal-mode.sml b/fcore/normal-mode/normal-mode.sml index cf74d00..b6e2aa8 100644 --- a/fcore/normal-mode/normal-mode.sml +++ b/fcore/normal-mode/normal-mode.sml @@ -31,9 +31,9 @@ struct let open MailboxType - val {cursorIdx = origCursorIdx, searchString, ...} = app + val {cursorIdx = origCursorIdx, ...} = app val buffer = LineGap.goToStart buffer - val initialMsg = [SEARCH (buffer, searchString, time)] + val initialMsg = [SEARCH (buffer, raise Fail "searchString", time)] in NormalDelete.finishAfterDeletingBuffer (app, origCursorIdx, buffer, time, initialMsg) @@ -94,7 +94,7 @@ struct let open MailboxType - val {cursorIdx, buffer, searchString, ...} = app + val {cursorIdx, buffer, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val lineStart = Cursor.vi0 (buffer, cursorIdx) @@ -127,7 +127,7 @@ struct loop (nextLine, buffer, count - 1) val buffer = LineGap.goToStart buffer - val initialMsg = [SEARCH (buffer, searchString, time)] + val initialMsg = [SEARCH (buffer, raise Fail "searchString", time)] in NormalDelete.finishAfterDeletingBuffer (app, newCursorIdx, buffer, time, initialMsg) diff --git a/fcore/normal-mode/normal-search-mode-with.sml b/fcore/normal-mode/normal-search-mode-with.sml index bb6d710..6f91dc4 100644 --- a/fcore/normal-mode/normal-search-mode-with.sml +++ b/fcore/normal-mode/normal-search-mode-with.sml @@ -5,7 +5,6 @@ struct fun returnToNormalMode ( app: app_type , newBuffer - , newSearchString , newSearchList , newStartLine , newMode @@ -16,7 +15,6 @@ struct val { mode = _ , buffer = _ - , searchString = _ , searchList = _ , startLine = _ , msgs = _ @@ -30,7 +28,6 @@ struct in { mode = newMode , buffer = newBuffer - , searchString = newSearchString , searchList = newSearchList , startLine = newStartLine , dfa = newDfa @@ -49,7 +46,6 @@ struct val { mode = _ , buffer = _ - , searchString , searchList , startLine = _ , msgs = _ @@ -65,7 +61,6 @@ struct , buffer = newBuffer , startLine = newStartLine , msgs = newMsgs - , searchString = searchString , searchList = searchList , bufferModifyTime = bufferModifyTime , windowWidth = windowWidth @@ -81,7 +76,6 @@ struct val { mode , buffer - , searchString , searchList = _ , startLine , msgs @@ -98,7 +92,6 @@ struct , buffer = buffer , startLine = startLine , msgs = msgs - , searchString = searchString , bufferModifyTime = bufferModifyTime , windowWidth = windowWidth , windowHeight = windowHeight @@ -123,7 +116,6 @@ struct , windowHeight = _ , msgs = _ , buffer = _ - , searchString , searchList , startLine , bufferModifyTime @@ -139,7 +131,6 @@ struct , msgs = newMsgs , searchList = searchList , startLine = startLine - , searchString = searchString , bufferModifyTime = bufferModifyTime , cursorIdx = cursorIdx , visualScrollColumn = visualScrollColumn diff --git a/fcore/normal-mode/normal-search-mode.sml b/fcore/normal-mode/normal-search-mode.sml index dafb0e2..124db0b 100644 --- a/fcore/normal-mode/normal-search-mode.sml +++ b/fcore/normal-mode/normal-search-mode.sml @@ -10,7 +10,7 @@ struct if caseSensitive then CaseSensitiveDfa.fromString searchString else CaseInsensitiveDfa.fromString searchString in - SearchList.buildRange (buffer, searchString, cursorIdx + 1111, dfa) + SearchList.buildRange (buffer, cursorIdx + 1111, dfa) end fun addChr @@ -106,7 +106,7 @@ struct else CaseInsensitiveDfa.fromString searchString in NormalSearchModeWith.returnToNormalMode - (app, buffer, searchString, tempSearchList, startLine, mode, dfa, msgs) + (app, buffer, tempSearchList, startLine, mode, dfa, msgs) end fun backspace diff --git a/fcore/normal-mode/normal-yank.sml b/fcore/normal-mode/normal-yank.sml index cb5e371..3d3615f 100644 --- a/fcore/normal-mode/normal-yank.sml +++ b/fcore/normal-mode/normal-yank.sml @@ -259,7 +259,7 @@ struct fun yankInsideWord (app: app_type) = let - val {buffer, cursorIdx, searchString, ...} = app + val {buffer, cursorIdx, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val low = Cursor.prevWordStrict (buffer, cursorIdx, 1) val high = Cursor.endOfWordStrict (buffer, cursorIdx, 1) @@ -278,7 +278,7 @@ struct fun yankInsideWORD (app: app_type) = let - val {buffer, cursorIdx, searchString, ...} = app + val {buffer, cursorIdx, ...} = app val buffer = LineGap.goToIdx (cursorIdx, buffer) val low = Cursor.prevWORDStrict (buffer, cursorIdx, 1) val high = Cursor.endOfWORDStrict (buffer, cursorIdx, 1) diff --git a/fcore/search-list/search-list.sml b/fcore/search-list/search-list.sml index 84fa330..f339c79 100644 --- a/fcore/search-list/search-list.sml +++ b/fcore/search-list/search-list.sml @@ -159,8 +159,8 @@ struct ) end - fun buildRange (buffer, searchString, finishIdx, dfa) = - if String.size searchString > 0 andalso Vector.length dfa > 0 then + fun buildRange (buffer, finishIdx, dfa) = + if Vector.length dfa > 0 then rangeLoop ( dfa , #idx buffer