add d% motion for deleting a matching pair
This commit is contained in:
@@ -5,9 +5,9 @@ struct
|
|||||||
|
|
||||||
fun deleteAndFinish (app: app_type, low, length, buffer) =
|
fun deleteAndFinish (app: app_type, low, length, buffer) =
|
||||||
let
|
let
|
||||||
val searchString = #searchString app
|
|
||||||
val buffer = LineGap.delete (low, length, buffer)
|
val buffer = LineGap.delete (low, length, buffer)
|
||||||
|
|
||||||
|
val searchString = #searchString app
|
||||||
val buffer = LineGap.goToEnd buffer
|
val buffer = LineGap.goToEnd buffer
|
||||||
val initialMsg = [SEARCH (buffer, searchString)]
|
val initialMsg = [SEARCH (buffer, searchString)]
|
||||||
|
|
||||||
@@ -479,4 +479,42 @@ struct
|
|||||||
if low = high then Finish.clearMode app
|
if low = high then Finish.clearMode app
|
||||||
else deleteAndFinish (app, low, high - low + 1, buffer)
|
else deleteAndFinish (app, low, high - low + 1, buffer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun deletePair (app: app_type) =
|
||||||
|
let
|
||||||
|
val {cursorIdx, buffer, ...} = app
|
||||||
|
val otherIdx = Cursor.matchPair (buffer, cursorIdx)
|
||||||
|
in
|
||||||
|
if otherIdx = cursorIdx then
|
||||||
|
Finish.clearMode app
|
||||||
|
else
|
||||||
|
let
|
||||||
|
val low = Int.min (cursorIdx, otherIdx)
|
||||||
|
val high = Int.max (cursorIdx, otherIdx)
|
||||||
|
val length = high - low + 1
|
||||||
|
|
||||||
|
val buffer = LineGap.delete (low, length, buffer)
|
||||||
|
val buffer = LineGap.goToIdx (low, buffer)
|
||||||
|
|
||||||
|
val low =
|
||||||
|
if Cursor.isCursorAtStartOfLine (buffer, low) then
|
||||||
|
(* we may have deleted the last character of this current line,
|
||||||
|
* and if we did, we have to move the cursor back by 1 *)
|
||||||
|
Int.max (low - 1, 0)
|
||||||
|
else
|
||||||
|
low
|
||||||
|
|
||||||
|
val searchString = #searchString app
|
||||||
|
val buffer = LineGap.goToEnd buffer
|
||||||
|
val initialMsg = [SEARCH (buffer, searchString)]
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (low + 777, buffer)
|
||||||
|
val searchList =
|
||||||
|
SearchList.buildRange (buffer, searchString, low - 777)
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (low, buffer)
|
||||||
|
in
|
||||||
|
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ struct
|
|||||||
| #"d" => NormalDelete.deleteLine (app, count)
|
| #"d" => NormalDelete.deleteLine (app, count)
|
||||||
| #"n" => NormalDelete.deleteToNextMatch (app, count)
|
| #"n" => NormalDelete.deleteToNextMatch (app, count)
|
||||||
| #"N" => NormalDelete.deleteToPrevMatch (app, count)
|
| #"N" => NormalDelete.deleteToPrevMatch (app, count)
|
||||||
|
| #"%" => NormalDelete.deletePair app
|
||||||
(* 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)
|
||||||
|
|||||||
Reference in New Issue
Block a user