From 0f945c9646a63ab0e7ee7c4baf8af2b44d2f4dd8 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Mon, 1 Sep 2025 02:26:25 +0100 Subject: [PATCH] create an 'exitToNormalMode' function which exits NORMAL_SEARCH_MODE and creates a message to redraw the screen so that it looks like normal mode --- fcore/normal-mode/normal-search-mode.sml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fcore/normal-mode/normal-search-mode.sml b/fcore/normal-mode/normal-search-mode.sml index 6d1ea14..43c593b 100644 --- a/fcore/normal-mode/normal-search-mode.sml +++ b/fcore/normal-mode/normal-search-mode.sml @@ -66,6 +66,16 @@ struct onSearchChanged (app, searchString, tempSearchList, buffer) end + (* return to normal mode, keeping the same searchString and searchList + * from before entering this mode. *) + fun exitToNormalMode (app: app_type) = + let + val {buffer, cursorIdx, searchList, bufferModifyTime, ...} = app + in + NormalFinish.buildTextAndClear + (app, buffer, cursorIdx, searchList, [], bufferModifyTime) + end + (* save search string and tempSearchList and return to normal mode *) fun finishSearch (app: app_type, searchString, tempSearchList) = let @@ -103,7 +113,7 @@ struct fun update (app, {searchString, tempSearchList}, msg, time) = case msg of CHAR_EVENT chr => addChr (app, searchString, chr) - | KEY_ESC => NormalFinish.clearMode app + | KEY_ESC => exitToNormalMode app | KEY_ENTER => finishSearch (app, searchString, tempSearchList) | RESIZE_EVENT (width, height) => app | WITH_SEARCH_LIST searchList => app