@@ -5,6 +5,7 @@ module System.Console.Haskeline.LineState(
55 -- * Graphemes
66 Grapheme (),
77 baseChar ,
8+ baseGrapheme , -- XXX The author says no!
89 stringToGraphemes ,
910 graphemesToString ,
1011 modifyBaseChar ,
@@ -74,7 +75,7 @@ import Data.Char
7475-- can represent one grapheme; for example, an @a@ followed by the diacritic @\'\\768\'@ should
7576-- be treated as one unit.
7677data Grapheme = Grapheme { gBaseChar :: Char ,
77- combiningChars :: [Char ]}
78+ combiningChars :: [Char ]}
7879 deriving Eq
7980
8081instance Show Grapheme where
@@ -163,7 +164,7 @@ listRestore xs = restore $ IMode (reverse xs) []
163164
164165class Move s where
165166 goLeft , goRight , moveToStart , moveToEnd :: s -> s
166-
167+
167168-- | The standard line state representation; considers the cursor to be located
168169-- between two characters. The first list is reversed.
169170data InsertMode = IMode [Grapheme ] [Grapheme ]
@@ -181,7 +182,7 @@ instance Save InsertMode where
181182 restore = id
182183
183184instance Move InsertMode where
184- goLeft im@ (IMode [] _) = im
185+ goLeft im@ (IMode [] _) = im
185186 goLeft (IMode (x: xs) ys) = IMode xs (x: ys)
186187
187188 goRight im@ (IMode _ [] ) = im
@@ -194,7 +195,7 @@ emptyIM :: InsertMode
194195emptyIM = IMode [] []
195196
196197-- | Insert one character, which may be combining, to the left of the cursor.
197- --
198+ --
198199insertChar :: Char -> InsertMode -> InsertMode
199200insertChar c im@ (IMode xs ys)
200201 | isCombiningChar c = case xs of
@@ -203,7 +204,7 @@ insertChar c im@(IMode xs ys)
203204 z: zs -> IMode (addCombiner z c : zs) ys
204205 | otherwise = IMode (baseGrapheme c : xs) ys
205206
206- -- | Insert a sequence of characters to the left of the cursor.
207+ -- | Insert a sequence of characters to the left of the cursor.
207208insertString :: String -> InsertMode -> InsertMode
208209insertString s (IMode xs ys) = IMode (reverse (stringToGraphemes s) ++ xs) ys
209210
@@ -212,12 +213,12 @@ deleteNext im@(IMode _ []) = im
212213deleteNext (IMode xs (_: ys)) = IMode xs ys
213214
214215deletePrev im@ (IMode [] _) = im
215- deletePrev (IMode (_: xs) ys) = IMode xs ys
216+ deletePrev (IMode (_: xs) ys) = IMode xs ys
216217
217218skipLeft , skipRight :: (Char -> Bool ) -> InsertMode -> InsertMode
218- skipLeft f (IMode xs ys) = let (ws,zs) = span (f . baseChar) xs
219+ skipLeft f (IMode xs ys) = let (ws,zs) = span (f . baseChar) xs
219220 in IMode zs (reverse ws ++ ys)
220- skipRight f (IMode xs ys) = let (ws,zs) = span (f . baseChar) ys
221+ skipRight f (IMode xs ys) = let (ws,zs) = span (f . baseChar) ys
221222 in IMode (reverse ws ++ xs) zs
222223
223224transposeChars :: InsertMode -> InsertMode
@@ -326,7 +327,7 @@ instance Functor ArgMode where
326327
327328instance LineState s => LineState (ArgMode s ) where
328329 beforeCursor _ am = let pre = map baseGrapheme $ " (arg: " ++ show (arg am) ++ " ) "
329- in beforeCursor pre (argState am)
330+ in beforeCursor pre (argState am)
330331 afterCursor = afterCursor . argState
331332
332333instance Result s => Result (ArgMode s ) where
@@ -342,15 +343,15 @@ startArg = ArgMode
342343addNum :: Int -> ArgMode s -> ArgMode s
343344addNum n am
344345 | arg am >= 1000 = am -- shouldn't ever need more than 4 digits
345- | otherwise = am {arg = arg am * 10 + n}
346+ | otherwise = am {arg = arg am * 10 + n}
346347
347- -- todo : negatives
348+ -- TODO : negatives
348349applyArg :: (s -> s ) -> ArgMode s -> s
349350applyArg f am = repeatN (arg am) f (argState am)
350351
351352repeatN :: Int -> (a -> a ) -> a -> a
352353repeatN n f | n <= 1 = f
353- | otherwise = f . repeatN (n- 1 ) f
354+ | otherwise = f . repeatN (n- 1 ) f
354355
355356applyCmdArg :: (InsertMode -> InsertMode ) -> ArgMode CommandMode -> CommandMode
356357applyCmdArg f am = withCommandMode (repeatN (arg am) f) (argState am)
@@ -406,10 +407,9 @@ afterChar _ _ = False
406407goRightUntil , goLeftUntil :: (InsertMode -> Bool ) -> InsertMode -> InsertMode
407408goRightUntil f = loop . goRight
408409 where
409- loop im@ (IMode _ ys) | null ys || f im = im
410+ loop im@ (IMode _ ys) | null ys || f im = im
410411 | otherwise = loop (goRight im)
411412goLeftUntil f = loop . goLeft
412413 where
413- loop im@ (IMode xs _) | null xs || f im = im
414- | otherwise = loop (goLeft im)
415-
414+ loop im@ (IMode xs _) | null xs || f im = im
415+ | otherwise = loop (goLeft im)
0 commit comments