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 -}
|
||||
|
||||
assignments = slicesToFT §: "assignment" §. matchStripCmts §~ "\\**.+=.+;"
|
||||
guards = slicesToFT §: "guard" §. matchStripCmts §~ "\\[.+:.+\\]"
|
||||
returns = slicesToFT §: "return" §. matchStripCmts §~ "\\^.+;"
|
||||
strings = slicesToFT §: "string" §. matchStripCmts §~ "\"[^%]*\""
|
||||
comments = slicesToFT §: "comment" §. matchAll §~ "%.*"
|
||||
|
||||
comments = slicesToFT §: "comment" §. matchAll §~ "%.*"
|
||||
assignments = slicesToFT §: "assignment" §. matchStripCmts §~ "\\**.+=.+;"
|
||||
returns = slicesToFT §: "return" §. matchStripCmts §~ "\\^.+;"
|
||||
strings = slicesToFT §: "string" §. matchStripCmts §~ "\"[^%]*\""
|
||||
guards = slicesToFT §: "guard" §. matchGrpStripCmts 1 §~ "\\[(.+):.+\\]"
|
||||
|
||||
{- Custom/Function-Based -}
|
||||
|
||||
|
@ -104,10 +103,16 @@ mismatchedBrackets s = concatMap (mismatched §: "err_brackets" $ s) [('('
|
|||
{- Regex Utilities -}
|
||||
|
||||
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 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
|
||||
stripComments [] = []
|
||||
stripComments (slice:slices) = if penetratesFT slice commentsFts
|
||||
|
@ -115,12 +120,14 @@ matchStripCmts r s = stripComments $ matchAll r s
|
|||
else slice: stripComments slices
|
||||
|
||||
matchesToSlices :: MatchResult -> Slices
|
||||
matchesToSlices [] = []
|
||||
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
|
||||
matchesToSlices = matchesGrpToSlices 0
|
||||
|
||||
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 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
|
||||
|
||||
|
||||
|
||||
|
||||
{- General Fontification Utilities -}
|
||||
|
||||
prune :: Fontifications -> Slices -> Slices
|
||||
|
|
|
@ -164,18 +164,3 @@ fontifyToMarkup' markup [] = markup
|
|||
fontifyToMarkup' markup (f:ff) = fontifyToMarkup' (markupSet slice attribute markup) ff
|
||||
where slice = ((ftStart f),(ftEnd f)-(ftStart f)) -- slice = (startIndex, length)
|
||||
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