safe-coloured-text 0.3.0.2 → 0.4.0.0
raw patch · 5 files changed
+58/−4 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.Colour: [chunkConcealed] :: Chunk -> !Maybe Bool
+ Text.Colour: [chunkOverlined] :: Chunk -> !Maybe Bool
+ Text.Colour: [chunkStrikethrough] :: Chunk -> !Maybe Bool
+ Text.Colour: [chunkSwapForegroundBackground] :: Chunk -> !Maybe Bool
+ Text.Colour: concealed :: Chunk -> Chunk
+ Text.Colour: overlined :: Chunk -> Chunk
+ Text.Colour: strikethrough :: Chunk -> Chunk
+ Text.Colour: swapForegroundBackground :: Chunk -> Chunk
+ Text.Colour.Chunk: [chunkConcealed] :: Chunk -> !Maybe Bool
+ Text.Colour.Chunk: [chunkOverlined] :: Chunk -> !Maybe Bool
+ Text.Colour.Chunk: [chunkStrikethrough] :: Chunk -> !Maybe Bool
+ Text.Colour.Chunk: [chunkSwapForegroundBackground] :: Chunk -> !Maybe Bool
+ Text.Colour.Chunk: concealed :: Chunk -> Chunk
+ Text.Colour.Chunk: overlined :: Chunk -> Chunk
+ Text.Colour.Chunk: strikethrough :: Chunk -> Chunk
+ Text.Colour.Chunk: swapForegroundBackground :: Chunk -> Chunk
+ Text.Colour.Code: SetConcealed :: !Bool -> SGR
+ Text.Colour.Code: SetOverlined :: !Bool -> SGR
+ Text.Colour.Code: SetStrikethrough :: !Bool -> SGR
+ Text.Colour.Code: SetSwapForegroundBackground :: !Bool -> SGR
- Text.Colour: Chunk :: !Text -> !Maybe Bool -> !Maybe ConsoleIntensity -> !Maybe Underlining -> !Maybe Blinking -> !Maybe Colour -> !Maybe Colour -> Chunk
+ Text.Colour: Chunk :: !Text -> !Maybe Bool -> !Maybe Bool -> !Maybe Bool -> !Maybe Bool -> !Maybe Bool -> !Maybe ConsoleIntensity -> !Maybe Underlining -> !Maybe Blinking -> !Maybe Colour -> !Maybe Colour -> Chunk
- Text.Colour.Chunk: Chunk :: !Text -> !Maybe Bool -> !Maybe ConsoleIntensity -> !Maybe Underlining -> !Maybe Blinking -> !Maybe Colour -> !Maybe Colour -> Chunk
+ Text.Colour.Chunk: Chunk :: !Text -> !Maybe Bool -> !Maybe Bool -> !Maybe Bool -> !Maybe Bool -> !Maybe Bool -> !Maybe ConsoleIntensity -> !Maybe Underlining -> !Maybe Blinking -> !Maybe Colour -> !Maybe Colour -> Chunk
Files
- CHANGELOG.md +14/−1
- safe-coloured-text.cabal +2/−2
- src/Text/Colour.hs +4/−0
- src/Text/Colour/Chunk.hs +30/−1
- src/Text/Colour/Code.hs +8/−0
CHANGELOG.md view
@@ -1,6 +1,19 @@ # Changelog for safe-coloured-text -## [0.3.0.2] - 2024-03-26+## [0.4.0.0] - 2026-04-12++### Added++* Strikethrough support (`chunkStrikethrough`, `strikethrough`, SGR 9/29)+* Reverse video support (`chunkSwapForegroundBackground`, `swapForegroundBackground`, SGR 7/27)+* Concealed/hidden text support (`chunkConcealed`, `concealed`, SGR 8/28)+* Overline support (`chunkOverlined`, `overlined`, SGR 53/55)++### Fixed++* `chunkBlinking` is now rendered in `chunkSGR` (was stored but never emitted)++## [0.3.0.2] - 2024-06-23 ### 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.36.0.+-- This file has been generated from package.yaml by hpack version 0.37.0. -- -- see: https://github.com/sol/hpack name: safe-coloured-text-version: 0.3.0.2+version: 0.4.0.0 synopsis: Safely output coloured text category: User Interfaces homepage: https://github.com/NorfairKing/safe-coloured-text#readme
src/Text/Colour.hs view
@@ -26,6 +26,10 @@ bold, faint, italic,+ strikethrough,+ swapForegroundBackground,+ concealed,+ overlined, underline, doubleUnderline, noUnderline,
src/Text/Colour/Chunk.hs view
@@ -25,6 +25,10 @@ data Chunk = Chunk { chunkText :: !Text, chunkItalic :: !(Maybe Bool),+ chunkStrikethrough :: !(Maybe Bool),+ chunkSwapForegroundBackground :: !(Maybe Bool),+ chunkConcealed :: !(Maybe Bool),+ chunkOverlined :: !(Maybe Bool), chunkConsoleIntensity :: !(Maybe ConsoleIntensity), chunkUnderlining :: !(Maybe Underlining), chunkBlinking :: !(Maybe Blinking),@@ -46,9 +50,13 @@ plainChunk :: TerminalCapabilities -> Chunk -> Bool plainChunk tc Chunk {..} =- let Chunk _ _ _ _ _ _ _ = undefined+ let Chunk _ _ _ _ _ _ _ _ _ _ _ = undefined in and [ isNothing chunkItalic,+ isNothing chunkStrikethrough,+ isNothing chunkSwapForegroundBackground,+ isNothing chunkConcealed,+ isNothing chunkOverlined, isNothing chunkConsoleIntensity, isNothing chunkUnderlining, isNothing chunkBlinking,@@ -114,7 +122,12 @@ chunkSGR tc Chunk {..} = catMaybes [ SetItalic <$> chunkItalic,+ SetStrikethrough <$> chunkStrikethrough,+ SetSwapForegroundBackground <$> chunkSwapForegroundBackground,+ SetConcealed <$> chunkConcealed,+ SetOverlined <$> chunkOverlined, SetUnderlining <$> chunkUnderlining,+ SetBlinking <$> chunkBlinking, SetConsoleIntensity <$> chunkConsoleIntensity, chunkForeground >>= colourSGR tc Foreground, chunkBackground >>= colourSGR tc Background@@ -126,6 +139,10 @@ Chunk { chunkText = t, chunkItalic = Nothing,+ chunkStrikethrough = Nothing,+ chunkSwapForegroundBackground = Nothing,+ chunkConcealed = Nothing,+ chunkOverlined = Nothing, chunkConsoleIntensity = Nothing, chunkUnderlining = Nothing, chunkBlinking = Nothing,@@ -147,6 +164,18 @@ italic :: Chunk -> Chunk italic chu = chu {chunkItalic = Just True}++strikethrough :: Chunk -> Chunk+strikethrough chu = chu {chunkStrikethrough = Just True}++swapForegroundBackground :: Chunk -> Chunk+swapForegroundBackground chu = chu {chunkSwapForegroundBackground = Just True}++concealed :: Chunk -> Chunk+concealed chu = chu {chunkConcealed = Just True}++overlined :: Chunk -> Chunk+overlined chu = chu {chunkOverlined = Just True} underline :: Chunk -> Chunk underline chu = chu {chunkUnderlining = Just SingleUnderline}
src/Text/Colour/Code.hs view
@@ -71,6 +71,10 @@ data SGR = Reset | SetItalic !Bool+ | SetStrikethrough !Bool+ | SetSwapForegroundBackground !Bool+ | SetConcealed !Bool+ | SetOverlined !Bool | SetUnderlining !Underlining | SetBlinking !Blinking | SetConsoleIntensity !ConsoleIntensity@@ -95,6 +99,10 @@ sgrToCSIParams = \case Reset -> [] -- [0] would be fine too SetItalic b -> [if b then 3 else 23]+ SetStrikethrough b -> [if b then 9 else 29]+ SetSwapForegroundBackground b -> [if b then 7 else 27]+ SetConcealed b -> [if b then 8 else 28]+ SetOverlined b -> [if b then 53 else 55] SetUnderlining u -> [ case u of SingleUnderline -> 4