done implementing 'deleteInside' and 'deleteAroundd' commands
This commit is contained in:
@@ -449,4 +449,34 @@ struct
|
||||
in
|
||||
finishAfterDeleteInside (app, origLow, high)
|
||||
end
|
||||
|
||||
fun deleteAroundChrOpen (app: app_type, chr) =
|
||||
let
|
||||
val {cursorIdx, buffer, ...} = app
|
||||
|
||||
val start = cursorIdx + 1
|
||||
val buffer = LineGap.goToIdx (start, buffer)
|
||||
|
||||
val low = Cursor.toPrevChr (buffer, start, chr)
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
val high = Cursor.matchPair (buffer, low)
|
||||
in
|
||||
if low = high then Finish.clearMode app
|
||||
else deleteAndFinish (app, low, high - low + 1, buffer)
|
||||
end
|
||||
|
||||
fun deleteAroundChrClose (app: app_type, chr) =
|
||||
let
|
||||
val {cursorIdx, buffer, ...} = app
|
||||
|
||||
val start = Int.max (cursorIdx - 1, 0)
|
||||
val buffer = LineGap.goToIdx (start, buffer)
|
||||
|
||||
val high = Cursor.toNextChr (buffer, start, chr)
|
||||
val buffer = LineGap.goToIdx (high, buffer)
|
||||
val low = Cursor.matchPair (buffer, high)
|
||||
in
|
||||
if low = high then Finish.clearMode app
|
||||
else deleteAndFinish (app, low, high - low + 1, buffer)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -125,6 +125,18 @@ struct
|
||||
| #">" => NormalDelete.deleteInsideChrClose (app, chr)
|
||||
| _ => Finish.clearMode app
|
||||
|
||||
fun parseDeleteAround (app, chr) =
|
||||
case chr of
|
||||
#"(" => NormalDelete.deleteInsideChrOpen (app, chr)
|
||||
| #"[" => NormalDelete.deleteInsideChrOpen (app, chr)
|
||||
| #"{" => NormalDelete.deleteInsideChrOpen (app, chr)
|
||||
| #"<" => NormalDelete.deleteInsideChrOpen (app, chr)
|
||||
| #")" => NormalDelete.deleteAroundChrClose (app, chr)
|
||||
| #"]" => NormalDelete.deleteAroundChrClose (app, chr)
|
||||
| #"}" => NormalDelete.deleteAroundChrClose (app, chr)
|
||||
| #">" => NormalDelete.deleteAroundChrClose (app, chr)
|
||||
| _ => Finish.clearMode app
|
||||
|
||||
fun parseDelete (strPos, str, count, app, newCmd) =
|
||||
if strPos = String.size str - 1 then
|
||||
(* have to check newCmd *)
|
||||
@@ -161,6 +173,7 @@ struct
|
||||
| #"F" => appendChr (app, chr, str)
|
||||
| #"g" => appendChr (app, chr, str)
|
||||
| #"i" => appendChr (app, chr, str)
|
||||
| #"a" => appendChr (app, chr, str)
|
||||
(* invalid command: reset mode *)
|
||||
| _ => Finish.clearMode app)
|
||||
| KEY_ESC => Finish.clearMode app
|
||||
@@ -232,6 +245,14 @@ struct
|
||||
Finish.resizeText (app, width, height)
|
||||
| WITH_SEARCH_LIST searchList =>
|
||||
Finish.withSearchList (app, searchList))
|
||||
| #"a" =>
|
||||
(case newCmd of
|
||||
CHAR_EVENT chr => parseDeleteAround (app, chr)
|
||||
| KEY_ESC => Finish.clearMode app
|
||||
| RESIZE_EVENT (width, height) =>
|
||||
Finish.resizeText (app, width, height)
|
||||
| WITH_SEARCH_LIST searchList =>
|
||||
Finish.withSearchList (app, searchList))
|
||||
| _ => Finish.clearMode app
|
||||
|
||||
(* useful reference as list of non-terminal commands *)
|
||||
|
||||
Reference in New Issue
Block a user