summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Main.hs18
-rw-r--r--src/Scanner.hs2
2 files changed, 8 insertions, 12 deletions
diff --git a/src/Main.hs b/src/Main.hs
index f170492..6cac6fc 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -81,7 +81,7 @@ uiThread cf putState getState = forever $ do
--t1 <- getCurrentTime
--putStrLn $ "====> \ESC[32;1m" ++ show s ++ "\ESC[m in " ++
-- (show $ diffUTCTime t1 t0)
- -- ++ ": \"\ESC[35m" ++ (concat $ map (colorize . toChar) s)
+ -- ++ ": \"\ESC[35m" ++ (s >>= colorize . toChar)
-- ++ "\ESC[m\""
--case res of
-- Left msg -> putStrLn $ " error: " ++ msg
@@ -158,14 +158,13 @@ prettyError e = rec e
color cc s = "\x1b[" ++ cc ++ "m" ++ s ++ "\x1b[m"
rec (UnhandledInputError s) =
- color "31" $ "unhandled input: <" ++ (pp "31;1" s) ++ "\x1b[;31m>"
+ color "31" $ "unhandled input: <" ++ (s >>= pp "31;1") ++ "\x1b[;31m>"
rec (OtherError s) =
color "31" $ "error: " ++ s
-- TODO cc is ColorCode
- pp cc = concat . map (pp1 cc)
- pp1 cc c
+ pp cc c
| isPrint c = [c]
| otherwise = specialChar cc $
case c of
@@ -242,7 +241,7 @@ execCommand ExecuteInputBuffer = do
tell [ show s ]
'!' : cmdline -> do
--tell [ "spawn: " ++ cmdline ]
- -- "input: <" ++ (concat $ map (reform 32) $ showBuffer b) ++ ">" ]
+ -- "input: <" ++ (showBuffer b >>= reform 32) ++ ">" ]
-- TODO register process
i <- state $ \ q ->
let i = processCount q + 1
@@ -253,7 +252,7 @@ execCommand ExecuteInputBuffer = do
"" -> do
liftIO ringBell
s -> do
- tell [ "input: <" ++ (concat $ map (reform 32) s) ++ ">" ]
+ tell [ "input: <" ++ (s >>= reform 32) ++ ">" ]
modifyBuffer (const emptyBuffer)
@@ -333,11 +332,9 @@ renderInputLine m (lhs, rhs) = do
InsertMode -> "> "
VerbatimMode -> "\x1b[34;1m^\x1b[m "
- putStr $ promptString ++ pp lhs ++ pp rhs
- moveCursorLeft (length $ ppVis rhs)
+ putStr $ promptString ++ (lhs >>= reform') ++ (rhs >>= reform')
+ moveCursorLeft (length $ rhs >>= reformVis)
where
- pp = concat . map reform'
-
-- TODO unify reform and reform'
reform' c =
if isPrint c
@@ -349,7 +346,6 @@ renderInputLine m (lhs, rhs) = do
_ -> charToCode c
) ++ "\x1b[m"
- ppVis = concat . map reformVis
reformVis c =
if isPrint c
then [c]
diff --git a/src/Scanner.hs b/src/Scanner.hs
index ba81abb..780f9f8 100644
--- a/src/Scanner.hs
+++ b/src/Scanner.hs
@@ -76,7 +76,7 @@ main = do
putStrLn $ "====> \ESC[32;1m" ++ show s ++ "\ESC[m in " ++
(show $ diffUTCTime t1 t0)
- ++ ": \"\ESC[35m" ++ (concat $ map (colorize . toChar) s)
+ ++ ": \"\ESC[35m" ++ (s >>= colorize . toChar)
++ "\ESC[m\""
case res of
Left msg -> putStrLn $ " error: " ++ msg