implemented 'yh' motion (yank left)
This commit is contained in:
@@ -461,11 +461,8 @@ struct
|
|||||||
|
|
||||||
fun parseYankTerminal (str, count, app, chrCmd, time) =
|
fun parseYankTerminal (str, count, app, chrCmd, time) =
|
||||||
case chrCmd of
|
case chrCmd of
|
||||||
(* motions like yh / yj / yk / yl are not really needed.
|
#"h" => NormalYank.yankLeft (app, count)
|
||||||
* Vim supports them, but I never use them.
|
| #"y" => NormalYank.yankLine (app, count)
|
||||||
* I also don't need yx (yank a character and then remove it)
|
|
||||||
* because I never do that. *)
|
|
||||||
#"y" => NormalYank.yankLine (app, count)
|
|
||||||
| #"0" => NormalYank.yankToStartOfLine app
|
| #"0" => NormalYank.yankToStartOfLine app
|
||||||
| #"w" => NormalYank.yankWhenMovingForward (app, Cursor.nextWord, count)
|
| #"w" => NormalYank.yankWhenMovingForward (app, Cursor.nextWord, count)
|
||||||
| #"W" => NormalYank.yankWhenMovingForward (app, Cursor.nextWORD, count)
|
| #"W" => NormalYank.yankWhenMovingForward (app, Cursor.nextWORD, count)
|
||||||
|
|||||||
@@ -4,6 +4,24 @@ struct
|
|||||||
open DrawMsg
|
open DrawMsg
|
||||||
open MailboxType
|
open MailboxType
|
||||||
|
|
||||||
|
fun yankLeft (app: app_type, count) =
|
||||||
|
let
|
||||||
|
val {buffer, cursorIdx, ...} = app
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val min = Cursor.vi0 (buffer, cursorIdx)
|
||||||
|
val low = Cursor.viH (buffer, cursorIdx, 1)
|
||||||
|
|
||||||
|
val low = Int.max (min, low)
|
||||||
|
val length = cursorIdx - low
|
||||||
|
val str = LineGap.substring (low, length, buffer)
|
||||||
|
|
||||||
|
val msg = YANK str
|
||||||
|
val mode = NORMAL_MODE ""
|
||||||
|
in
|
||||||
|
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
|
||||||
|
end
|
||||||
|
|
||||||
fun yankLine (app: app_type, count) =
|
fun yankLine (app: app_type, count) =
|
||||||
let
|
let
|
||||||
val {buffer, cursorIdx, ...} = app
|
val {buffer, cursorIdx, ...} = app
|
||||||
|
|||||||
Reference in New Issue
Block a user