add count to 'x' command, allowing [count] chars to be deleted
This commit is contained in:
@@ -233,9 +233,23 @@ struct
|
|||||||
end
|
end
|
||||||
|
|
||||||
(* equivalent of vi's 'x' command *)
|
(* equivalent of vi's 'x' command *)
|
||||||
fun deleteChr (app: app_type, count) =
|
fun helpDeleteChr (app: app_type, buffer, cursorIdx, count) =
|
||||||
|
if count = 0 then
|
||||||
|
let
|
||||||
|
val {startLine, windowWidth, windowHeight, ...} = app
|
||||||
|
|
||||||
|
val buffer = LineGap.goToLine (startLine, buffer)
|
||||||
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
|
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
||||||
|
|
||||||
|
val drawMsg =
|
||||||
|
TextBuilder.build
|
||||||
|
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
||||||
|
in
|
||||||
|
(newApp, drawMsg)
|
||||||
|
end
|
||||||
|
else
|
||||||
let
|
let
|
||||||
val {buffer, cursorIdx, startLine, windowWidth, windowHeight, ...} = app
|
|
||||||
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
(* Explanation of how Vi's 'x' command behaves:
|
(* Explanation of how Vi's 'x' command behaves:
|
||||||
@@ -268,33 +282,20 @@ struct
|
|||||||
orelse cursorIdx = 0 then
|
orelse cursorIdx = 0 then
|
||||||
cursorIdx
|
cursorIdx
|
||||||
else cursorIdx - 1
|
else cursorIdx - 1
|
||||||
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
|
||||||
|
|
||||||
val drawMsg =
|
|
||||||
TextBuilder.build
|
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
helpDeleteChr (app, buffer, cursorIdx, count - 1)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
val buffer = LineGap.delete (cursorIdx, 1, buffer)
|
||||||
|
|
||||||
val buffer = LineGap.goToLine (startLine, buffer)
|
|
||||||
val newApp = AppWith.bufferAndCursorIdx
|
|
||||||
(app, buffer, cursorIdx, NORMAL_MODE "", startLine)
|
|
||||||
|
|
||||||
val drawMsg =
|
|
||||||
TextBuilder.build
|
|
||||||
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
|
||||||
in
|
in
|
||||||
(newApp, drawMsg)
|
helpDeleteChr (app, buffer, cursorIdx, count - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun deleteChr (app: app_type, count) =
|
||||||
|
helpDeleteChr (app, #buffer app, #cursorIdx app, count)
|
||||||
|
|
||||||
(* number of characters which are integers *)
|
(* number of characters which are integers *)
|
||||||
fun getNumLength (pos, str) =
|
fun getNumLength (pos, str) =
|
||||||
if pos = String.size str then
|
if pos = String.size str then
|
||||||
|
|||||||
Reference in New Issue
Block a user