summaryrefslogtreecommitdiffstats
path: root/src/Buffer/Motion.hs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-08-07 01:34:00 +0200
committertv <tv@krebsco.de>2017-08-07 01:34:00 +0200
commit9c2d648916f1a62fc429527bae610f71967843ea (patch)
treee734e5fa1229bcb23fdbd904fe83999725fb7446 /src/Buffer/Motion.hs
parent5e9ee547af994a88da8bbaa638c3e94f16795aac (diff)
Main: add Yank
Diffstat (limited to 'src/Buffer/Motion.hs')
-rw-r--r--src/Buffer/Motion.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Buffer/Motion.hs b/src/Buffer/Motion.hs
index 8e59789..b07a45c 100644
--- a/src/Buffer/Motion.hs
+++ b/src/Buffer/Motion.hs
@@ -78,3 +78,31 @@ move ToEndOfLine _ = gotoEndOfLine -- TODO use count
move ToColumn c = gotoColumn c
move WordsForward c = wordsForward c
move WordsBackward c = wordsBackward c
+
+
+select :: Motion -> Int -> Buffer -> String
+select x i b =
+ if nls' < nls then take (nls - nls') rs' else
+ if nrs' < nrs then take (nrs - nrs') rs else
+ ""
+ where
+ (ls, rs) = b
+ (ls', rs') = move x i b
+ nls = length ls
+ nls' = length ls'
+ nrs = length rs
+ nrs' = length rs'
+
+
+delete :: Motion -> Int -> Buffer -> Buffer
+delete x i b =
+ ( if nls' < nls then ls' else ls
+ , if nrs' < nrs then rs' else rs
+ )
+ where
+ (ls, rs) = b
+ (ls', rs')= move x i b
+ nls = length ls
+ nls' = length ls'
+ nrs = length rs
+ nrs' = length rs'