Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4183 Make PrettyPrint styles background-agnostic #4184

Merged
merged 1 commit into from
Jul 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/Stack/PrettyPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,57 +154,59 @@ debugBracket msg f = do
output $ "Finished in" <+> displayMilliseconds diff <> ":" <+> msg
return x

-- The following syles do not affect the colour of the background.

-- | Style an 'AnsiDoc' as an error. Should be used sparingly, not to style
-- entire long messages. For example, it's used to style the "Error:"
-- label for an error message, not the entire message.
styleError :: AnsiDoc -> AnsiDoc
styleError = dullred . ondullblack
styleError = dullred

-- | Style an 'AnsiDoc' as a warning. Should be used sparingly, not to style
-- entire long messages. For example, it's used to style the "Warning:"
-- label for an error message, not the entire message.
styleWarning :: AnsiDoc -> AnsiDoc
styleWarning = yellow . ondullblack
styleWarning = yellow

-- | Style an 'AnsiDoc' in a way to emphasize that it is a particularly good
-- thing.
styleGood :: AnsiDoc -> AnsiDoc
styleGood = green . ondullblack
styleGood = green

-- | Style an 'AnsiDoc' as a shell command, i.e. when suggesting something
-- to the user that should be typed in directly as written.
styleShell :: AnsiDoc -> AnsiDoc
styleShell = magenta . ondullblack
styleShell = magenta

-- | Style an 'AnsiDoc' as a filename. See 'styleDir' for directories.
styleFile :: AnsiDoc -> AnsiDoc
styleFile = bold . white . ondullblack
styleFile = bold . white

-- | Style an 'AsciDoc' as a URL. For now using the same style as files.
styleUrl :: AnsiDoc -> AnsiDoc
styleUrl = styleFile

-- | Style an 'AnsiDoc' as a directory name. See 'styleFile' for files.
styleDir :: AnsiDoc -> AnsiDoc
styleDir = bold . blue . ondullblack
styleDir = bold . blue

-- | Style used to highlight part of a recommended course of action.
styleRecommendation :: AnsiDoc -> AnsiDoc
styleRecommendation = bold . green . ondullblack
styleRecommendation = bold . green

-- | Style an 'AnsiDoc' in a way that emphasizes that it is related to
-- a current thing. For example, could be used when talking about the
-- current package we're processing when outputting the name of it.
styleCurrent :: AnsiDoc -> AnsiDoc
styleCurrent = yellow . ondullblack
styleCurrent = yellow

-- TODO: figure out how to describe this
styleTarget :: AnsiDoc -> AnsiDoc
styleTarget = cyan . ondullblack
styleTarget = cyan

-- | Style an 'AnsiDoc' as a module name
styleModule :: AnsiDoc -> AnsiDoc
styleModule = magenta . ondullblack -- TODO: what color should this be?
styleModule = magenta -- TODO: what color should this be?

instance Display PackageName where
display = fromString . packageNameString
Expand Down