From 8a265c2e3ed2badc1354fd639641438275dfe144 Mon Sep 17 00:00:00 2001 From: ardislu Date: Tue, 3 Jan 2023 06:20:19 -0800 Subject: [PATCH] Use classes instead of inline styles (#878) --- lib/Echidna/Output/Source.hs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/Echidna/Output/Source.hs b/lib/Echidna/Output/Source.hs index 1fbc37b7b..a22fd5f1f 100644 --- a/lib/Echidna/Output/Source.hs +++ b/lib/Echidna/Output/Source.hs @@ -51,7 +51,12 @@ ppCoveredCode isHtml sc cs s | s == mempty = "Coverage map is empty" in T.unlines (changeFileName srcPath : changeFileLines (V.toList marked)) -- ^ Pretty print individual file coverage topHeader - | isHtml = "" + | isHtml = "" | otherwise = "" -- ^ Text to add to top of the file changeFileName fn @@ -75,28 +80,22 @@ markLines isHtml codeLines runtimeLines resultMap = markers = sort $ nub $ getMarker <$> results wrapLine :: Text -> Text wrapLine line - | isHtml = "" <> + | isHtml = "" <> HTML.text line <> "" | otherwise = line where - color = if n `elem` runtimeLines then getColor markers else grey - grey = "eee" + cssClass = if n `elem` runtimeLines then getCSSClass markers else "neutral" in pack $ printf " %*d | %-4s| %s" lineNrSpan n markers (wrapLine codeLine) lineNrSpan = length . show $ V.length codeLines + 1 -getColor :: String -> Text -getColor markers = +getCSSClass :: String -> Text +getCSSClass markers = case markers of - [] -> red - _ | '*' `elem` markers -> green - _ -> yellow - - where - green = "afa" - yellow = "ffa" - red = "faa" + [] -> "unexecuted" + _ | '*' `elem` markers -> "executed" + _ -> "reverted" -- | Select the proper marker, according to the result of the transaction getMarker :: TxResult -> Char