add functions to yank to end-of-previous-character, and to yank from current line to start of buffer
This commit is contained in:
@@ -68,7 +68,7 @@ struct
|
|||||||
val startState = startState
|
val startState = startState
|
||||||
|
|
||||||
structure Folder =
|
structure Folder =
|
||||||
MakeCharFolderNext
|
MakeCharFolderPrev
|
||||||
(struct
|
(struct
|
||||||
val startState = startState
|
val startState = startState
|
||||||
val tables = tables
|
val tables = tables
|
||||||
@@ -78,7 +78,7 @@ struct
|
|||||||
currentState = nonBlankAfterSpaceState
|
currentState = nonBlankAfterSpaceState
|
||||||
end)
|
end)
|
||||||
|
|
||||||
val fStart = Folder.foldNext
|
val fStart = Folder.foldPrev
|
||||||
end)
|
end)
|
||||||
|
|
||||||
structure StartOfCurrentWORDFolder =
|
structure StartOfCurrentWORDFolder =
|
||||||
|
|||||||
@@ -275,6 +275,15 @@ struct
|
|||||||
| #"a" => appendChr (app, chrCmd, str)
|
| #"a" => appendChr (app, chrCmd, str)
|
||||||
| _ => NormalFinish.clearMode app
|
| _ => NormalFinish.clearMode app
|
||||||
|
|
||||||
|
fun parseYankGo (count, app, chrCmd) =
|
||||||
|
case chrCmd of
|
||||||
|
#"e" =>
|
||||||
|
NormalYank.yankWhenMovingBackPlusOne (app, Cursor.endOfPrevWord, count)
|
||||||
|
| #"E" =>
|
||||||
|
NormalYank.yankWhenMovingBackPlusOne (app, Cursor.endOfPrevWORD, count)
|
||||||
|
| #"g" => NormalYank.yankToStart app
|
||||||
|
| _ => NormalFinish.clearMode app
|
||||||
|
|
||||||
fun parseYank (strPos, str, count, app, chrCmd, time) =
|
fun parseYank (strPos, str, count, app, chrCmd, time) =
|
||||||
if strPos = String.size str - 1 then
|
if strPos = String.size str - 1 then
|
||||||
parseYankTerminal (str, count, app, chrCmd, time)
|
parseYankTerminal (str, count, app, chrCmd, time)
|
||||||
@@ -285,11 +294,11 @@ struct
|
|||||||
| #"T" => NormalYank.yankToChr (app, 1, Cursor.tillPrevChr, op-, chrCmd)
|
| #"T" => NormalYank.yankToChr (app, 1, Cursor.tillPrevChr, op-, chrCmd)
|
||||||
| #"f" => NormalYank.yankToChr (app, count, Cursor.toNextChr, op+, chrCmd)
|
| #"f" => NormalYank.yankToChr (app, count, Cursor.toNextChr, op+, chrCmd)
|
||||||
| #"F" => NormalYank.yankToChr (app, count, Cursor.toPrevChr, op-, chrCmd)
|
| #"F" => NormalYank.yankToChr (app, count, Cursor.toPrevChr, op-, chrCmd)
|
||||||
(* todo: implement
|
| #"g" => parseYankGo (count, app, chrCmd)
|
||||||
| #"g" =>
|
(*
|
||||||
| #"i" =>
|
| #"i" =>
|
||||||
| #"a" =>
|
| #"a" =>
|
||||||
| #"d" =>
|
| #"d" =>
|
||||||
*)
|
*)
|
||||||
| _ => NormalFinish.clearMode app
|
| _ => NormalFinish.clearMode app
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,22 @@ struct
|
|||||||
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
|
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun yankWhenMovingBackPlusOne (app: app_type, fMove, count) =
|
||||||
|
let
|
||||||
|
val {buffer, cursorIdx, ...} = app
|
||||||
|
|
||||||
|
val buffer = LineGap.goToIdx (cursorIdx, buffer)
|
||||||
|
val low = fMove (buffer, cursorIdx, count)
|
||||||
|
|
||||||
|
val length = (cursorIdx + 1) - 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 yankWhenMovingForward (app: app_type, fMove, count) =
|
fun yankWhenMovingForward (app: app_type, fMove, count) =
|
||||||
let
|
let
|
||||||
val {buffer, cursorIdx, ...} = app
|
val {buffer, cursorIdx, ...} = app
|
||||||
@@ -226,4 +242,18 @@ struct
|
|||||||
, fInc
|
, fInc
|
||||||
, chr
|
, chr
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun yankToStart (app: app_type) =
|
||||||
|
let
|
||||||
|
val {cursorIdx, buffer, ...} = app
|
||||||
|
|
||||||
|
val high = Cursor.viDlrForDelete (buffer, cursorIdx, 1)
|
||||||
|
val buffer = LineGap.goToIdx (high, buffer)
|
||||||
|
|
||||||
|
val str = LineGap.substring (0, high, buffer)
|
||||||
|
val msg = YANK str
|
||||||
|
val mode = NORMAL_MODE ""
|
||||||
|
in
|
||||||
|
NormalModeWith.modeAndBuffer (app, buffer, mode, [DRAW msg])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user