packages feed

safe-coloured-text-gen 0.0.0.0 → 0.0.0.1

raw patch · 5 files changed

+66/−30 lines, 5 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Text.Colour.Gen: instance Data.GenValidity.GenValid Text.Colour.Code.Blinking

Files

+ CHANGELOG.md view
@@ -0,0 +1,7 @@+# Changelog for safe-coloured-text++## [0.0.0.1] - 2022-06-29++### Added++* Support blinking text
safe-coloured-text-gen.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.34.7. -- -- see: https://github.com/sol/hpack  name:           safe-coloured-text-gen-version:        0.0.0.0+version:        0.0.0.1 description:    Generators for types in safe-coloured-text homepage:       https://github.com/NorfairKing/safe-coloured-text#readme bug-reports:    https://github.com/NorfairKing/safe-coloured-text/issues@@ -14,6 +14,8 @@ copyright:      Copyright (c) 2020 Tom Sydney Kerckhove license:        MIT build-type:     Simple+extra-source-files:+    CHANGELOG.md  source-repository head   type: git
src/Text/Colour/Gen.hs view
@@ -24,6 +24,10 @@   genValid = genValidStructurallyWithoutExtraChecking   shrinkValid = shrinkValidStructurallyWithoutExtraFiltering +instance GenValid Blinking where+  genValid = genValidStructurallyWithoutExtraChecking+  shrinkValid = shrinkValidStructurallyWithoutExtraFiltering+ instance GenValid ColourIntensity where   genValid = genValidStructurallyWithoutExtraChecking   shrinkValid = shrinkValidStructurallyWithoutExtraFiltering
test/Text/Colour/ChunkSpec.hs view
@@ -18,19 +18,19 @@   let gf = ("test_resources/chunk/" ++)   describe "renderChunk" $ do     it "outputs plain text if the terminal has no colours" $-      renderChunksBS WithoutColours [fore red "hello"] `shouldBe` "hello"+      renderChunksText WithoutColours [fore red "hello"] `shouldBe` "hello"     it "outputs plain text if the terminal has no colours and 256 are needed" $-      renderChunksBS WithoutColours [fore (colour256 128) "hello"] `shouldBe` "hello"+      renderChunksText WithoutColours [fore (colour256 128) "hello"] `shouldBe` "hello"     it "outputs plain text if the terminal has only 8 colours and 256 are needed" $-      renderChunksBS With8Colours [fore (colour256 128) "hello"] `shouldBe` "hello"+      renderChunksText With8Colours [fore (colour256 128) "hello"] `shouldBe` "hello"     it "outputs plain text if the terminal has no colours and 24bit colours are needed" $-      renderChunksBS WithoutColours [fore (colourRGB 128 128 128) "hello"] `shouldBe` "hello"+      renderChunksText WithoutColours [fore (colourRGB 128 128 128) "hello"] `shouldBe` "hello"     it "outputs plain text if the terminal has only 8 colours and 24bit colours are needed" $-      renderChunksBS With8Colours [fore (colourRGB 128 128 128) "hello"] `shouldBe` "hello"+      renderChunksText With8Colours [fore (colourRGB 128 128 128) "hello"] `shouldBe` "hello"     it "outputs plain text if the terminal has only 8bit colours and 24bit colours are needed" $-      renderChunksBS With8BitColours [fore (colourRGB 128 128 128) "hello"] `shouldBe` "hello"+      renderChunksText With8BitColours [fore (colourRGB 128 128 128) "hello"] `shouldBe` "hello"     it "outputs a plain chunk the same as before" $-      pureGoldenByteStringFile (gf "plain.dat") (renderChunkBS With24BitColours (chunk "ook"))+      pureGoldenTextFile (gf "plain.dat") (renderChunkText With24BitColours (chunk "ook"))     describe "8 colours" $ do       let gf8 = ("test_resources/chunk/8/" ++)       let chunks string = justAFew $ do@@ -42,6 +42,7 @@             chunkItalic <- Nothing : map Just [minBound .. maxBound]             chunkConsoleIntensity <- Nothing : map Just [minBound .. maxBound]             chunkUnderlining <- Nothing : map Just [minBound .. maxBound]+            chunkBlinking <- Nothing : map Just [minBound .. maxBound]             chunkForeground <- mColour             chunkBackground <- mColour             let chunkText = T.pack string@@ -56,6 +57,11 @@                   SingleUnderline -> "underline"                   DoubleUnderline -> "double underline"                   NoUnderline -> "no underline"+                blinkingName :: Blinking -> String+                blinkingName = \case+                  SlowBlinking -> "slow blinking"+                  RapidBlinking -> "rapid blinking"+                  NoBlinking -> "no underline"                 name =                   unwords $                     filter@@ -63,6 +69,7 @@                       [ maybe "" italicName chunkItalic,                         maybe "" consoleIntensityName chunkConsoleIntensity,                         maybe "" underliningName chunkUnderlining,+                        maybe "" blinkingName chunkBlinking,                         string,                         "with",                         mColourName chunkForeground,@@ -82,6 +89,11 @@                   SingleUnderline -> "underline"                   DoubleUnderline -> "double-underline"                   NoUnderline -> "no-underline"+                blinkingPath :: Blinking -> String+                blinkingPath = \case+                  SlowBlinking -> "slow-blinking"+                  RapidBlinking -> "rapid-blinking"+                  NoBlinking -> "no-underline"                 path =                   intercalate                     "-"@@ -90,6 +102,7 @@                         [ maybe "" italicPath chunkItalic,                           maybe "" consoleIntensityPath chunkConsoleIntensity,                           maybe "" underliningPath chunkUnderlining,+                          maybe "" blinkingPath chunkBlinking,                           mColourPath chunkForeground,                           "fg",                           mColourPath chunkBackground,@@ -101,7 +114,7 @@        forM_ (chunks "ook") $ \(name, path, c) ->         it (unwords ["outputs a", name, "the same way as before"]) $-          pureGoldenByteStringFile (gf8 path) (renderChunkBS With24BitColours c)+          pureGoldenTextFile (gf8 path) (renderChunkText With24BitColours c)     describe "8bit colours" $ do       let gf8bit = ("test_resources/chunk/8bit/" ++)       let chunks string = justAFew $ do@@ -110,6 +123,7 @@             let chunkItalic = Nothing             let chunkConsoleIntensity = Nothing             let chunkUnderlining = Nothing+            let chunkBlinking = Nothing             chunkForeground <- mColour             chunkBackground <- mColour             let chunkText = T.pack string@@ -133,7 +147,7 @@        forM_ (chunks "ook") $ \(name, path, c) ->         it (unwords ["outputs a", name, "the same way as before"]) $-          pureGoldenByteStringFile (gf8bit path) (renderChunkBS With24BitColours c)+          pureGoldenTextFile (gf8bit path) (renderChunkText With24BitColours c)     describe "24bit colours" $ do       let gf24bit = ("test_resources/chunk/24bit/" ++)       let chunks string = justAFew $ do@@ -147,6 +161,7 @@             let chunkItalic = Nothing             let chunkConsoleIntensity = Nothing             let chunkUnderlining = Nothing+            let chunkBlinking = Nothing             chunkForeground <- mColour             chunkBackground <- mColour             let chunkText = T.pack string@@ -170,7 +185,7 @@        forM_ (chunks "ook") $ \(name, path, c) ->         it (unwords ["outputs a", name, "the same way as before"]) $-          pureGoldenByteStringFile (gf24bit path) (renderChunkBS With24BitColours c)+          pureGoldenTextFile (gf24bit path) (renderChunkText With24BitColours c)     describe "super fancy" $ do       it "outputs this super fancy thing the same way as before" $         let bc c = back c $ chunk " "@@ -190,7 +205,7 @@                     ["\n8 bit colours:"] : map (map bc) colour8Bitss,                     ["\n24 bit colours:"] : map (map bc) colour24Bitss                   ]-         in pureGoldenByteStringFile (gf "fancy.dat") (renderChunksBS With24BitColours cs)+         in pureGoldenTextFile (gf "fancy.dat") (renderChunksText With24BitColours cs)  chunksOf :: Int -> [a] -> [[a]] chunksOf w l
test/Text/Colour/CodeSpec.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE OverloadedStrings #-}+ module Text.Colour.CodeSpec (spec) where  import Control.Monad@@ -11,7 +13,7 @@   let gf = ("test_resources/csi/" ++)   describe "renderCSI" $ do     it "outputs a reset the same as before" $-      pureGoldenByteStringFile (gf "reset.dat") (renderCSIBS (SGR [Reset]))+      pureGoldenTextFile (gf "reset.dat") (renderCSIText (SGR [Reset]))     describe "SGR" $ do       let gf8 = ("test_resources/csi/8/" ++)       describe "8 colours" $ do@@ -27,37 +29,43 @@                   )           forM_ sgrTests $ \(name, path, sgr) ->             it (unwords ["outputs a", show name, "the same as before"]) $-              pureGoldenByteStringFile (gf8 path) (renderCSIBS (SGR [sgr]))+              pureGoldenTextFile (gf8 path) (renderCSIText (SGR [sgr]))         it "outputs an dull red background with bright blue foreground the same as before" $ do-          pureGoldenByteStringFile+          pureGoldenTextFile             (gf8 "two-colours.dat")-            ( renderCSIBS+            ( renderCSIText                 ( SGR                     [ SetColour Dull Background Red,                       SetColour Bright Foreground Blue                     ]                 )             )-        it "outputs an bold, italic, underlined, dull yellow background with bright green foreground the same as before" $ do-          pureGoldenByteStringFile+        it "outputs a blinking, bold, italic, underlined, dull yellow background with bright green foreground the same as before" $ do+          pureGoldenTextFile             (gf8 "complex.dat")-            ( renderCSIBS-                ( SGR-                    [ SetItalic True,-                      SetUnderlining SingleUnderline,-                      SetConsoleIntensity BoldIntensity,-                      SetColour Dull Background Yellow,-                      SetColour Bright Foreground Green-                    ]-                )+            ( mconcat+                [ renderCSIText+                    ( SGR+                        [ SetItalic True,+                          SetUnderlining SingleUnderline,+                          SetBlinking SlowBlinking,+                          SetConsoleIntensity BoldIntensity,+                          SetColour Dull Background Yellow,+                          SetColour Bright Foreground Green+                        ]+                    ),+                  "hello world",+                  renderCSIText+                    (SGR [Reset])+                ]             )       let gf256 = ("test_resources/csi/256/" ++)       describe "256 colours" $ do         -- https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit         it "outputs a pink foreground colour with light blue background the same as before" $ do-          pureGoldenByteStringFile+          pureGoldenTextFile             (gf256 "two-colours.dat")-            ( renderCSIBS+            ( renderCSIText                 ( SGR                     [ SetColour Dull Background Red,                       SetColour Bright Foreground Blue