diff --git a/fcore/normal-mode/normal-mode.sml b/fcore/normal-mode/normal-mode.sml index 2812729..9e44dc5 100644 --- a/fcore/normal-mode/normal-mode.sml +++ b/fcore/normal-mode/normal-mode.sml @@ -5,14 +5,14 @@ struct open AppType open InputMsg - (* todo: create draw msg showing search bar *) fun switchToNormalSearchMode (app: app_type) = let val mode = NORMAL_SEARCH_MODE {searchString = "", tempSearchList = Vector.fromList []} in - NormalModeWith.mode (app, mode, []) + NormalSearchFinish.onSearchChanged + (app, "", Vector.fromList [], #buffer app) end fun getNumLength (pos, str) = diff --git a/fcore/normal-mode/normal-search-finish.sml b/fcore/normal-mode/normal-search-finish.sml new file mode 100644 index 0000000..792655a --- /dev/null +++ b/fcore/normal-mode/normal-search-finish.sml @@ -0,0 +1,53 @@ +structure NormalSearchFinish = +struct + open AppType + + fun onSearchChanged (app: app_type, searchString, tempSearchList, buffer) = + let + open DrawMsg + + val {buffer, cursorIdx, startLine, windowWidth, windowHeight, ...} = app + val mode = + NORMAL_SEARCH_MODE + {searchString = searchString, tempSearchList = tempSearchList} + + val floatWindowWidth = Real32.fromInt windowWidth + val floatWindowHeight = Real32.fromInt windowHeight + + val searchStringPosY = windowHeight - TextConstants.ySpace - 5 + + val initialTextAcc = TextBuilder.buildLineToList + ( searchString + , 5 + , searchStringPosY + , windowWidth + , floatWindowWidth + , floatWindowHeight + ) + + val buffer = LineGap.goToLine (startLine, buffer) + val startLine = TextWindow.getStartLine + (buffer, startLine, cursorIdx, windowWidth, windowHeight) + + val remainingWindowHeight = windowHeight - (TextConstants.ySpace * 2) + + val msgs = TextBuilder.buildWithExisting + ( startLine + , cursorIdx + , buffer + , windowWidth + , remainingWindowHeight + , floatWindowWidth + , floatWindowHeight + , tempSearchList + , searchString + , [] + , initialTextAcc + , [] + ) + in + NormalSearchModeWith.changeTempSearchString + (app, buffer, startLine, mode, msgs) + end + +end diff --git a/fcore/normal-mode/normal-search-mode.sml b/fcore/normal-mode/normal-search-mode.sml index 2ce1f13..abf3e6e 100644 --- a/fcore/normal-mode/normal-search-mode.sml +++ b/fcore/normal-mode/normal-search-mode.sml @@ -4,54 +4,6 @@ struct open InputMsg open MailboxType - fun onSearchChanged (app: app_type, searchString, tempSearchList, buffer) = - let - open DrawMsg - - val {buffer, cursorIdx, startLine, windowWidth, windowHeight, ...} = app - val mode = - NORMAL_SEARCH_MODE - {searchString = searchString, tempSearchList = tempSearchList} - - val floatWindowWidth = Real32.fromInt windowWidth - val floatWindowHeight = Real32.fromInt windowHeight - - val searchStringPosY = windowHeight - TextConstants.ySpace - 5 - - val initialTextAcc = TextBuilder.buildLineToList - ( searchString - , 5 - , searchStringPosY - , windowWidth - , floatWindowWidth - , floatWindowHeight - ) - - val buffer = LineGap.goToLine (startLine, buffer) - val startLine = TextWindow.getStartLine - (buffer, startLine, cursorIdx, windowWidth, windowHeight) - - val remainingWindowHeight = windowHeight - (TextConstants.ySpace * 2) - - val msgs = TextBuilder.buildWithExisting - ( startLine - , cursorIdx - , buffer - , windowWidth - , remainingWindowHeight - , floatWindowWidth - , floatWindowHeight - , tempSearchList - , searchString - , [] - , initialTextAcc - , [] - ) - in - NormalSearchModeWith.changeTempSearchString - (app, buffer, startLine, mode, msgs) - end - fun addChr (app: app_type, searchString, chr) = let val {cursorIdx, buffer, ...} = app @@ -63,7 +15,8 @@ struct val tempSearchList = SearchList.buildRange (buffer, searchString, cursorIdx + 1111) in - onSearchChanged (app, searchString, tempSearchList, buffer) + NormalSearchFinish.onSearchChanged + (app, searchString, tempSearchList, buffer) end (* return to normal mode, keeping the same searchString and searchList diff --git a/shf.mlb b/shf.mlb index 99c0633..3f39a47 100644 --- a/shf.mlb +++ b/shf.mlb @@ -39,6 +39,7 @@ fcore/cursor.sml fcore/text-window.sml fcore/normal-mode/normal-finish.sml +fcore/normal-mode/normal-search-finish.sml fcore/move.sml fcore/normal-mode/normal-move.sml