rename function for vi's 'x' command from deleteChr to removeChr, because it helps avoid confusion with motion-based delete (for example, 'dw')

This commit is contained in:
2024-11-08 15:27:16 +00:00
parent 88f4ff6057
commit f7c99530ae

View File

@@ -233,7 +233,7 @@ struct
end end
(* equivalent of vi's 'x' command *) (* equivalent of vi's 'x' command *)
fun helpDeleteChr (app: app_type, buffer, cursorIdx, count) = fun helpRemoveChr (app: app_type, buffer, cursorIdx, count) =
if count = 0 then if count = 0 then
let let
val {startLine, windowWidth, windowHeight, ...} = app val {startLine, windowWidth, windowHeight, ...} = app
@@ -270,9 +270,9 @@ struct
(* vi simply doesn't do anything on 'x' command (* vi simply doesn't do anything on 'x' command
* when cursor is at start of line, and next chr is line break * when cursor is at start of line, and next chr is line break
* so skip to end of loop by passing count of 0 *) * so skip to end of loop by passing count of 0 *)
helpDeleteChr (app, buffer, cursorIdx, 0) helpRemoveChr (app, buffer, cursorIdx, 0)
else if cursorIsStart then else if cursorIsStart then
helpDeleteChr (app, buffer, cursorIdx, 0) helpRemoveChr (app, buffer, cursorIdx, 0)
else if nextIsEnd then else if nextIsEnd then
let let
(* delete char at cursor and then decrement cursorIdx by 1 (* delete char at cursor and then decrement cursorIdx by 1
@@ -284,18 +284,18 @@ struct
cursorIdx cursorIdx
else cursorIdx - 1 else cursorIdx - 1
in in
helpDeleteChr (app, buffer, cursorIdx, count - 1) helpRemoveChr (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)
in in
helpDeleteChr (app, buffer, cursorIdx, count - 1) helpRemoveChr (app, buffer, cursorIdx, count - 1)
end end
end end
fun deleteChr (app: app_type, count) = fun removeChr (app: app_type, count) =
helpDeleteChr (app, #buffer app, #cursorIdx app, count) helpRemoveChr (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) =
@@ -366,7 +366,7 @@ struct
else else
moveToLine (app, count - 1) moveToLine (app, count - 1)
| #"%" => moveToMatchingPair app | #"%" => moveToMatchingPair app
| #"x" => deleteChr (app, count) | #"x" => removeChr (app, count)
(* multi-char commands which can be appended *) (* multi-char commands which can be appended *)
| #"t" => appendChr (app, chr, str) | #"t" => appendChr (app, chr, str)
| #"T" => appendChr (app, chr, str) | #"T" => appendChr (app, chr, str)