reimplement vi's 'E' command

This commit is contained in:
2025-07-20 14:00:59 +01:00
parent 2b060b99a0
commit 90c0d657bc
2 changed files with 32 additions and 2 deletions

View File

@@ -136,7 +136,38 @@ struct
end
end)
structure EndOfCurrentWORD =
MakeNextDfaLoopPlus1
(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