diff --git a/fcore/app-update.sml b/fcore/app-update.sml index c4568e7..2cb811c 100644 --- a/fcore/app-update.sml +++ b/fcore/app-update.sml @@ -695,6 +695,38 @@ struct (app, buffer, cursorIdx, mode, startLine, searchList, drawMsg) end + fun helpDeleteToMatch (app: app_type, low, high) = + let + val {buffer, searchString, ...} = app + val length = high - low + val buffer = LineGap.delete (low, length, buffer) + + val buffer = LineGap.goToEnd buffer + val initialMsg = [SEARCH (buffer, searchString)] + + val buffer = LineGap.goToIdx (low, buffer) + in + Finish.buildTextAndClear (app, buffer, low, SearchList.empty, initialMsg) + end + + fun deleteToNextMatch (app: app_type, count) = + let + val {cursorIdx, searchList, ...} = app + val newCursorIdx = SearchList.nextMatch (cursorIdx, searchList, count) + in + if newCursorIdx = ~1 orelse newCursorIdx <= cursorIdx then clearMode app + else helpDeleteToMatch (app, cursorIdx, newCursorIdx) + end + + fun deleteToPrevMatch (app: app_type, count) = + let + val {cursorIdx, searchList, ...} = app + val newCursorIdx = SearchList.prevMatch (cursorIdx, searchList, count) + in + if newCursorIdx = ~1 orelse newCursorIdx >= cursorIdx then clearMode app + else helpDeleteToMatch (app, newCursorIdx, cursorIdx) + end + (* command-parsing functions *) (** number of characters which are integers *) fun getNumLength (pos, str) = @@ -809,6 +841,8 @@ struct | #"$" => deleteToEndOfLine app | #"^" => deleteToFirstNonSpaceChr app | #"d" => deleteLine (app, count) + | #"n" => deleteToNextMatch (app, count) + | #"N" => deleteToPrevMatch (app, count) (* non-terminal commands which require appending chr *) | #"t" => appendChr (app, chr, str) | #"T" => appendChr (app, chr, str) diff --git a/fcore/finish.sml b/fcore/finish.sml index 2084f8a..190a22a 100644 --- a/fcore/finish.sml +++ b/fcore/finish.sml @@ -6,8 +6,7 @@ struct let val {windowWidth, windowHeight, startLine, searchString, ...} = app - (* move LineGap to first line displayed on screen - * and move searchList to line's start idx as well *) + (* move LineGap to first line displayed on screen *) val buffer = LineGap.goToLine (startLine, buffer) (* get new startLine which may move screen depending on cursor movements *)