{- This module is part of Chatty. Copyleft (c) 2014 Marvin Cohrs All wrongs reversed. Sharing is an act of love, not crime. Please share Antisplice with everyone you like. Chatty is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Chatty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Chatty. If not, see . -} -- | Provides an extended printer class that supports colours. module Text.Chatty.Extended.Printer where import Text.Chatty.Printer -- | Colour tone. data Tone = Green | Red | Yellow | Blue | Black | White | Cyan | Magenta -- | Colour brightness data Colour = Dull Tone | Vivid Tone -- | Typeclass for all printers that support colourized output. class MonadPrinter m => ExtendedPrinter m where -- | Run the function with the given colour. ebracket :: Colour -> m a -> m a ebracket c m = do estart c; a <- m; efin; return a -- | Print the string in the given colour. eprint :: Colour -> String -> m () eprint c = ebracket c . mprint -- | Print the string in the given colour and terminate the line. eprintLn :: Colour -> String -> m () eprintLn c s = eprint c s >> mprintLn "" -- | Start using the specified colour. estart :: Colour -> m () -- | Reset colour. efin :: m ()