deleted markup function in Gui.hs, since it's superseded by Fontifier.hs now

This commit is contained in:
Armin Friedl 2016-08-12 03:44:26 +02:00
parent c7a83b731c
commit d3361ad93c

View file

@ -175,43 +175,3 @@ drawContent = markup . (createMarkup []) . unlines
-- TODO is this needed/used somewhere? i don't see it -> delete? -- TODO is this needed/used somewhere? i don't see it -> delete?
appCursor :: HeditState -> [CursorLocation Names] -> Maybe (CursorLocation Names) appCursor :: HeditState -> [CursorLocation Names] -> Maybe (CursorLocation Names)
appCursor st c = Just (head c) appCursor st c = Just (head c)
-- TODO Refactor
-- 1) Forget the monad thing that used to stand here, no need to
-- introduce state
-- 2) Rough idea:
-- -> call Fontifier.fontify (public interface to whatever
-- the fontification functions do)
-- -> get list of attributes for text slices
-- -> apply attributes to text in editor gui
brackets :: [(Char,Char)]
brackets = [('(',')'),('[',']'),('{','}')]
mismatched :: (Char, Char) -> String -> Int -> Bool
mismatched _ _ 0 = False
mismatched _ [] _ = True
mismatched b@(ob, cb) (c:cs) d
-- TODO ignore comments and strings
| c == ob = mismatched b cs $ d+1
| c == cb = mismatched b cs $ d-1
| otherwise = mismatched b cs d
createMarkup :: String -> String -> Markup Vty.Attr
createMarkup _ [] = mempty
createMarkup p s@('%':ss) = case i of
Just n -> (pack (take (2+n) s) @@ fg Vty.green) <> (createMarkup (reverse (take (2+n) s) ++ p) (drop (1+n) ss))
Nothing -> pack s @@ fg Vty.green
where i = elemIndex '\n' ss
createMarkup p s@('"':ss) = case i of
Just n -> (pack (take (2+n) s) @@ fg Vty.blue) <> (createMarkup (reverse (take (2+n) s) ++ p) (drop (1+n) ss))
Nothing -> pack s @@ fg Vty.red
where i = elemIndex '"' ss
createMarkup p (c:ss)
| isJust ob && mismatched (fromJust ob) ss 1
|| isJust cb && mismatched (swap $ fromJust cb) p 1 = (singleton c @@ bg Vty.red) <> r
| otherwise = (singleton c @@ fg Vty.white) <> r
where ob = find ((== c).fst) brackets
cb = find ((== c).snd) brackets
r = createMarkup (c:p) ss