done refactoring terminal yank commands
This commit is contained in:
@@ -149,4 +149,43 @@ struct
|
||||
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
|
||||
end
|
||||
end
|
||||
|
||||
fun yankToNextMatch (app: app_type, count) =
|
||||
let
|
||||
val {cursorIdx, searchList, buffer, ...} = app
|
||||
val high = SearchList.nextMatch (cursorIdx, searchList, count)
|
||||
in
|
||||
if high = ~1 orelse high <= cursorIdx then
|
||||
NormalFinish.clearMode app
|
||||
else
|
||||
let
|
||||
val length = high - cursorIdx
|
||||
val buffer = LineGap.goToIdx (high, 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 yankToPrevMatch (app: app_type, count) =
|
||||
let
|
||||
val {cursorIdx, searchList, buffer, ...} = app
|
||||
val low = SearchList.prevMatch (cursorIdx, searchList, count)
|
||||
in
|
||||
if low = ~1 orelse low >= cursorIdx then
|
||||
NormalFinish.clearMode app
|
||||
else
|
||||
let
|
||||
val length = cursorIdx - low
|
||||
|
||||
val str = LineGap.substring (low, length, buffer)
|
||||
val msg = YANK str
|
||||
val mode = NORMAL_MODE ""
|
||||
in
|
||||
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user