reimplement vi's 'E' command
This commit is contained in:
@@ -136,7 +136,38 @@ struct
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
val startOfNextWORD = StartOfNextWORD.next
|
structure EndOfCurrentWORD =
|
||||||
val endOfPrevWORD = EndOfPrevWORD.prev
|
MakeNextDfaLoopPlus1
|
||||||
val startOfCurrentWORD = StartOfCurrentWORD.prev
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
|
||||||
|
fun fStart (idx, absIdx, str, tl, currentState, counter) =
|
||||||
|
if idx = String.size str then
|
||||||
|
case tl of
|
||||||
|
str :: tl => fStart (0, absIdx, str, tl, currentState, counter)
|
||||||
|
| [] => Int.max (0, absIdx - 2)
|
||||||
|
else
|
||||||
|
let
|
||||||
|
val chr = String.sub (str, idx)
|
||||||
|
val newState = next (currentState, chr)
|
||||||
|
in
|
||||||
|
if newState = spaceAfterNonBlankState then
|
||||||
|
if counter - 1 = 0 then
|
||||||
|
Int.max (0, absIdx - 1)
|
||||||
|
else
|
||||||
|
fStart
|
||||||
|
(idx + 1, absIdx + 1, str, tl, startState, counter - 1)
|
||||||
|
else
|
||||||
|
fStart (idx + 1, absIdx + 1, str, tl, newState, counter)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
(* W *)
|
||||||
|
val startOfNextWORD = StartOfNextWORD.next
|
||||||
|
(* gE *)
|
||||||
|
val endOfPrevWORD = EndOfPrevWORD.prev
|
||||||
|
(* B *)
|
||||||
|
val startOfCurrentWORD = StartOfCurrentWORD.prev
|
||||||
|
(* E *)
|
||||||
|
val endOfCurrentWORD = EndOfCurrentWORD.next
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1169,8 +1169,7 @@ struct
|
|||||||
toEndOfWord (lineGap, cursorIdx, helpEndOfWord)
|
toEndOfWord (lineGap, cursorIdx, helpEndOfWord)
|
||||||
|
|
||||||
(* equivalent of vi's `E` command *)
|
(* equivalent of vi's `E` command *)
|
||||||
fun endOfWORD (lineGap, cursorIdx) =
|
val endOfWORD = ViWORDDfa.endOfCurrentWORD
|
||||||
toEndOfWord (lineGap, cursorIdx, helpEndOfWORD)
|
|
||||||
|
|
||||||
(* vi's 'e' command takes user last char in word
|
(* vi's 'e' command takes user last char in word
|
||||||
* but 'de' deletes up to and including last char of word
|
* but 'de' deletes up to and including last char of word
|
||||||
|
|||||||
Reference in New Issue
Block a user