@@ -1576,36 +1576,41 @@ instance Pretty PTerm OutputAnnotation where
15761576-- | Colourise annotations according to an Idris state. It ignores the names
15771577-- in the annotation, as there's no good way to show extended information on a
15781578-- terminal.
1579−consoleDecorate :: IState -> OutputAnnotation -> String -> String
1580−consoleDecorate ist _ | not (idris_colourRepl ist) = id
1581−consoleDecorate ist (AnnConst c) = let theme = idris_colourTheme ist
1582− in if constIsType c
1583− then colouriseType theme
1584− else colouriseData theme
1585−consoleDecorate ist (AnnData _ _) = colouriseData (idris_colourTheme ist)
1586−consoleDecorate ist (AnnType _ _) = colouriseType (idris_colourTheme ist)
1587−consoleDecorate ist (AnnBoundName _ True) = colouriseImplicit (idris_colourTheme ist)
1588−consoleDecorate ist (AnnBoundName _ False) = colouriseBound (idris_colourTheme ist)
1589−consoleDecorate ist AnnKeyword = colouriseKeyword (idris_colourTheme ist)
1590−consoleDecorate ist (AnnName n _ _ _) = let ctxt = tt_ctxt ist
1591− theme = idris_colourTheme ist
1592− in case () of
1593− _ | isDConName n ctxt -> colouriseData theme
1594− _ | isFnName n ctxt -> colouriseFun theme
1595− _ | isTConName n ctxt -> colouriseType theme
1596− _ | isPostulateName n ist -> colourisePostulate theme
1597− _ | otherwise -> id -- don't colourise unknown names
1598−consoleDecorate ist (AnnFC _) = id
1599−consoleDecorate ist (AnnTextFmt fmt) = Idris.Colours.colourise (colour fmt)
1579+annotationColour :: IState -> OutputAnnotation -> Maybe IdrisColour
1580+annotationColour ist _ | not (idris_colourRepl ist) = Nothing
1581+annotationColour ist (AnnConst c) =
1582+ let theme = idris_colourTheme ist
1583+ in Just $ if constIsType c
1584+ then typeColour theme
1585+ else dataColour theme
1586+annotationColour ist (AnnData _ _) = Just $ dataColour (idris_colourTheme ist)
1587+annotationColour ist (AnnType _ _) = Just $ typeColour (idris_colourTheme ist)
1588+annotationColour ist (AnnBoundName _ True) = Just $ implicitColour (idris_colourTheme ist)
1589+annotationColour ist (AnnBoundName _ False) = Just $ boundVarColour (idris_colourTheme ist)
1590+annotationColour ist AnnKeyword = Just $ keywordColour (idris_colourTheme ist)
1591+annotationColour ist (AnnName n _ _ _) =
1592+ let ctxt = tt_ctxt ist
1593+ theme = idris_colourTheme ist
1594+ in case () of
1595+ _ | isDConName n ctxt -> Just $ dataColour theme
1596+ _ | isFnName n ctxt -> Just $ functionColour theme
1597+ _ | isTConName n ctxt -> Just $ typeColour theme
1598+ _ | isPostulateName n ist -> Just $ postulateColour theme
1599+ _ | otherwise -> Nothing -- don't colourise unknown names
1600+annotationColour ist (AnnTextFmt fmt) = Just (colour fmt)
16001601 where colour BoldText = IdrisColour Nothing True False True False
16011602 colour UnderlineText = IdrisColour Nothing True True False False
16021603 colour ItalicText = IdrisColour Nothing True False False True
1603−consoleDecorate ist (AnnTerm _ _) = id
1604−consoleDecorate ist (AnnSearchResult _) = id
1605−consoleDecorate ist (AnnErr _) = id
1606−consoleDecorate ist (AnnNamespace _ _) = id
1607−consoleDecorate ist (AnnLink url) =
1608− \txt -> Idris.Colours.colourise (IdrisColour Nothing True True False False) txt ++ " (" ++ url ++ ")"
1604+annotationColour ist _ = Nothing
1605+
1606+
1607+-- | Colourise annotations according to an Idris state. It ignores the names
1608+-- in the annotation, as there's no good way to show extended
1609+-- information on a terminal. Note that strings produced this way will
1610+-- not be coloured on Windows, so the use of the colour rendering
1611+-- functions in Idris.Output is to be preferred.
1612+consoleDecorate :: IState -> OutputAnnotation -> String -> String
1613+consoleDecorate ist ann = maybe id colourise (annotationColour ist ann)
16091614
16101615isPostulateName :: Name -> IState -> Bool
16111616isPostulateName n ist = S.member n (idris_postulates ist)