pass time parameter in normal-delete.sml
This commit is contained in:
@@ -3,7 +3,7 @@ struct
|
||||
open AppType
|
||||
open MailboxType
|
||||
|
||||
fun deleteAndFinish (app: app_type, low, length, buffer) =
|
||||
fun deleteAndFinish (app: app_type, low, length, buffer, time) =
|
||||
let
|
||||
val buffer = LineGap.delete (low, length, buffer)
|
||||
|
||||
@@ -16,11 +16,11 @@ struct
|
||||
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg, time)
|
||||
end
|
||||
|
||||
(* equivalent of vi's 'x' command **)
|
||||
fun helpRemoveChr (app: app_type, buffer, cursorIdx, count) =
|
||||
fun helpRemoveChr (app: app_type, buffer, cursorIdx, count, time) =
|
||||
if count = 0 then
|
||||
let
|
||||
val searchString = #searchString app
|
||||
@@ -32,7 +32,7 @@ struct
|
||||
SearchList.buildRange (buffer, searchString, cursorIdx - 777)
|
||||
in
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, cursorIdx, searchList, initialMsg)
|
||||
(app, buffer, cursorIdx, searchList, initialMsg, time)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -56,9 +56,9 @@ struct
|
||||
(* vi simply doesn't do anything on 'x' command
|
||||
* when cursor is at start of line, and next chr is line break
|
||||
* so skip to end of loop by passing count of 0 *)
|
||||
helpRemoveChr (app, buffer, cursorIdx, 0)
|
||||
helpRemoveChr (app, buffer, cursorIdx, 0, time)
|
||||
else if cursorIsStart then
|
||||
helpRemoveChr (app, buffer, cursorIdx, 0)
|
||||
helpRemoveChr (app, buffer, cursorIdx, 0, time)
|
||||
else if nextIsEnd then
|
||||
let
|
||||
(* delete char at cursor and then decrement cursorIdx by 1
|
||||
@@ -73,21 +73,22 @@ struct
|
||||
then cursorIdx
|
||||
else cursorIdx - 1
|
||||
in
|
||||
helpRemoveChr (app, buffer, cursorIdx, count - 1)
|
||||
helpRemoveChr (app, buffer, cursorIdx, count - 1, time)
|
||||
end
|
||||
else
|
||||
let
|
||||
val searchString = #searchString app
|
||||
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||
in
|
||||
helpRemoveChr (app, buffer, cursorIdx, count - 1)
|
||||
helpRemoveChr (app, buffer, cursorIdx, count - 1, time)
|
||||
end
|
||||
end
|
||||
|
||||
fun removeChr (app: app_type, count) =
|
||||
helpRemoveChr (app, #buffer app, #cursorIdx app, count)
|
||||
fun removeChr (app: app_type, count, time) =
|
||||
helpRemoveChr (app, #buffer app, #cursorIdx app, count, time)
|
||||
|
||||
fun helpDelete (app: app_type, buffer, cursorIdx, otherIdx, count, fMove) =
|
||||
fun helpDelete
|
||||
(app: app_type, buffer, cursorIdx, otherIdx, count, fMove, time) =
|
||||
(* As a small optimisation to reduce allocations,
|
||||
* we accumulate otherIdx by calling fMove with it and the buffer
|
||||
* on each loop.
|
||||
@@ -119,7 +120,7 @@ struct
|
||||
val cursorIdx = Cursor.clipIdx (buffer, low)
|
||||
in
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, cursorIdx, searchList, initialMsg)
|
||||
(app, buffer, cursorIdx, searchList, initialMsg, time)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -128,13 +129,15 @@ struct
|
||||
val newOtherIdx = fMove (buffer, otherIdx)
|
||||
val newCount = if newOtherIdx = otherIdx then 0 else count - 1
|
||||
in
|
||||
helpDelete (app, buffer, cursorIdx, newOtherIdx, newCount, fMove)
|
||||
helpDelete (app, buffer, cursorIdx, newOtherIdx, newCount, fMove, time)
|
||||
end
|
||||
|
||||
fun delete (app: app_type, count, fMove) =
|
||||
helpDelete (app, #buffer app, #cursorIdx app, #cursorIdx app, count, fMove)
|
||||
fun delete (app: app_type, count, fMove, time) =
|
||||
let val {buffer, cursorIdx, ...} = app
|
||||
in helpDelete (app, buffer, cursorIdx, cursorIdx, count, fMove, time)
|
||||
end
|
||||
|
||||
fun deleteByDfa (app: app_type, count, fMove) =
|
||||
fun deleteByDfa (app: app_type, count, fMove, time) =
|
||||
let
|
||||
val {buffer, cursorIdx, searchString, ...} = app
|
||||
|
||||
@@ -145,10 +148,10 @@ struct
|
||||
val high = Int.max (cursorIdx, otherIdx)
|
||||
val length = high - low
|
||||
in
|
||||
deleteAndFinish (app, low, length, buffer)
|
||||
deleteAndFinish (app, low, length, buffer, time)
|
||||
end
|
||||
|
||||
fun deleteToEndOfLine (app: app_type) =
|
||||
fun deleteToEndOfLine (app: app_type, time) =
|
||||
let
|
||||
val {buffer, cursorIdx, ...} = app
|
||||
in
|
||||
@@ -168,11 +171,11 @@ struct
|
||||
val length = lastChr - cursorIdx
|
||||
val buffer = LineGap.delete (cursorIdx, length, buffer)
|
||||
in
|
||||
helpRemoveChr (app, buffer, cursorIdx, 1)
|
||||
helpRemoveChr (app, buffer, cursorIdx, 1, time)
|
||||
end
|
||||
end
|
||||
|
||||
fun deleteLine (app: app_type, count) =
|
||||
fun deleteLine (app: app_type, count, time) =
|
||||
let
|
||||
val {buffer, cursorIdx, searchString, ...} = app
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
@@ -182,16 +185,16 @@ struct
|
||||
|
||||
val length = finishIdx - startIdx
|
||||
in
|
||||
deleteAndFinish (app, startIdx, length, buffer)
|
||||
deleteAndFinish (app, startIdx, length, buffer, time)
|
||||
end
|
||||
|
||||
fun helpDeleteLineBack (app, buffer, low, high, count) =
|
||||
fun helpDeleteLineBack (app, buffer, low, high, count, time) =
|
||||
if count = 0 then
|
||||
let
|
||||
val low = Int.max (low, 0)
|
||||
val length = high - low
|
||||
in
|
||||
deleteAndFinish (app, low, length, buffer)
|
||||
deleteAndFinish (app, low, length, buffer, time)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -201,19 +204,19 @@ struct
|
||||
val low = Cursor.vi0 (buffer, low)
|
||||
val newCount = if low = 0 then 0 else count - 1
|
||||
in
|
||||
helpDeleteLineBack (app, buffer, low, high, newCount)
|
||||
helpDeleteLineBack (app, buffer, low, high, newCount, time)
|
||||
end
|
||||
|
||||
fun deleteLineBack (app: app_type, count) =
|
||||
fun deleteLineBack (app: app_type, count, time) =
|
||||
let
|
||||
val {buffer, cursorIdx, ...} = app
|
||||
val low = Cursor.vi0 (buffer, cursorIdx)
|
||||
val high = Cursor.viDlr (buffer, cursorIdx, 1) + 1
|
||||
in
|
||||
helpDeleteLineBack (app, buffer, low, high, count)
|
||||
helpDeleteLineBack (app, buffer, low, high, count, time)
|
||||
end
|
||||
|
||||
fun deleteToFirstNonSpaceChr (app: app_type) =
|
||||
fun deleteToFirstNonSpaceChr (app: app_type, time) =
|
||||
let
|
||||
val
|
||||
{ buffer
|
||||
@@ -237,7 +240,7 @@ struct
|
||||
val high = Int.max (cursorIdx, otherIdx)
|
||||
val length = high - low
|
||||
in
|
||||
deleteAndFinish (app, low, length, buffer)
|
||||
deleteAndFinish (app, low, length, buffer, time)
|
||||
end
|
||||
|
||||
fun helpDeleteToChr
|
||||
@@ -248,7 +251,7 @@ struct
|
||||
val high = Int.max (cursorIdx, otherIdx)
|
||||
val length = high - low
|
||||
in
|
||||
deleteAndFinish (app, low, length, buffer)
|
||||
deleteAndFinish (app, low, length, buffer, #bufferModifyTime app)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -273,7 +276,7 @@ struct
|
||||
, chr
|
||||
)
|
||||
|
||||
fun deleteToStart (app: app_type) =
|
||||
fun deleteToStart (app: app_type, time) =
|
||||
let
|
||||
val {cursorIdx, buffer, windowWidth, windowHeight, searchString, ...} =
|
||||
app
|
||||
@@ -305,10 +308,10 @@ struct
|
||||
val mode = NORMAL_MODE ""
|
||||
in
|
||||
AppWith.bufferAndCursorIdx
|
||||
(app, buffer, cursorIdx, mode, startLine, searchList, drawMsg)
|
||||
(app, buffer, cursorIdx, mode, startLine, searchList, drawMsg, time)
|
||||
end
|
||||
|
||||
fun helpDeleteToMatch (app: app_type, low, high) =
|
||||
fun helpDeleteToMatch (app: app_type, low, high, time) =
|
||||
let
|
||||
val {buffer, searchString, ...} = app
|
||||
val length = high - low
|
||||
@@ -322,10 +325,10 @@ struct
|
||||
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg, time)
|
||||
end
|
||||
|
||||
fun deleteToNextMatch (app: app_type, count) =
|
||||
fun deleteToNextMatch (app: app_type, count, time) =
|
||||
let
|
||||
val {cursorIdx, searchList, ...} = app
|
||||
val newCursorIdx = SearchList.nextMatch (cursorIdx, searchList, count)
|
||||
@@ -333,10 +336,10 @@ struct
|
||||
if newCursorIdx = ~1 orelse newCursorIdx <= cursorIdx then
|
||||
Finish.clearMode app
|
||||
else
|
||||
helpDeleteToMatch (app, cursorIdx, newCursorIdx)
|
||||
helpDeleteToMatch (app, cursorIdx, newCursorIdx, time)
|
||||
end
|
||||
|
||||
fun deleteToPrevMatch (app: app_type, count) =
|
||||
fun deleteToPrevMatch (app: app_type, count, time) =
|
||||
let
|
||||
val {cursorIdx, searchList, ...} = app
|
||||
val newCursorIdx = SearchList.prevMatch (cursorIdx, searchList, count)
|
||||
@@ -344,10 +347,10 @@ struct
|
||||
if newCursorIdx = ~1 orelse newCursorIdx >= cursorIdx then
|
||||
Finish.clearMode app
|
||||
else
|
||||
helpDeleteToMatch (app, newCursorIdx, cursorIdx)
|
||||
helpDeleteToMatch (app, newCursorIdx, cursorIdx, time)
|
||||
end
|
||||
|
||||
fun deleteInsideWord (app: app_type) =
|
||||
fun deleteInsideWord (app: app_type, time) =
|
||||
let
|
||||
val {buffer, cursorIdx, searchString, ...} = app
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
@@ -370,11 +373,12 @@ struct
|
||||
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, low, searchList, initialMsg, time)
|
||||
end
|
||||
end
|
||||
|
||||
fun deleteInsideWORD (app: app_type) =
|
||||
fun deleteInsideWORD (app: app_type, time) =
|
||||
let
|
||||
val {buffer, cursorIdx, searchString, ...} = app
|
||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||
@@ -397,11 +401,12 @@ struct
|
||||
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, low, searchList, initialMsg, time)
|
||||
end
|
||||
end
|
||||
|
||||
fun finishAfterDeleteInside (app: app_type, origLow, high) =
|
||||
fun finishAfterDeleteInside (app: app_type, origLow, high, time) =
|
||||
if origLow = high then
|
||||
Finish.clearMode app
|
||||
else
|
||||
@@ -419,10 +424,11 @@ struct
|
||||
|
||||
val buffer = LineGap.goToIdx (origLow, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, origLow, searchList, initialMsg)
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, origLow, searchList, initialMsg, time)
|
||||
end
|
||||
|
||||
fun deleteInsideChrOpen (app: app_type, chr) =
|
||||
fun deleteInsideChrOpen (app: app_type, chr, time) =
|
||||
let
|
||||
val {cursorIdx, buffer, ...} = app
|
||||
|
||||
@@ -433,10 +439,10 @@ struct
|
||||
val buffer = LineGap.goToIdx (origLow, buffer)
|
||||
val high = Cursor.matchPair (buffer, origLow)
|
||||
in
|
||||
finishAfterDeleteInside (app, origLow, high)
|
||||
finishAfterDeleteInside (app, origLow, high, time)
|
||||
end
|
||||
|
||||
fun deleteInsideChrClose (app: app_type, chr) =
|
||||
fun deleteInsideChrClose (app: app_type, chr, time) =
|
||||
let
|
||||
val {cursorIdx, buffer, ...} = app
|
||||
|
||||
@@ -447,10 +453,10 @@ struct
|
||||
val buffer = LineGap.goToIdx (high, buffer)
|
||||
val origLow = Cursor.matchPair (buffer, high)
|
||||
in
|
||||
finishAfterDeleteInside (app, origLow, high)
|
||||
finishAfterDeleteInside (app, origLow, high, time)
|
||||
end
|
||||
|
||||
fun deleteAroundChrOpen (app: app_type, chr) =
|
||||
fun deleteAroundChrOpen (app: app_type, chr, time) =
|
||||
let
|
||||
val {cursorIdx, buffer, ...} = app
|
||||
|
||||
@@ -462,10 +468,10 @@ struct
|
||||
val high = Cursor.matchPair (buffer, low)
|
||||
in
|
||||
if low = high then Finish.clearMode app
|
||||
else deleteAndFinish (app, low, high - low + 1, buffer)
|
||||
else deleteAndFinish (app, low, high - low + 1, buffer, time)
|
||||
end
|
||||
|
||||
fun deleteAroundChrClose (app: app_type, chr) =
|
||||
fun deleteAroundChrClose (app: app_type, chr, time) =
|
||||
let
|
||||
val {cursorIdx, buffer, ...} = app
|
||||
|
||||
@@ -477,10 +483,10 @@ struct
|
||||
val low = Cursor.matchPair (buffer, high)
|
||||
in
|
||||
if low = high then Finish.clearMode app
|
||||
else deleteAndFinish (app, low, high - low + 1, buffer)
|
||||
else deleteAndFinish (app, low, high - low + 1, buffer, time)
|
||||
end
|
||||
|
||||
fun deletePair (app: app_type) =
|
||||
fun deletePair (app: app_type, time) =
|
||||
let
|
||||
val {cursorIdx, buffer, ...} = app
|
||||
val otherIdx = Cursor.matchPair (buffer, cursorIdx)
|
||||
@@ -514,7 +520,8 @@ struct
|
||||
|
||||
val buffer = LineGap.goToIdx (low, buffer)
|
||||
in
|
||||
Finish.buildTextAndClear (app, buffer, low, searchList, initialMsg)
|
||||
Finish.buildTextAndClear
|
||||
(app, buffer, low, searchList, initialMsg, time)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user