remove usages of 'Cursor.toNextChr' and delete it

This commit is contained in:
2025-10-18 15:14:41 +01:00
parent ee96419901
commit e07f21d6f4
3 changed files with 24 additions and 7 deletions

View File

@@ -304,9 +304,6 @@ struct
fun tillNextChr (lineGap, cursorIdx, chr) =
nextChr (lineGap, cursorIdx, chr, startTillNextChr)
fun toNextChr (lineGap, cursorIdx, chr) =
nextChr (lineGap, cursorIdx, chr, startToNextChr)
structure ToNextChr =
MakeIfCharFolderNext
(struct

View File

@@ -531,8 +531,7 @@ struct
case String.sub (str, strPos + 1) of
#"t" => NormalYank.yankToChr (app, 1, Cursor.tillNextChr, op+, chrCmd)
| #"T" => NormalYank.yankToChr (app, 1, Cursor.tillPrevChr, op-, chrCmd)
| #"f" =>
NormalYank.yankToChr (app, count, Cursor.toNextChr, op+, chrCmd)
| #"f" => NormalYank.yankToNextChr (app, count, chrCmd)
| #"F" =>
NormalYank.yankToChr (app, count, Cursor.toPrevChr, op-, chrCmd)
| #"g" => parseYankGo (count, app, chrCmd)

View File

@@ -230,6 +230,27 @@ struct
(app, buffer, cursorIdx, newOtherIdx, newCount, fMove, fInc, chr)
end
fun yankToNextChr (app: app_type, count, chr) =
let
val {buffer, cursorIdx, ...} = app
val buffer = LineGap.goToIdx (cursorIdx, buffer)
val newCursorIdx =
Cursor.toNextChrNew (buffer, cursorIdx, {findChr = chr, count = count})
in
if newCursorIdx = ~1 then
NormalFinish.clearMode app
else
let
val length = newCursorIdx - cursorIdx + 1
val buffer = LineGap.goToIdx (newCursorIdx, buffer)
val str = LineGap.substring (cursorIdx, length, buffer)
val msg = YANK str
val mode = NORMAL_MODE ""
in
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
end
end
fun yankToChr (app: app_type, count, fMove, fInc, chr) =
helpYankToChr
( app
@@ -329,7 +350,7 @@ struct
val start = Int.max (cursorIdx - 1, 0)
val buffer = LineGap.goToIdx (start, buffer)
val high = Cursor.toNextChr (buffer, start, chr)
val high = Cursor.toNextChrNew (buffer, start, {findChr = chr, count = 1})
val buffer = LineGap.goToIdx (high, buffer)
val low = Cursor.matchPair (buffer, high) + 1
in
@@ -361,7 +382,7 @@ struct
val start = Int.max (cursorIdx - 1, 0)
val buffer = LineGap.goToIdx (start, buffer)
val high = Cursor.toNextChr (buffer, start, chr)
val high = Cursor.toNextChrNew (buffer, start, {findChr = chr, count = 1})
val buffer = LineGap.goToIdx (high, buffer)
val low = Cursor.matchPair (buffer, high)
val high = high + 1