summaryrefslogtreecommitdiffstats
path: root/Buffer
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-07-28 14:18:39 +0200
committertv <tv@shackspace.de>2014-07-28 14:18:39 +0200
commite3c8479127589b05719567f6821383ad0d9f5b27 (patch)
tree7cc95adc3953ad880a5e676057043d19b1835435 /Buffer
parent25b8aa03070758e7f72f37e325f3e6e4b22e685c (diff)
move source to src/
Diffstat (limited to 'Buffer')
-rw-r--r--Buffer/Class.hs13
-rw-r--r--Buffer/Motion.hs83
2 files changed, 0 insertions, 96 deletions
diff --git a/Buffer/Class.hs b/Buffer/Class.hs
deleted file mode 100644
index 75664a5..0000000
--- a/Buffer/Class.hs
+++ /dev/null
@@ -1,13 +0,0 @@
--- TODO Class is a lie
-module Buffer.Class where
-
-
-type Buffer = (String, String)
-
-emptyBuffer :: Buffer
-emptyBuffer = ("", "")
-
-
--- TODO instance Show Buffer (w/newtype Buffer) (?)
-showBuffer :: Buffer -> String
-showBuffer (lhs, rhs) = lhs ++ rhs
diff --git a/Buffer/Motion.hs b/Buffer/Motion.hs
deleted file mode 100644
index fa9e059..0000000
--- a/Buffer/Motion.hs
+++ /dev/null
@@ -1,83 +0,0 @@
-module Buffer.Motion where
-
-import Data.List (dropWhileEnd)
-import Buffer.Class
-
---data Motion = Motion Int LeftRightMotion
-
-
--- TODO factor Count
--- TODO various Vim gX
-data LeftRightMotion
- = GotoLeft Int
- | GotoRight Int
- | GotoFirstChar
- -- | GotoFirstNonBlankChar
- | GotoEndOfLine -- XXX in Vi this can go downwards
- | GotoColumn Int
- -- | GotoFindLeft Int (Char -> Bool) -- TODO don't use functions here
- -- | GotoFindRight Int (Char -> Bool) -- TODO ^ dto.
- -- | GotillFindLeft Int Char
- -- | GotillFindRight Int Char
- -- | RepeatLastFind Int
- -- | RepeatLastFindReverse Int
- | WordsForward Int
- | WordsBackward Int
- deriving (Show)
-
-
--- TODO fail if cannot splitAt properly OR if we didn't modify the buffer
-gotoLeft :: Int -> Buffer -> Buffer
-gotoLeft i (ls, rs) =
- let (lls, rls) = splitAt (length ls - i) ls in (lls, rls ++ rs)
-
-
--- TODO fail if cannot splitAt properly OR if we didn't modify the buffer
-gotoRight :: Int -> Buffer -> Buffer
-gotoRight i (ls, rs) =
- let (lrs, rrs) = splitAt i rs in (ls ++ lrs, rrs)
-
-
-gotoFirstChar :: Buffer -> Buffer
-gotoFirstChar (ls, rs) = ("", ls ++ rs)
-
-
-gotoEndOfLine :: Buffer -> Buffer
-gotoEndOfLine (ls, rs) = (ls ++ rs, "")
-
-
--- TODO fail if i <= 0 or i > length
-gotoColumn :: Int -> Buffer -> Buffer
-gotoColumn i (ls, rs) = splitAt (i - 1) $ ls ++ rs
-
-
-wordsForward :: Int -> Buffer -> Buffer
-wordsForward i (ls, rs) =
- let rs' = dropWhile (==' ') $ dropWhile (/=' ') rs
- ls' = ls ++ take (length rs - length rs') rs
- b' = (ls', rs')
- in
- if i > 1
- then wordsForward (i - 1) b'
- else b'
-
-
-wordsBackward :: Int -> Buffer -> Buffer
-wordsBackward i (ls, rs) =
- let ls' = dropWhileEnd (/=' ') $ dropWhileEnd (==' ') ls
- rs' = drop (length ls') ls ++ rs
- b' = (ls', rs')
- in
- if i > 1
- then wordsBackward (i - 1) b'
- else b'
-
-
-move :: LeftRightMotion -> Buffer -> Buffer
-move (GotoLeft i) = gotoLeft i
-move (GotoRight i) = gotoRight i
-move GotoFirstChar = gotoFirstChar
-move GotoEndOfLine = gotoEndOfLine
-move (GotoColumn i) = gotoColumn i
-move (WordsForward i) = wordsForward i
-move (WordsBackward i) = wordsBackward i