packages feed

safe-coloured-text 0.3.0.1 → 0.3.0.2

raw patch · 4 files changed

+31/−8 lines, 4 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Text.Colour: unwordsChunks :: [[Chunk]] -> [Chunk]
+ Text.Colour.Chunk: chunkWidth :: Chunk -> Int

Files

CHANGELOG.md view
@@ -1,5 +1,12 @@ # Changelog for safe-coloured-text +## [0.3.0.2] - 2024-03-26++### Added++* `unwordsChunks`+* `chunkWidth`+ ## [0.3.0.1] - 2024-03-26  ### Added
safe-coloured-text.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.2.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack  name:           safe-coloured-text-version:        0.3.0.1+version:        0.3.0.2 synopsis:       Safely output coloured text category:       User Interfaces homepage:       https://github.com/NorfairKing/safe-coloured-text#readme@@ -17,6 +17,7 @@ license-file:   LICENSE build-type:     Simple extra-source-files:+    LICENSE     CHANGELOG.md  source-repository head
src/Text/Colour.hs view
@@ -70,6 +70,7 @@      -- ** Composing chunks     unlinesChunks,+    unwordsChunks,      -- ** Rendering chunks to strict bytestring in UTF8     renderChunksUtf8BS,@@ -103,6 +104,7 @@ where  import qualified Data.ByteString.Builder as SBB+import Data.List (intercalate) import qualified Data.Text.IO as TIO import System.IO import Text.Colour.Capabilities@@ -126,6 +128,12 @@  -- | Render lines of chunks. ----- This puts newlines ("\n") inbetween the lines.+-- This puts newlines ("\n") at the end of every list of chunks. unlinesChunks :: [[Chunk]] -> [Chunk] unlinesChunks = concatMap (<> [chunk "\n"])++-- | Render lines of chunks.+--+-- This puts newlines (" ") inbetween the list of chunks.+unwordsChunks :: [[Chunk]] -> [Chunk]+unwordsChunks = intercalate [" "]
src/Text/Colour/Chunk.hs view
@@ -10,6 +10,7 @@ import Data.Maybe import Data.String import Data.Text (Text)+import qualified Data.Text as T import qualified Data.Text.Encoding as TE import qualified Data.Text.Lazy as LT import qualified Data.Text.Lazy.Builder as LTB@@ -37,6 +38,12 @@ instance IsString Chunk where   fromString = chunk . fromString +-- TODO This is not correct because text-width is correct but it's a+-- good place to put this so we can fix it later and it'll get fixed+-- everywhere.+chunkWidth :: Chunk -> Int+chunkWidth = T.length . chunkText+ plainChunk :: TerminalCapabilities -> Chunk -> Bool plainChunk tc Chunk {..} =   let Chunk _ _ _ _ _ _ _ = undefined@@ -56,23 +63,23 @@   Colour24Bit {} -> tc < With24BitColours  -- | Render chunks directly to a UTF8-encoded 'Bytestring'.-renderChunksUtf8BS :: Foldable f => TerminalCapabilities -> f Chunk -> ByteString+renderChunksUtf8BS :: (Foldable f) => TerminalCapabilities -> f Chunk -> ByteString renderChunksUtf8BS tc = TE.encodeUtf8 . renderChunksText tc  -- | Render chunks to a UTF8-encoded 'ByteString' 'Bytestring.Builder'.-renderChunksUtf8BSBuilder :: Foldable f => TerminalCapabilities -> f Chunk -> ByteString.Builder+renderChunksUtf8BSBuilder :: (Foldable f) => TerminalCapabilities -> f Chunk -> ByteString.Builder renderChunksUtf8BSBuilder tc = foldMap (renderChunkUtf8BSBuilder tc)  -- | Render chunks directly to strict 'Text'.-renderChunksText :: Foldable f => TerminalCapabilities -> f Chunk -> Text+renderChunksText :: (Foldable f) => TerminalCapabilities -> f Chunk -> Text renderChunksText tc = LT.toStrict . renderChunksLazyText tc  -- | Render chunks directly to lazy 'LT.Text'.-renderChunksLazyText :: Foldable f => TerminalCapabilities -> f Chunk -> LT.Text+renderChunksLazyText :: (Foldable f) => TerminalCapabilities -> f Chunk -> LT.Text renderChunksLazyText tc = LTB.toLazyText . renderChunksBuilder tc  -- | Render chunks to a lazy 'LT.Text' 'Text.Builder'-renderChunksBuilder :: Foldable f => TerminalCapabilities -> f Chunk -> Text.Builder+renderChunksBuilder :: (Foldable f) => TerminalCapabilities -> f Chunk -> Text.Builder renderChunksBuilder tc = foldMap (renderChunkBuilder tc)  -- | Render a chunk directly to a UTF8-encoded 'Bytestring'.