add functionality for commands: 'dgg' (delete from cursor to start of buffer), 'dge' (delete from cursor to the end of the previous word) and 'dgE' (delete from cursor to the end of the previous WORD)
This commit is contained in:
@@ -463,6 +463,26 @@ struct
|
|||||||
helpDeleteToChr
|
helpDeleteToChr
|
||||||
(app, #buffer app, #cursorIdx app, #cursorIdx app, count, fMove, fInc, chr)
|
(app, #buffer app, #cursorIdx app, #cursorIdx app, count, fMove, fInc, chr)
|
||||||
|
|
||||||
|
fun deleteToStart (app: app_type) =
|
||||||
|
let
|
||||||
|
val {cursorIdx, buffer, windowWidth, windowHeight, ...} = app
|
||||||
|
|
||||||
|
val buffer = LineGap.delete(0, cursorIdx, buffer)
|
||||||
|
val cursorIdx = 0
|
||||||
|
val startLine = 0
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
|
||||||
|
val drawMsg =
|
||||||
|
TextBuilder.build
|
||||||
|
(startLine, cursorIdx, buffer, windowWidth, windowHeight)
|
||||||
|
|
||||||
|
val mode = NORMAL_MODE ""
|
||||||
|
val newApp = AppWith.bufferAndCursorIdx
|
||||||
|
(app, buffer, cursorIdx, mode, startLine)
|
||||||
|
in
|
||||||
|
(newApp, drawMsg)
|
||||||
|
end
|
||||||
|
|
||||||
(* command-parsing functions *)
|
(* command-parsing functions *)
|
||||||
(** number of characters which are integers *)
|
(** number of characters which are integers *)
|
||||||
fun getNumLength (pos, str) =
|
fun getNumLength (pos, str) =
|
||||||
@@ -592,44 +612,40 @@ struct
|
|||||||
#"t" =>
|
#"t" =>
|
||||||
(* delete till chr, forwards *)
|
(* delete till chr, forwards *)
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr =>
|
CHAR_EVENT chr => deleteToChr (app, 1, Cursor.tillNextChr, op+, chr)
|
||||||
deleteToChr (app, 1, Cursor.tillNextChr, op+, chr)
|
| KEY_ESC => clearMode app
|
||||||
| KEY_ESC =>
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
clearMode app
|
|
||||||
| RESIZE_EVENT (width, height) =>
|
|
||||||
resizeText (app, width, height))
|
|
||||||
| #"T" =>
|
| #"T" =>
|
||||||
(* delete till chr, backwards *)
|
(* delete till chr, backwards *)
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr =>
|
CHAR_EVENT chr => deleteToChr (app, 1, Cursor.tillPrevChr, op-, chr)
|
||||||
deleteToChr (app, 1, Cursor.tillPrevChr, op-, chr)
|
| KEY_ESC => clearMode app
|
||||||
| KEY_ESC =>
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
clearMode app
|
|
||||||
| RESIZE_EVENT (width, height) =>
|
|
||||||
resizeText (app, width, height))
|
|
||||||
| #"d" =>
|
| #"d" =>
|
||||||
(* delete whole line *)
|
(* delete whole line *)
|
||||||
clearMode app
|
clearMode app
|
||||||
| #"f" =>
|
| #"f" =>
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr =>
|
CHAR_EVENT chr => deleteToChr (app, count, Cursor.toNextChr, op+, chr)
|
||||||
deleteToChr (app, count, Cursor.toNextChr, op+, chr)
|
| KEY_ESC => clearMode app
|
||||||
| KEY_ESC =>
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
clearMode app
|
|
||||||
| RESIZE_EVENT (width, height) =>
|
|
||||||
resizeText (app, width, height))
|
|
||||||
| #"F" =>
|
| #"F" =>
|
||||||
(* delete to chr, backwards *)
|
(* delete to chr, backwards *)
|
||||||
(case newCmd of
|
(case newCmd of
|
||||||
CHAR_EVENT chr =>
|
CHAR_EVENT chr => deleteToChr (app, count, Cursor.toPrevChr, op-, chr)
|
||||||
deleteToChr (app, count, Cursor.toPrevChr, op-, chr)
|
| KEY_ESC => clearMode app
|
||||||
| KEY_ESC =>
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
clearMode app
|
|
||||||
| RESIZE_EVENT (width, height) =>
|
|
||||||
resizeText (app, width, height))
|
|
||||||
| #"g" =>
|
| #"g" =>
|
||||||
(* todo: same events as handleGo *)
|
(* same events as handleGo *)
|
||||||
clearMode app
|
(case newCmd of
|
||||||
|
CHAR_EVENT chr =>
|
||||||
|
(case chr of
|
||||||
|
#"e" => delete (app, count, Cursor.endOfPrevWord)
|
||||||
|
| #"E" => delete (app, count, Cursor.endOfPrevWORD)
|
||||||
|
| #"g" => deleteToStart app
|
||||||
|
| _ => clearMode app)
|
||||||
|
| KEY_ESC => clearMode app
|
||||||
|
| RESIZE_EVENT (width, height) => resizeText (app, width, height))
|
||||||
| _ => clearMode app
|
| _ => clearMode app
|
||||||
|
|
||||||
(* useful reference as list of non-terminal commands *)
|
(* useful reference as list of non-terminal commands *)
|
||||||
|
|||||||
Reference in New Issue
Block a user