Skip to content

Commit

Permalink
Revert "[#26] Ability to disable and enable colouring (#38)"
Browse files Browse the repository at this point in the history
This reverts commit d2bcd11.
  • Loading branch information
chshersh committed Apr 5, 2021
1 parent 01a108d commit 8cfbaa3
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 310 deletions.
13 changes: 0 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
`colourista` uses [PVP Versioning][1].
The changelog is available [on GitHub][2].

## 0.2.0.0

* [#26](https://github.com/kowainik/colourista/issues/26):
Support enabling and disable of colouring with implicit parameters.

__Migration guide:__ You can continue using `colourista` without
changing anything and you still get colourful formatting.

However, if you want to enable or disable colouring, you need to add
the `HasColourMode =>` constraint to all functions that format data
or call such formatting functions, and set the value of the
`?colourMode` variable in the beginning of your application.

## 0.1.0.0 — May 2, 2020 🌈

* [#22](https://github.com/kowainik/colourista/issues/22):
Expand Down
24 changes: 6 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@
>
> — Coco Chanel
`colourista` is the library that provides a simple and convenient
interface for printing colourful messages to the
terminal. Additionally, `colourista` allows to easily control enabling
and disabling of colours.

The library is based on
[`ansi-terminal`](https://hackage.haskell.org/package/ansi-terminal),
however, in contradistinction to this Haskell library, `colourista` is
a high-level wrapper focused on easily achieved output modification
without low-level setup.
`colourista` is the library that provides a convenient interface for printing
colourful messages to the terminal. It is based on
[`ansi-terminal`](https://hackage.haskell.org/package/ansi-terminal), however,
in contradistinction to this Haskell library, `colourista` is a high-level
wrapper focused on easily achieved output modification without low-level setup.

## Interface

Expand All @@ -35,17 +30,10 @@ The two main functions that `colourista` provides are:
The library also provides a set of different pure and impure helpers for the
colouring and emphasis.

## Examples

Simple output example:
## Example

![output](https://user-images.githubusercontent.com/8126674/74609327-0a5dbb00-50e1-11ea-8c4b-2db4ab5b42a2.png)

Example of disabling colouring. The colour mode controlling is based on the
[Implicit Parameters](https://downloads.haskell.org/ghc/latest/docs/html/users_guide/glasgow_exts.html#implicit-parameters) GHC feature.

![Colour mode](https://user-images.githubusercontent.com/4276606/90915207-0c2d7180-e3d7-11ea-934c-ec840118ed73.png)

## How to use

`colourista` is compatible with the latest GHC compiler versions starting from `8.2.2`.
Expand Down
17 changes: 3 additions & 14 deletions colourista.cabal
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
cabal-version: 2.4
name: colourista
version: 0.2.0.0
synopsis: Simple and convenient interface for colourful outputting
description:
Convenient interface for printing colourful messages based on the @ansi-terminal@ library.
Supports enabling and disabling of colouring based on
the [Implicit Parameters](https://downloads.haskell.org/ghc/latest/docs/html/users_guide/glasgow_exts.html#implicit-parameters)
GHC feature.
.
Usage and output example:
.
* ![Example](https://user-images.githubusercontent.com/4276606/90915207-0c2d7180-e3d7-11ea-934c-ec840118ed73.png)

version: 0.1.0.0
synopsis: Convenient interface for printing colourful messages
description: Convenient interface for printing colourful messages based on the @ansi-terminal@ library.
homepage: https://github.com/kowainik/colourista
bug-reports: https://github.com/kowainik/colourista/issues
license: MPL-2.0
Expand All @@ -37,14 +28,12 @@ library
hs-source-dirs: src
exposed-modules: Colourista
Colourista.IO
Colourista.Mode
Colourista.Pure
Colourista.Short

build-depends: base >= 4.10.1.0 && < 4.15
, ansi-terminal >= 0.10 && < 0.12
, bytestring ^>= 0.10
, ghc-prim >= 0.5 && < 0.7
, text ^>= 1.2.3.0

ghc-options: -Wall
Expand Down
8 changes: 0 additions & 8 deletions src/Colourista.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ module Colourista
-- $pure
, module Colourista.IO
-- $io
, module Colourista.Mode
-- $mode
) where

import Colourista.IO
import Colourista.Mode
import Colourista.Pure


Expand All @@ -32,8 +29,3 @@ customisation: colouring and emphasis.
The set of functions that work in 'IO' to output formatted messages
directly to terminal.
-}

{- $mode
'ColourMode' data type that allows disabling and enabling colouring
based on the implicit @?colourMode@ parameter in scope.
-}
34 changes: 16 additions & 18 deletions src/Colourista/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import Data.Semigroup (Semigroup (..))
#endif
import Data.Text (Text)

import Colourista.Mode (HasColourMode)

import qualified Data.Text.IO as TIO

import qualified Colourista.Pure as Colourista
Expand All @@ -48,42 +46,42 @@ import qualified Colourista.Pure as Colourista
----------------------------------------------------------------------------

-- | Print 'Text' coloured in 'Colourista.red'.
redMessage :: HasColourMode => Text -> IO ()
redMessage :: Text -> IO ()
redMessage = formattedMessage [Colourista.red]
{-# INLINE redMessage #-}

-- | Print 'Text' coloured in 'Colourista.green'.
greenMessage :: HasColourMode => Text -> IO ()
greenMessage :: Text -> IO ()
greenMessage = formattedMessage [Colourista.green]
{-# INLINE greenMessage #-}

-- | Print 'Text' coloured in 'Colourista.blue'.
blueMessage :: HasColourMode => Text -> IO ()
blueMessage :: Text -> IO ()
blueMessage = formattedMessage [Colourista.blue]
{-# INLINE blueMessage #-}

-- | Print 'Text' coloured in 'Colourista.yellow'.
yellowMessage :: HasColourMode => Text -> IO ()
yellowMessage :: Text -> IO ()
yellowMessage = formattedMessage [Colourista.yellow]
{-# INLINE yellowMessage #-}

-- | Print 'Text' coloured in 'Colourista.black'.
blackMessage :: HasColourMode => Text -> IO ()
blackMessage :: Text -> IO ()
blackMessage = formattedMessage [Colourista.black]
{-# INLINE blackMessage #-}

-- | Print 'Text' coloured in 'Colourista.white'.
whiteMessage :: HasColourMode => Text -> IO ()
whiteMessage :: Text -> IO ()
whiteMessage = formattedMessage [Colourista.white]
{-# INLINE whiteMessage #-}

-- | Print 'Text' coloured in 'Colourista.magenta'.
magentaMessage :: HasColourMode => Text -> IO ()
magentaMessage :: Text -> IO ()
magentaMessage = formattedMessage [Colourista.magenta]
{-# INLINE magentaMessage #-}

-- | Print 'Text' coloured in 'Colourista.cyan'.
cyanMessage :: HasColourMode => Text -> IO ()
cyanMessage :: Text -> IO ()
cyanMessage = formattedMessage [Colourista.cyan]
{-# INLINE cyanMessage #-}

Expand All @@ -95,39 +93,39 @@ cyanMessage = formattedMessage [Colourista.cyan]
<<https://user-images.githubusercontent.com/4276606/80867598-dbd99000-8c8c-11ea-9fac-81a1a606d8d8.png Success message>>
-}
successMessage :: HasColourMode => Text -> IO ()
successMessage :: Text -> IO ()
successMessage t = greenMessage $ "" <> t
{-# INLINE successMessage #-}

{- | Similar to 'blueMessage', but add unicode indicator.
<<https://user-images.githubusercontent.com/4276606/80867597-db40f980-8c8c-11ea-9775-e8a3c4a7aaa2.png Information message>>
-}
infoMessage :: HasColourMode => Text -> IO ()
infoMessage :: Text -> IO ()
infoMessage t = blueMessage $ "" <> t
{-# INLINE infoMessage #-}

{- | Similar to 'cyanMessage', but add unicode indicator.
<<https://user-images.githubusercontent.com/4276606/80867596-db40f980-8c8c-11ea-8131-9c7cba32a4fd.png Skip message>>
-}
skipMessage :: HasColourMode => Text -> IO ()
skipMessage :: Text -> IO ()
skipMessage t = cyanMessage $ "" <> t
{-# INLINE skipMessage #-}

{- | Similar to 'yellowMessage', but add unicode indicator.
<<https://user-images.githubusercontent.com/4276606/80867594-daa86300-8c8c-11ea-9c6a-a42b634a1e4b.png Warning message>>
-}
warningMessage :: HasColourMode => Text -> IO ()
warningMessage :: Text -> IO ()
warningMessage t = yellowMessage $ "" <> t
{-# INLINE warningMessage #-}

{- | Similar to 'redMessage', but add unicode indicator.
<<https://user-images.githubusercontent.com/4276606/80867592-da0fcc80-8c8c-11ea-90e0-42aae8770c18.png Error message>>
-}
errorMessage :: HasColourMode => Text -> IO ()
errorMessage :: Text -> IO ()
errorMessage t = redMessage $ " \128721 " <> t
{-# INLINE errorMessage #-}

Expand All @@ -136,12 +134,12 @@ errorMessage t = redMessage $ " \128721 " <> t
----------------------------------------------------------------------------

-- | Print 'Text' emphasized with 'Colourista.bold'.
boldMessage :: HasColourMode => Text -> IO ()
boldMessage :: Text -> IO ()
boldMessage = formattedMessage [Colourista.bold]
{-# INLINE boldMessage #-}

-- | Print 'Text' emphasized with 'Colourista.italic'.
italicMessage :: HasColourMode => Text -> IO ()
italicMessage :: Text -> IO ()
italicMessage = formattedMessage [Colourista.italic]
{-# INLINE italicMessage #-}

Expand All @@ -155,6 +153,6 @@ list, no formatting is applied.
![formattedMessage-example](https://user-images.githubusercontent.com/4276606/74608898-e6987600-50dc-11ea-9a93-bda701fd3c43.png)
-}
formattedMessage :: HasColourMode => [Text] -> Text -> IO ()
formattedMessage :: [Text] -> Text -> IO ()
formattedMessage formatting = TIO.putStrLn . Colourista.formatWith formatting
{-# INLINE formattedMessage #-}
108 changes: 0 additions & 108 deletions src/Colourista/Mode.hs

This file was deleted.

0 comments on commit 8cfbaa3

Please sign in to comment.