Safe Haskell | None |
---|---|
Language | Haskell2010 |
- Building chunks
- Rendering
- Rendering chunks to strict bytestring in UTF8
- Rendering chunks to lazy bytestring builders in UTF8
- Rendering chunks to strict Text
- Rendering chunks to lazy text
- Rendering chunks to lazy text builder
- Decrecated rendering chunks to strict bytestring in UTF8
- Deprecated rendering chunks to lazy bytestring builders in UTF8
- IO
Safe Coloured Text
This module is responsible for defining, building, and rendering coloured text.
The text to be coloured is Text
, but the rendered text, while technically still (probably) valid Utf8, will be a ByteString
builder.
Synopsis
- chunk :: Text -> Chunk
- data Chunk = Chunk {
- chunkText :: !Text
- chunkItalic :: !(Maybe Bool)
- chunkConsoleIntensity :: !(Maybe ConsoleIntensity)
- chunkUnderlining :: !(Maybe Underlining)
- chunkBlinking :: !(Maybe Blinking)
- chunkForeground :: !(Maybe Colour)
- chunkBackground :: !(Maybe Colour)
- fore :: Colour -> Chunk -> Chunk
- back :: Colour -> Chunk -> Chunk
- bold :: Chunk -> Chunk
- faint :: Chunk -> Chunk
- italic :: Chunk -> Chunk
- underline :: Chunk -> Chunk
- doubleUnderline :: Chunk -> Chunk
- noUnderline :: Chunk -> Chunk
- slowBlinking :: Chunk -> Chunk
- rapidBlinking :: Chunk -> Chunk
- noBlinking :: Chunk -> Chunk
- data Colour
- black :: Colour
- red :: Colour
- green :: Colour
- yellow :: Colour
- blue :: Colour
- magenta :: Colour
- cyan :: Colour
- white :: Colour
- brightBlack :: Colour
- brightRed :: Colour
- brightGreen :: Colour
- brightYellow :: Colour
- brightBlue :: Colour
- brightMagenta :: Colour
- brightCyan :: Colour
- brightWhite :: Colour
- color256 :: Word8 -> Colour
- colour256 :: Word8 -> Colour
- colorRGB :: Word8 -> Word8 -> Word8 -> Colour
- colourRGB :: Word8 -> Word8 -> Word8 -> Colour
- renderChunksUtf8BS :: Foldable f => TerminalCapabilities -> f Chunk -> ByteString
- renderChunkUtf8BS :: TerminalCapabilities -> Chunk -> ByteString
- renderChunksUtf8BSBuilder :: Foldable f => TerminalCapabilities -> f Chunk -> Builder
- renderChunkUtf8BSBuilder :: TerminalCapabilities -> Chunk -> Builder
- renderChunksText :: Foldable f => TerminalCapabilities -> f Chunk -> Text
- renderChunkText :: TerminalCapabilities -> Chunk -> Text
- renderChunksLazyText :: Foldable f => TerminalCapabilities -> f Chunk -> Text
- renderChunkLazyText :: TerminalCapabilities -> Chunk -> Text
- renderChunksBuilder :: Foldable f => TerminalCapabilities -> f Chunk -> Builder
- renderChunkBuilder :: TerminalCapabilities -> Chunk -> Builder
- renderChunksBS :: Foldable f => TerminalCapabilities -> f Chunk -> ByteString
- renderChunkBS :: TerminalCapabilities -> Chunk -> ByteString
- renderChunks :: Foldable f => TerminalCapabilities -> f Chunk -> Builder
- renderChunk :: TerminalCapabilities -> Chunk -> Builder
- data TerminalCapabilities
- putChunksUtf8With :: TerminalCapabilities -> [Chunk] -> IO ()
- putChunksLocaleWith :: TerminalCapabilities -> [Chunk] -> IO ()
- hPutChunksUtf8With :: TerminalCapabilities -> Handle -> [Chunk] -> IO ()
- hPutChunksLocaleWith :: TerminalCapabilities -> Handle -> [Chunk] -> IO ()
- putChunksWith :: TerminalCapabilities -> [Chunk] -> IO ()
- hPutChunksWith :: TerminalCapabilities -> Handle -> [Chunk] -> IO ()
Building chunks
Chunk | |
|
Instances
Styling
Setting colour
Setting non-colour attributes
doubleUnderline :: Chunk -> Chunk Source #
noUnderline :: Chunk -> Chunk Source #
slowBlinking :: Chunk -> Chunk Source #
rapidBlinking :: Chunk -> Chunk Source #
noBlinking :: Chunk -> Chunk Source #
Colours
Instances
8-colour
Dull
Bright
brightBlack :: Colour Source #
brightGreen :: Colour Source #
brightBlue :: Colour Source #
brightCyan :: Colour Source #
brightWhite :: Colour Source #
8-bit
colour256 :: Word8 -> Colour Source #
Bulid an 8-bit RGB Colour
This will not be rendered unless With8BitColours
is used.
24-bit
colourRGB :: Word8 -> Word8 -> Word8 -> Colour Source #
Bulid a 24-bit RGB Colour
This will not be rendered unless With24BitColours
is used.
Rendering
Rendering chunks to strict bytestring in UTF8
renderChunksUtf8BS :: Foldable f => TerminalCapabilities -> f Chunk -> ByteString Source #
Render chunks directly to a UTF8-encoded Bytestring
.
renderChunkUtf8BS :: TerminalCapabilities -> Chunk -> ByteString Source #
Render a chunk directly to a UTF8-encoded Bytestring
.
Rendering chunks to lazy bytestring builders in UTF8
renderChunksUtf8BSBuilder :: Foldable f => TerminalCapabilities -> f Chunk -> Builder Source #
Render chunks to a UTF8-encoded ByteString
Builder
.
renderChunkUtf8BSBuilder :: TerminalCapabilities -> Chunk -> Builder Source #
Render a chunk directly to a UTF8-encoded Bytestring
Builder
.
Rendering chunks to strict Text
renderChunksText :: Foldable f => TerminalCapabilities -> f Chunk -> Text Source #
Render chunks directly to strict Text
.
renderChunkText :: TerminalCapabilities -> Chunk -> Text Source #
Render a chunk directly to strict Text
.
Rendering chunks to lazy text
renderChunksLazyText :: Foldable f => TerminalCapabilities -> f Chunk -> Text Source #
Render chunks directly to lazy Text
.
renderChunkLazyText :: TerminalCapabilities -> Chunk -> Text Source #
Render a chunk directly to strict Text
.
Rendering chunks to lazy text builder
renderChunksBuilder :: Foldable f => TerminalCapabilities -> f Chunk -> Builder Source #
Decrecated rendering chunks to strict bytestring in UTF8
renderChunksBS :: Foldable f => TerminalCapabilities -> f Chunk -> ByteString Source #
Deprecated: Use renderChunksText, or renderChunksUtf8BS if you must.
Deprecated synonym for renderChunksUtf8BS
renderChunkBS :: TerminalCapabilities -> Chunk -> ByteString Source #
Deprecated: Use renderChunkText, or renderChunkUtf8BS if you must.
Deprecated synonym for renderChunkUtf8BS
Deprecated rendering chunks to lazy bytestring builders in UTF8
renderChunks :: Foldable f => TerminalCapabilities -> f Chunk -> Builder Source #
Deprecated: Use renderChunksBuilder, or renderChunksUtf8BSBuilder if you must.
Deprecated synonym for renderChunksUtf8BSBuilder
renderChunk :: TerminalCapabilities -> Chunk -> Builder Source #
Deprecated: Use renderChunkBuilder, or renderChunkUtf8BSBuilder if you must.
Deprecated synonym for renderChunkUtf8BSBuilder
IO
data TerminalCapabilities Source #
WithoutColours | No colours |
With8Colours | Only 8 colours |
With8BitColours | Only 8-bit colours |
With24BitColours | All 24-bit colours |
Instances
Outputting chunks directly
putChunksUtf8With :: TerminalCapabilities -> [Chunk] -> IO () Source #
Print a list of chunks to stdout with given TerminalCapabilities
.
putChunksLocaleWith :: TerminalCapabilities -> [Chunk] -> IO () Source #
Print a list of chunks to stdout with given TerminalCapabilities
in an encoding according to the system's locale.
hPutChunksUtf8With :: TerminalCapabilities -> Handle -> [Chunk] -> IO () Source #
Print a list of chunks to the given Handle
with given TerminalCapabilities
.
hPutChunksLocaleWith :: TerminalCapabilities -> Handle -> [Chunk] -> IO () Source #
Print a list of chunks to the given Handle
with given TerminalCapabilities
in an encoding according to the system's locale.
putChunksWith :: TerminalCapabilities -> [Chunk] -> IO () Source #
Deprecated: Use putChunksLocaleWith, or putChunksUtf8With if you must.
Deprecated synonym of putChunksUtf8With
hPutChunksWith :: TerminalCapabilities -> Handle -> [Chunk] -> IO () Source #
Deprecated: Use hPutChunksLocaleWith, or hPutChunksUtf8With if you must.
Deprecated synonym of hPutChunksUtf8With