implemented 'diw' and 'diW' commands for deleting inside a word or WORD
This commit is contained in:
@@ -604,9 +604,11 @@ struct
|
|||||||
|
|
||||||
(* equivalent of vi's 'b' command *)
|
(* equivalent of vi's 'b' command *)
|
||||||
val prevWord = ViWordDfa.startOfCurrentWord
|
val prevWord = ViWordDfa.startOfCurrentWord
|
||||||
|
val prevWordStrict = ViWordDfa.startOfCurrentWordStrict
|
||||||
|
|
||||||
(* equivalent of vi's 'B' command *)
|
(* equivalent of vi's 'B' command *)
|
||||||
val prevWORD = ViWORDDfa.startOfCurrentWORD
|
val prevWORD = ViWORDDfa.startOfCurrentWORD
|
||||||
|
val prevWORDStrict = ViWORDDfa.startOfCurrentWORDStrict
|
||||||
|
|
||||||
(* equivalent of vi's 'ge' command *)
|
(* equivalent of vi's 'ge' command *)
|
||||||
val endOfPrevWord = ViWordDfa.endOfPrevWord
|
val endOfPrevWord = ViWordDfa.endOfPrevWord
|
||||||
|
|||||||
@@ -380,4 +380,59 @@ struct
|
|||||||
else
|
else
|
||||||
helpDeleteToMatch (app, newCursorIdx, cursorIdx)
|
helpDeleteToMatch (app, newCursorIdx, cursorIdx)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun deleteInsideWord (app: app_type) =
|
||||||
|
let
|
||||||
|
val {buffer, cursorIdx, searchString, ...} = app
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val low = Cursor.prevWordStrict (buffer, cursorIdx, 1)
|
||||||
|
val high = Cursor.endOfWordForDelete (buffer, cursorIdx, 1)
|
||||||
|
in
|
||||||
|
if low = high then
|
||||||
|
app
|
||||||
|
else
|
||||||
|
let
|
||||||
|
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 + 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
|
||||||
|
|
||||||
|
fun deleteInsideWORD (app: app_type) =
|
||||||
|
let
|
||||||
|
val {buffer, cursorIdx, searchString, ...} = app
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val low = Cursor.prevWORDStrict (buffer, cursorIdx, 1)
|
||||||
|
val high = Cursor.endOfWORDForDelete (buffer, cursorIdx, 1)
|
||||||
|
in
|
||||||
|
if low = high then
|
||||||
|
app
|
||||||
|
else
|
||||||
|
let
|
||||||
|
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 + 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
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ struct
|
|||||||
| #"f" => appendChr (app, chr, str)
|
| #"f" => appendChr (app, chr, str)
|
||||||
| #"F" => appendChr (app, chr, str)
|
| #"F" => appendChr (app, chr, str)
|
||||||
| #"g" => appendChr (app, chr, str)
|
| #"g" => appendChr (app, chr, str)
|
||||||
|
| #"i" => appendChr (app, chr, str)
|
||||||
(* invalid command: reset mode *)
|
(* invalid command: reset mode *)
|
||||||
| _ => Finish.clearMode app)
|
| _ => Finish.clearMode app)
|
||||||
| KEY_ESC => Finish.clearMode app
|
| KEY_ESC => Finish.clearMode app
|
||||||
@@ -209,6 +210,16 @@ struct
|
|||||||
Finish.resizeText (app, width, height)
|
Finish.resizeText (app, width, height)
|
||||||
| WITH_SEARCH_LIST searchList =>
|
| WITH_SEARCH_LIST searchList =>
|
||||||
Finish.withSearchList (app, searchList))
|
Finish.withSearchList (app, searchList))
|
||||||
|
| #"i" =>
|
||||||
|
(case newCmd of
|
||||||
|
CHAR_EVENT #"w" => NormalDelete.deleteInsideWord app
|
||||||
|
| CHAR_EVENT #"W" => NormalDelete.deleteInsideWORD app
|
||||||
|
| CHAR_EVENT _ => Finish.clearMode app
|
||||||
|
| 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
|
| _ => Finish.clearMode app
|
||||||
|
|
||||||
(* useful reference as list of non-terminal commands *)
|
(* useful reference as list of non-terminal commands *)
|
||||||
|
|||||||
Reference in New Issue
Block a user