-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Print text to terminal with colors and effects -- -- rainbow helps you print Text chunks to a terminal with colors and -- effects such as bold, underlining, etc. You pair each Text with a -- description of how it should appear. Rainbow works with both 8-color -- and 256-color terminals. -- -- rainbow uses the terminfo package which, in turn, needs the full C -- library for ncurses installed, including the development headers. -- Before installing terminfo, you may need to install the ncurses -- headers (for instance, on Debian systems, install the libncurses5-dev -- package.) @package rainbow @version 0.14.0.2 -- | Ordinarily you should not need this module. Typically you will just -- need to use System.Console.Rainbow.ColorChunks, which is -- re-exported from System.Console.Rainbow. However this module -- can be useful if you want names for individual colors, as opposed to -- names for chunks, which is what -- System.Console.Rainbow.ColorChunks provides. module System.Console.Rainbow.Colors -- | Color for an 8-color terminal. data Color8 -- | Nothing indicates to use the default color for the terminal; -- otherwise, the Terminfo Color is returned. unColor8 :: Color8 -> Maybe Color -- | Color for an 256-color terminal. data Color256 -- | Nothing indicates to use the default color for the terminal; -- otherwise, the Terminfo Color is returned. unColor256 :: Color256 -> Maybe Color -- | Any color for an 8-color terminal can also be used in a 256-color -- terminal. to256 :: Color8 -> Color256 c8_default :: Color8 c8_black :: Color8 c8_red :: Color8 c8_green :: Color8 c8_yellow :: Color8 c8_blue :: Color8 c8_magenta :: Color8 c8_cyan :: Color8 c8_white :: Color8 c8_0 :: Color8 c8_1 :: Color8 c8_2 :: Color8 c8_3 :: Color8 c8_4 :: Color8 c8_5 :: Color8 c8_6 :: Color8 c8_7 :: Color8 -- | All colors available for an 8-color terminal, in an association list -- indexed by color number. Does not include the default color, -- c8_default. c8_all :: [(Int, Color8)] c256_default :: Color256 c256_black :: Color256 c256_red :: Color256 c256_green :: Color256 c256_yellow :: Color256 c256_blue :: Color256 c256_magenta :: Color256 c256_cyan :: Color256 c256_white :: Color256 c256_grey :: Color256 c256_red_bright :: Color256 c256_green_bright :: Color256 c256_yellow_bright :: Color256 c256_blue_bright :: Color256 c256_magenta_bright :: Color256 c256_cyan_bright :: Color256 c256_white_bright :: Color256 c256_0 :: Color256 c256_1 :: Color256 c256_2 :: Color256 c256_3 :: Color256 c256_4 :: Color256 c256_5 :: Color256 c256_6 :: Color256 c256_7 :: Color256 c256_8 :: Color256 c256_9 :: Color256 c256_10 :: Color256 c256_11 :: Color256 c256_12 :: Color256 c256_13 :: Color256 c256_14 :: Color256 c256_15 :: Color256 c256_16 :: Color256 c256_17 :: Color256 c256_18 :: Color256 c256_19 :: Color256 c256_20 :: Color256 c256_21 :: Color256 c256_22 :: Color256 c256_23 :: Color256 c256_24 :: Color256 c256_25 :: Color256 c256_26 :: Color256 c256_27 :: Color256 c256_28 :: Color256 c256_29 :: Color256 c256_30 :: Color256 c256_31 :: Color256 c256_32 :: Color256 c256_33 :: Color256 c256_34 :: Color256 c256_35 :: Color256 c256_36 :: Color256 c256_37 :: Color256 c256_38 :: Color256 c256_39 :: Color256 c256_40 :: Color256 c256_41 :: Color256 c256_42 :: Color256 c256_43 :: Color256 c256_44 :: Color256 c256_45 :: Color256 c256_46 :: Color256 c256_47 :: Color256 c256_48 :: Color256 c256_49 :: Color256 c256_50 :: Color256 c256_51 :: Color256 c256_52 :: Color256 c256_53 :: Color256 c256_54 :: Color256 c256_55 :: Color256 c256_56 :: Color256 c256_57 :: Color256 c256_58 :: Color256 c256_59 :: Color256 c256_60 :: Color256 c256_61 :: Color256 c256_62 :: Color256 c256_63 :: Color256 c256_64 :: Color256 c256_65 :: Color256 c256_66 :: Color256 c256_67 :: Color256 c256_68 :: Color256 c256_69 :: Color256 c256_70 :: Color256 c256_71 :: Color256 c256_72 :: Color256 c256_73 :: Color256 c256_74 :: Color256 c256_75 :: Color256 c256_76 :: Color256 c256_77 :: Color256 c256_78 :: Color256 c256_79 :: Color256 c256_80 :: Color256 c256_81 :: Color256 c256_82 :: Color256 c256_83 :: Color256 c256_84 :: Color256 c256_85 :: Color256 c256_86 :: Color256 c256_87 :: Color256 c256_88 :: Color256 c256_89 :: Color256 c256_90 :: Color256 c256_91 :: Color256 c256_92 :: Color256 c256_93 :: Color256 c256_94 :: Color256 c256_95 :: Color256 c256_96 :: Color256 c256_97 :: Color256 c256_98 :: Color256 c256_99 :: Color256 c256_100 :: Color256 c256_101 :: Color256 c256_102 :: Color256 c256_103 :: Color256 c256_104 :: Color256 c256_105 :: Color256 c256_106 :: Color256 c256_107 :: Color256 c256_108 :: Color256 c256_109 :: Color256 c256_110 :: Color256 c256_111 :: Color256 c256_112 :: Color256 c256_113 :: Color256 c256_114 :: Color256 c256_115 :: Color256 c256_116 :: Color256 c256_117 :: Color256 c256_118 :: Color256 c256_119 :: Color256 c256_120 :: Color256 c256_121 :: Color256 c256_122 :: Color256 c256_123 :: Color256 c256_124 :: Color256 c256_125 :: Color256 c256_126 :: Color256 c256_127 :: Color256 c256_128 :: Color256 c256_129 :: Color256 c256_130 :: Color256 c256_131 :: Color256 c256_132 :: Color256 c256_133 :: Color256 c256_134 :: Color256 c256_135 :: Color256 c256_136 :: Color256 c256_137 :: Color256 c256_138 :: Color256 c256_139 :: Color256 c256_140 :: Color256 c256_141 :: Color256 c256_142 :: Color256 c256_143 :: Color256 c256_144 :: Color256 c256_145 :: Color256 c256_146 :: Color256 c256_147 :: Color256 c256_148 :: Color256 c256_149 :: Color256 c256_150 :: Color256 c256_151 :: Color256 c256_152 :: Color256 c256_153 :: Color256 c256_154 :: Color256 c256_155 :: Color256 c256_156 :: Color256 c256_157 :: Color256 c256_158 :: Color256 c256_159 :: Color256 c256_160 :: Color256 c256_161 :: Color256 c256_162 :: Color256 c256_163 :: Color256 c256_164 :: Color256 c256_165 :: Color256 c256_166 :: Color256 c256_167 :: Color256 c256_168 :: Color256 c256_169 :: Color256 c256_170 :: Color256 c256_171 :: Color256 c256_172 :: Color256 c256_173 :: Color256 c256_174 :: Color256 c256_175 :: Color256 c256_176 :: Color256 c256_177 :: Color256 c256_178 :: Color256 c256_179 :: Color256 c256_180 :: Color256 c256_181 :: Color256 c256_182 :: Color256 c256_183 :: Color256 c256_184 :: Color256 c256_185 :: Color256 c256_186 :: Color256 c256_187 :: Color256 c256_188 :: Color256 c256_189 :: Color256 c256_190 :: Color256 c256_191 :: Color256 c256_192 :: Color256 c256_193 :: Color256 c256_194 :: Color256 c256_195 :: Color256 c256_196 :: Color256 c256_197 :: Color256 c256_198 :: Color256 c256_199 :: Color256 c256_200 :: Color256 c256_201 :: Color256 c256_202 :: Color256 c256_203 :: Color256 c256_204 :: Color256 c256_205 :: Color256 c256_206 :: Color256 c256_207 :: Color256 c256_208 :: Color256 c256_209 :: Color256 c256_210 :: Color256 c256_211 :: Color256 c256_212 :: Color256 c256_213 :: Color256 c256_214 :: Color256 c256_215 :: Color256 c256_216 :: Color256 c256_217 :: Color256 c256_218 :: Color256 c256_219 :: Color256 c256_220 :: Color256 c256_221 :: Color256 c256_222 :: Color256 c256_223 :: Color256 c256_224 :: Color256 c256_225 :: Color256 c256_226 :: Color256 c256_227 :: Color256 c256_228 :: Color256 c256_229 :: Color256 c256_230 :: Color256 c256_231 :: Color256 c256_232 :: Color256 c256_233 :: Color256 c256_234 :: Color256 c256_235 :: Color256 c256_236 :: Color256 c256_237 :: Color256 c256_238 :: Color256 c256_239 :: Color256 c256_240 :: Color256 c256_241 :: Color256 c256_242 :: Color256 c256_243 :: Color256 c256_244 :: Color256 c256_245 :: Color256 c256_246 :: Color256 c256_247 :: Color256 c256_248 :: Color256 c256_249 :: Color256 c256_250 :: Color256 c256_251 :: Color256 c256_252 :: Color256 c256_253 :: Color256 c256_254 :: Color256 c256_255 :: Color256 -- | All available colors for a 256-color terminal, in an association list -- by color number. Does not include the default color, -- c256_default. c256_all :: [(Int, Color256)] instance Eq Color8 instance Ord Color8 instance Show Color8 instance Eq Color256 instance Ord Color256 instance Show Color256 -- | The innards of Rainbow. Ordinarily you should not need this module; -- instead, just import System.Console.Rainbow, which re-exports -- the most useful names from this module. module System.Console.Rainbow.Types -- | Which terminal definition to use. data Term -- | Using this terminal should always succeed. This suppresses all colors. -- Uesful if output is not going to a TTY, or if you just do not like -- colors. Dumb :: Term -- | Use the terminal with this given name. You might get this from the -- TERM environment variable, or set it explicitly. A runtime error will -- result if the terminfo database does not have a definition for this -- terminal. If this terminal supports 256 colors, then 256 colors are -- used. If this terminal supports less than 256 colors, but at least 8 -- colors, then 8 colors are used. Otherwise, no colors are used. TermName :: String -> Term -- | Gets the terminal definition from the environment. If the environment -- does not have a TERM veriable, use Dumb. termFromEnv :: IO Term -- | Gets the terminal definition from the environment and a handle. If the -- handle is not a terminal, Dumb is returned. Otherwise, the -- terminal is obtained from the environment. -- -- Changed in version 0.12.0.0 - the type of this function was -- different in previous versions. smartTermFromEnv :: Handle -> IO Term type Background8 = Last Color8 type Background256 = Last Color256 type Foreground8 = Last Color8 type Foreground256 = Last Color256 -- | Style elements that apply in both 8 and 256 color terminals. However, -- the elements are described separately for 8 and 256 color terminals, -- so that the text appearance can change depending on how many colors a -- terminal has. data StyleCommon StyleCommon :: Last Bool -> Last Bool -> Last Bool -> Last Bool -> StyleCommon scBold :: StyleCommon -> Last Bool scUnderline :: StyleCommon -> Last Bool scFlash :: StyleCommon -> Last Bool scInverse :: StyleCommon -> Last Bool -- | Describes text appearance (foreground and background colors, as well -- as other attributes such as bold) for an 8 color terminal. data Style8 Style8 :: Foreground8 -> Background8 -> StyleCommon -> Style8 foreground8 :: Style8 -> Foreground8 background8 :: Style8 -> Background8 common8 :: Style8 -> StyleCommon -- | Describes text appearance (foreground and background colors, as well -- as other attributes such as bold) for a 256 color terminal. data Style256 Style256 :: Foreground256 -> Background256 -> StyleCommon -> Style256 foreground256 :: Style256 -> Foreground256 background256 :: Style256 -> Background256 common256 :: Style256 -> StyleCommon -- | The TextSpec bundles together the styles for the 8 and 256 color -- terminals, so that the text can be portrayed on any terminal. data TextSpec TextSpec :: Style8 -> Style256 -> TextSpec style8 :: TextSpec -> Style8 style256 :: TextSpec -> Style256 -- | A chunk is some textual data coupled with a description of what color -- the text is, attributes like whether it is bold or underlined, etc. -- The chunk knows what foreground and background colors and what -- attributes to use for both an 8 color terminal and a 256 color -- terminal. -- -- The text is held as a list of strict Text. data Chunk Chunk :: TextSpec -> [Text] -> Chunk textSpec :: Chunk -> TextSpec text :: Chunk -> [Text] -- | Creates a Chunk from a strict Text with default colors -- and no special effects. fromText :: Text -> Chunk -- | Creates a Chunk from a lazy Text with default colors and -- no special effects. fromLazyText :: Text -> Chunk defaultColors :: Terminal -> TermOutput commonAttrs :: Terminal -> StyleCommon -> TermOutput -- | Gets the right set of terminal codes to apply the desired -- highlighting, bold, underlining, etc. Be sure to apply the attributes -- first (bold, underlining, etc) and then the colors. Setting the colors -- first and then the attributes seems to reset the colors, giving blank -- output. getTermCodes :: Terminal -> TextSpec -> TermOutput hPrintChunk :: Handle -> Terminal -> Chunk -> IO () -- | Sends a list of chunks to the given handle for printing. Sets up the -- terminal (this only needs to be done once.) Lazily processes the list -- of Chunk. See putChunks for notes on how many colors are used. hPutChunks :: Handle -> Term -> [Chunk] -> IO () -- | Sends a list of chunks to standard output for printing. Sets up the -- terminal (this only needs to be done once.) Lazily processes the list -- of Chunk. -- -- Which colors are used depends upon the Term. If it is -- Dumb, then no colors are used on output. If the Term is -- specified with TermName, the UNIX terminfo library is used to -- determine how many colors the terminal supports. If it supports at -- least 256 colors, then 256 colors are used. If it supports at least 8 -- colors but less than 256 colors, then 256 colors are used. Otherwise, -- no colors are used. A runtime error will occur if the TermName -- is not found in the system terminal database. putChunks :: Term -> [Chunk] -> IO () -- | Print one chunk at a time, to a handle hPutChunk :: Handle -> Chunk -> IO () -- | Print one chunk at a time, to standard output putChunk :: Chunk -> IO () -- | Print one chunk at a time, to a handle, append a newline hPutChunkLn :: Handle -> Chunk -> IO () -- | Print one chunk at a time, to standard output, append a newline putChunkLn :: Chunk -> IO () bold8 :: Chunk bold8off :: Chunk underline8 :: Chunk underline8off :: Chunk flash8 :: Chunk flash8off :: Chunk inverse8 :: Chunk inverse8off :: Chunk underline256 :: Chunk underline256off :: Chunk bold256 :: Chunk bold256off :: Chunk inverse256 :: Chunk inverse256off :: Chunk flash256 :: Chunk flash256off :: Chunk -- | Bold. What actually happens when you use Bold is going to depend on -- your terminal. For example, xterm allows you actually use a bold font -- for bold, if you have one. Otherwise, it might simulate bold by using -- overstriking. Another possibility is that your terminal might use a -- different color to indicate bold. For more details (at least for -- xterm), look at xterm (1) and search for boldColors. -- -- If your terminal uses a different color for bold, this allows an -- 8-color terminal to really have 16 colors. bold :: Chunk boldOff :: Chunk inverse :: Chunk inverseOff :: Chunk flash :: Chunk flashOff :: Chunk underline :: Chunk underlineOff :: Chunk instance Eq Term instance Show Term instance Show StyleCommon instance Eq StyleCommon instance Ord StyleCommon instance Show Style8 instance Eq Style8 instance Ord Style8 instance Show Style256 instance Eq Style256 instance Ord Style256 instance Show TextSpec instance Eq TextSpec instance Ord TextSpec instance Eq Chunk instance Show Chunk instance Ord Chunk instance Monoid Chunk instance IsString Chunk instance Monoid TextSpec instance Monoid Style256 instance Monoid Style8 instance Monoid StyleCommon -- | Color chunks. -- -- Names in this module follow these connventions: -- --
-- {-# LANGUAGE OverloadedStrings #-}
--
--
-- and all future examples assume you have enabled OverloadedStrings.
--
-- Here are some basic examples:
--
-- -- putChunkLn $ "Some blue text" <> f_blue -- putChunkLn $ "Blue on red background" <> f_blue <> b_red -- putChunkLn $ "Blue on red, foreground bold" <> f_blue <> b_red <> bold ---- -- But what makes Rainbow a little more interesting is that you can also -- specify output for 256-color terminals. To use these examples, be sure -- your TERM environment variable is set to something that supports 256 -- colors (like xterm-256color) before you start GHCi: -- --
-- putChunkLn $ "Blue on 8-color terminal, red on 256-color terminal" -- <> c8_f_blue <> c256_f_red ---- -- If mappend multiple chunks that change the same property, the -- rightmost one "wins": -- --
-- putChunkLn $ "This will be blue" <> f_red <> f_blue ---- -- This property comes in handy if you want to specify a default color -- for 8- and 256-color terminals, then a more specific shade for a -- 256-color terminal: -- --
-- putChunkLn $ "Pink" <> f_red <> c256_f_201 ---- -- However, if you use mappend to add additional Chunks -- that have text, the text will be appended: -- --
-- putChunkLn $ f_green <> "You will see this text " -- <> "and this text too, but it will all be blue" -- <> f_blue ---- -- Although one chunk can have different colors on 8- and 256-color -- terminals, it cannot have different colors on the same terminal. That -- is, if you want to print some text in one color and some text in -- another color, make two chunks. module System.Console.Rainbow -- | Which terminal definition to use. data Term -- | Using this terminal should always succeed. This suppresses all colors. -- Uesful if output is not going to a TTY, or if you just do not like -- colors. Dumb :: Term -- | Use the terminal with this given name. You might get this from the -- TERM environment variable, or set it explicitly. A runtime error will -- result if the terminfo database does not have a definition for this -- terminal. If this terminal supports 256 colors, then 256 colors are -- used. If this terminal supports less than 256 colors, but at least 8 -- colors, then 8 colors are used. Otherwise, no colors are used. TermName :: String -> Term -- | Gets the terminal definition from the environment. If the environment -- does not have a TERM veriable, use Dumb. termFromEnv :: IO Term -- | Gets the terminal definition from the environment and a handle. If the -- handle is not a terminal, Dumb is returned. Otherwise, the -- terminal is obtained from the environment. -- -- Changed in version 0.12.0.0 - the type of this function was -- different in previous versions. smartTermFromEnv :: Handle -> IO Term -- | A chunk is some textual data coupled with a description of what color -- the text is, attributes like whether it is bold or underlined, etc. -- The chunk knows what foreground and background colors and what -- attributes to use for both an 8 color terminal and a 256 color -- terminal. -- -- The text is held as a list of strict Text. data Chunk Chunk :: TextSpec -> [Text] -> Chunk textSpec :: Chunk -> TextSpec text :: Chunk -> [Text] -- | Creates a Chunk from a strict Text with default colors -- and no special effects. fromText :: Text -> Chunk -- | Creates a Chunk from a lazy Text with default colors and -- no special effects. fromLazyText :: Text -> Chunk -- | Sends a list of chunks to standard output for printing. Sets up the -- terminal (this only needs to be done once.) Lazily processes the list -- of Chunk. -- -- Which colors are used depends upon the Term. If it is -- Dumb, then no colors are used on output. If the Term is -- specified with TermName, the UNIX terminfo library is used to -- determine how many colors the terminal supports. If it supports at -- least 256 colors, then 256 colors are used. If it supports at least 8 -- colors but less than 256 colors, then 256 colors are used. Otherwise, -- no colors are used. A runtime error will occur if the TermName -- is not found in the system terminal database. putChunks :: Term -> [Chunk] -> IO () -- | Sends a list of chunks to the given handle for printing. Sets up the -- terminal (this only needs to be done once.) Lazily processes the list -- of Chunk. See putChunks for notes on how many colors are used. hPutChunks :: Handle -> Term -> [Chunk] -> IO () -- | Print one chunk at a time, to standard output putChunk :: Chunk -> IO () -- | Print one chunk at a time, to standard output, append a newline putChunkLn :: Chunk -> IO () -- | Print one chunk at a time, to a handle hPutChunk :: Handle -> Chunk -> IO () -- | Print one chunk at a time, to a handle, append a newline hPutChunkLn :: Handle -> Chunk -> IO () -- | Bold. What actually happens when you use Bold is going to depend on -- your terminal. For example, xterm allows you actually use a bold font -- for bold, if you have one. Otherwise, it might simulate bold by using -- overstriking. Another possibility is that your terminal might use a -- different color to indicate bold. For more details (at least for -- xterm), look at xterm (1) and search for boldColors. -- -- If your terminal uses a different color for bold, this allows an -- 8-color terminal to really have 16 colors. bold :: Chunk boldOff :: Chunk underline :: Chunk underlineOff :: Chunk flash :: Chunk flashOff :: Chunk inverse :: Chunk inverseOff :: Chunk bold8 :: Chunk bold8off :: Chunk underline8 :: Chunk underline8off :: Chunk flash8 :: Chunk flash8off :: Chunk inverse8 :: Chunk inverse8off :: Chunk bold256 :: Chunk bold256off :: Chunk underline256 :: Chunk underline256off :: Chunk flash256 :: Chunk flash256off :: Chunk inverse256 :: Chunk inverse256off :: Chunk