add another custom delete function ('deleteToFirstNonSpaceChr', which can be triggered with command d^ and it works fine on testing
This commit is contained in:
@@ -396,6 +396,27 @@ struct
|
|||||||
buildTextAndClear (app, buffer, cursorIdx)
|
buildTextAndClear (app, buffer, cursorIdx)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun deleteToFirstNonSpaceChr (app: app_type) =
|
||||||
|
let
|
||||||
|
val {buffer, cursorIdx, windowWidth, windowHeight, startLine, ...} = app
|
||||||
|
|
||||||
|
(* move LineGap and buffer to start of line *)
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val otherIdx = Cursor.vi0 (buffer, cursorIdx)
|
||||||
|
|
||||||
|
(* move cursorIdx to first character on line *)
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val otherIdx = Cursor.firstNonSpaceChr (buffer, otherIdx)
|
||||||
|
|
||||||
|
val low = Int.min (cursorIdx, otherIdx)
|
||||||
|
val high = Int.max (cursorIdx, otherIdx)
|
||||||
|
val length = high - low
|
||||||
|
|
||||||
|
val buffer = LineGap.delete (low, length, buffer)
|
||||||
|
in
|
||||||
|
buildTextAndClear (app, buffer, low)
|
||||||
|
end
|
||||||
|
|
||||||
fun helpDeleteToChr (app: app_type, buffer, cursorIdx, count, fMove, chr) =
|
fun helpDeleteToChr (app: app_type, buffer, cursorIdx, count, fMove, chr) =
|
||||||
if count = 0 then
|
if count = 0 then
|
||||||
buildTextAndClearAfterChr (app, buffer, cursorIdx)
|
buildTextAndClearAfterChr (app, buffer, cursorIdx)
|
||||||
@@ -526,14 +547,8 @@ struct
|
|||||||
| #"e" => delete (app, count, Cursor.endOfWord)
|
| #"e" => delete (app, count, Cursor.endOfWord)
|
||||||
| #"E" => delete (app, count, Cursor.endOfWORD)
|
| #"E" => delete (app, count, Cursor.endOfWORD)
|
||||||
| #"0" => delete (app, 1, Cursor.vi0)
|
| #"0" => delete (app, 1, Cursor.vi0)
|
||||||
(* todo for '$':
|
|
||||||
* Cursor.viDlr takes us to last chr on line
|
|
||||||
* but it leaves last chr on line alone.
|
|
||||||
* Have to increment by 1. *)
|
|
||||||
| #"$" => deleteToEndOfLine app
|
| #"$" => deleteToEndOfLine app
|
||||||
(* todo: requires custom delete function
|
| #"^" => deleteToFirstNonSpaceChr app
|
||||||
| #"^" => firstNonSpaceChr app
|
|
||||||
*)
|
|
||||||
(* non-terminal commands which require appending chr *)
|
(* non-terminal commands which require appending chr *)
|
||||||
| #"t" => appendChr (app, chr, str)
|
| #"t" => appendChr (app, chr, str)
|
||||||
| #"T" => appendChr (app, chr, str)
|
| #"T" => appendChr (app, chr, str)
|
||||||
|
|||||||
Reference in New Issue
Block a user