add functionality to delete to/until prev match
This commit is contained in:
@@ -695,6 +695,38 @@ struct
|
|||||||
(app, buffer, cursorIdx, mode, startLine, searchList, drawMsg)
|
(app, buffer, cursorIdx, mode, startLine, searchList, drawMsg)
|
||||||
end
|
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 *)
|
(* command-parsing functions *)
|
||||||
(** number of characters which are integers *)
|
(** number of characters which are integers *)
|
||||||
fun getNumLength (pos, str) =
|
fun getNumLength (pos, str) =
|
||||||
@@ -809,6 +841,8 @@ struct
|
|||||||
| #"$" => deleteToEndOfLine app
|
| #"$" => deleteToEndOfLine app
|
||||||
| #"^" => deleteToFirstNonSpaceChr app
|
| #"^" => deleteToFirstNonSpaceChr app
|
||||||
| #"d" => deleteLine (app, count)
|
| #"d" => deleteLine (app, count)
|
||||||
|
| #"n" => deleteToNextMatch (app, count)
|
||||||
|
| #"N" => deleteToPrevMatch (app, count)
|
||||||
(* non-terminal commands which require appending chr *)
|
(* non-terminal commands which require appending chr *)
|
||||||
| #"t" => appendChr (app, chr, str)
|
| #"t" => appendChr (app, chr, str)
|
||||||
| #"T" => appendChr (app, chr, str)
|
| #"T" => appendChr (app, chr, str)
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ struct
|
|||||||
let
|
let
|
||||||
val {windowWidth, windowHeight, startLine, searchString, ...} = app
|
val {windowWidth, windowHeight, startLine, searchString, ...} = app
|
||||||
|
|
||||||
(* move LineGap to first line displayed on screen
|
(* move LineGap to first line displayed on screen *)
|
||||||
* and move searchList to line's start idx as well *)
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
|
||||||
(* get new startLine which may move screen depending on cursor movements *)
|
(* get new startLine which may move screen depending on cursor movements *)
|
||||||
|
|||||||
Reference in New Issue
Block a user