guard coloring fixed
This commit is contained in:
parent
77081e3437
commit
b8c0315697
2 changed files with 19 additions and 29 deletions
|
@ -84,12 +84,11 @@ concatApply (f:fs) s = f s ++ concatApply fs s
|
||||||
|
|
||||||
{- Regex-Based -}
|
{- Regex-Based -}
|
||||||
|
|
||||||
|
comments = slicesToFT §: "comment" §. matchAll §~ "%.*"
|
||||||
assignments = slicesToFT §: "assignment" §. matchStripCmts §~ "\\**.+=.+;"
|
assignments = slicesToFT §: "assignment" §. matchStripCmts §~ "\\**.+=.+;"
|
||||||
guards = slicesToFT §: "guard" §. matchStripCmts §~ "\\[.+:.+\\]"
|
|
||||||
returns = slicesToFT §: "return" §. matchStripCmts §~ "\\^.+;"
|
returns = slicesToFT §: "return" §. matchStripCmts §~ "\\^.+;"
|
||||||
strings = slicesToFT §: "string" §. matchStripCmts §~ "\"[^%]*\""
|
strings = slicesToFT §: "string" §. matchStripCmts §~ "\"[^%]*\""
|
||||||
comments = slicesToFT §: "comment" §. matchAll §~ "%.*"
|
guards = slicesToFT §: "guard" §. matchGrpStripCmts 1 §~ "\\[(.+):.+\\]"
|
||||||
|
|
||||||
|
|
||||||
{- Custom/Function-Based -}
|
{- Custom/Function-Based -}
|
||||||
|
|
||||||
|
@ -104,10 +103,16 @@ mismatchedBrackets s = concatMap (mismatched §: "err_brackets" $ s) [('('
|
||||||
{- Regex Utilities -}
|
{- Regex Utilities -}
|
||||||
|
|
||||||
matchAll :: Regex -> CheckString -> Slices
|
matchAll :: Regex -> CheckString -> Slices
|
||||||
matchAll r s = matchesToSlices $ Tdfa.matchAll r s
|
matchAll = matchGrpAll 0
|
||||||
|
|
||||||
|
matchGrpAll :: Int -> Regex -> CheckString -> Slices
|
||||||
|
matchGrpAll g r s = matchesGrpToSlices g $ Tdfa.matchAll r s
|
||||||
|
|
||||||
matchStripCmts :: Regex -> CheckString -> Slices
|
matchStripCmts :: Regex -> CheckString -> Slices
|
||||||
matchStripCmts r s = stripComments $ matchAll r s
|
matchStripCmts = matchGrpStripCmts 0
|
||||||
|
|
||||||
|
matchGrpStripCmts :: Int -> Regex -> CheckString -> Slices
|
||||||
|
matchGrpStripCmts g r s = stripComments $ matchesGrpToSlices g $ Tdfa.matchAll r s
|
||||||
where commentsFts = comments s
|
where commentsFts = comments s
|
||||||
stripComments [] = []
|
stripComments [] = []
|
||||||
stripComments (slice:slices) = if penetratesFT slice commentsFts
|
stripComments (slice:slices) = if penetratesFT slice commentsFts
|
||||||
|
@ -115,12 +120,14 @@ matchStripCmts r s = stripComments $ matchAll r s
|
||||||
else slice: stripComments slices
|
else slice: stripComments slices
|
||||||
|
|
||||||
matchesToSlices :: MatchResult -> Slices
|
matchesToSlices :: MatchResult -> Slices
|
||||||
matchesToSlices [] = []
|
matchesToSlices = matchesGrpToSlices 0
|
||||||
matchesToSlices (m:ms) = let match = m ! 0 -- get 1st elem of match array (this is the whole match, which we want)
|
|
||||||
in (fst match, (fst match) + (snd match)): matchesToSlices ms
|
|
||||||
|
|
||||||
|
matchesGrpToSlices :: Int -> MatchResult -> Slices
|
||||||
|
matchesGrpToSlices _ [] = []
|
||||||
|
matchesGrpToSlices group (m:ms) = let match = m ! group -- extract the match group (0 = the whole match)
|
||||||
|
in (fst match, (fst match) + (snd match)): matchesGrpToSlices group ms
|
||||||
|
|
||||||
{- Custom Fontifier Utilities -}
|
{- Utilities for Custom Fontifiers -}
|
||||||
|
|
||||||
mismatched :: AttrName -> CheckString -> (Char, Char) -> Fontifications
|
mismatched :: AttrName -> CheckString -> (Char, Char) -> Fontifications
|
||||||
mismatched attrName s (open, close) = slicesToFT attrName $ (fst orphans)++(snd orphans) -- (fst orphans) = open without close,
|
mismatched attrName s (open, close) = slicesToFT attrName $ (fst orphans)++(snd orphans) -- (fst orphans) = open without close,
|
||||||
|
@ -156,8 +163,6 @@ mismatchedQuotes s = slicesToFT §: "err_quotes" $ firstChar untermed
|
||||||
| otherwise = negPrune checkFts slices
|
| otherwise = negPrune checkFts slices
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{- General Fontification Utilities -}
|
{- General Fontification Utilities -}
|
||||||
|
|
||||||
prune :: Fontifications -> Slices -> Slices
|
prune :: Fontifications -> Slices -> Slices
|
||||||
|
|
|
@ -164,18 +164,3 @@ fontifyToMarkup' markup [] = markup
|
||||||
fontifyToMarkup' markup (f:ff) = fontifyToMarkup' (markupSet slice attribute markup) ff
|
fontifyToMarkup' markup (f:ff) = fontifyToMarkup' (markupSet slice attribute markup) ff
|
||||||
where slice = ((ftStart f),(ftEnd f)-(ftStart f)) -- slice = (startIndex, length)
|
where slice = ((ftStart f),(ftEnd f)-(ftStart f)) -- slice = (startIndex, length)
|
||||||
attribute = ftAttr f
|
attribute = ftAttr f
|
||||||
|
|
||||||
|
|
||||||
-- TODO had to name this function drawHeditText to test
|
|
||||||
-- out the fontifier w/o deleting the old thing,
|
|
||||||
-- think it won't be needed -> delete?
|
|
||||||
{-
|
|
||||||
drawContent :: [String] -> Widget n
|
|
||||||
drawContent = markup . (createMarkup []) . unlines
|
|
||||||
-}
|
|
||||||
|
|
||||||
-- TODO is this needed/used somewhere? i don't see it -> delete?
|
|
||||||
{-
|
|
||||||
appCursor :: HeditState -> [CursorLocation Names] -> Maybe (CursorLocation Names)
|
|
||||||
appCursor st c = Just (head c)
|
|
||||||
-}
|
|
||||||
|
|
Loading…
Reference in a new issue