-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Styled console text output using ANSI escape sequences.
--   
--   Styled console text output using ANSI escape sequences.
@package console-style
@version 0.0.2.1


-- | This library provides styled text output using ANSI escape sequences.
--   The main feature is that the library keeps track of a stack of the
--   active styles using a state monad. This makes it easy to use this
--   library for a pretty printer with nested annotations, e.g.,
--   wl-pprint-console.
--   
--   Warning: Windows support is currently not implemented, but is planned
--   (by using ansi-terminal or the ffi).
--   
--   Example:
--   
--   <pre>
--   basicExample :: IO ()
--   basicExample = runWithStyle [FgColor Blue] $ do
--     withStyle [Bold] $ liftIO $ putStr "Bold Blue"
--   
--     setStyle [Save, Italic, BgColor Red]
--     liftIO $ putStr "Italic Red"
--     setStyle [Restore]
--   
--     setStyle [Under]
--     liftIO $ putStr "Under Blue"
--     setStyle [Reset]
--   
--     liftIO $ putStrLn "Normal output"
--   </pre>
--   
--   For many more examples, see the <a>Example.hs</a> file.
module System.Console.Style

-- | Console color
data Color

-- | Default terminal color (terminal specific)
DefaultColor :: Color
Black :: Color
Red :: Color
Green :: Color
Yellow :: Color
Blue :: Color
Magenta :: Color
Cyan :: Color
White :: Color
DullBlack :: Color
DullRed :: Color
DullGreen :: Color
DullYellow :: Color
DullBlue :: Color
DullMagenta :: Color
DullCyan :: Color
DullWhite :: Color

-- | Color from 256 color scheme. Color is automatically reduced to 8
--   colors for less capable terminals.
Color256 :: !Word8 -> Color

-- | True color. Color is automatically reduced to 256 or 8 colors for less
--   capable terminals.
RGB :: !Word8 -> !Word8 -> !Word8 -> Color

-- | State accessor for the <a>Style</a>
class HasStyle s
getStyle :: HasStyle s => s -> Style
putStyle :: HasStyle s => Style -> s -> s

-- | Style commands
data SetStyle

-- | Bold font
Bold :: SetStyle

-- | Normal-weight font
NotBold :: SetStyle

-- | Italic font
Italic :: SetStyle

-- | Non-italic font
NotItalic :: SetStyle

-- | Underlined text
Under :: SetStyle

-- | Text without underline
NotUnder :: SetStyle

-- | Invert foreground and background color
Invert :: SetStyle

-- | Deactivate color inversion
NotInvert :: SetStyle

-- | Save style to stack
Save :: SetStyle

-- | Restore style from stack
Restore :: SetStyle

-- | Reset to default style
Reset :: SetStyle

-- | Activate blinking
Blink :: SetStyle

-- | Deactivate blinking
NotBlink :: SetStyle
FgColor :: !Color -> SetStyle
BgColor :: !Color -> SetStyle

-- | Abstract state datatype which keeps a stack of the applied styles.
data Style

-- | Terminal type. For less capable terminals the color depth is
--   automatically reduced.
data Term

-- | Dumb terminal - no color output
TermDumb :: Term

-- | 8 colors supported
Term8 :: Term

-- | 256 colors supported
Term256 :: Term

-- | True colors supported
TermRGB :: Term

-- | Windows terminal. Will use emulation (Not yet implemented).
TermWin :: Term

-- | The function <tt>(defaultStyle term)</tt> returns the default
--   <a>Style</a> configured with terminal type <tt>term</tt>.
defaultStyle :: Term -> Style

-- | <tt>(hDefaultStyle handle term) return the default (initial)
--   <a>Style</a> configured with the file handle </tt>handle<tt> and
--   terminal type </tt>term@.
--   
--   Every <a>Style</a> has a single associated handle.
hDefaultStyle :: Handle -> Term -> Style

-- | The action <tt>(hGetTerm handle)</tt> determines the terminal type of
--   the file <tt>handle</tt>.
--   
--   The terminal type is determined by checking if the file handle points
--   to a device and by looking at the <tt>$TERM</tt> environment variable.
hGetTerm :: MonadIO m => Handle -> m Term

-- | The action <tt>(hRunStyle handle action)</tt> runs the <a>StateT</a>
--   monad transformer providing the active <a>Style</a> for the given
--   <tt>action</tt>.
hRunStyle :: MonadIO m => Handle -> StateT Style m a -> m a

-- | The action <tt>(hRunWithStyle handle cmd action)</tt> runs the
--   <a>StateT</a> monad transformer providing the active <a>Style</a> for
--   the given <tt>action</tt>.
--   
--   The output on <tt>handle</tt> within the <tt>action</tt> is modified
--   by the given <tt>StyleSet</tt> commands <tt>cmd</tt>. The <a>Style</a>
--   is restored to the defaults afterwards.
hRunWithStyle :: (MonadIO m, Foldable f) => Handle -> f SetStyle -> StateT Style m a -> m a

-- | The action <tt>(runStyle term action)</tt> runs the <a>State</a> monad
--   providing the active <a>Style</a> for the given <tt>action</tt>.
runStyle :: Term -> State Style a -> a

-- | The action <tt>(runStyleT term action)</tt> runs the <a>StateT</a>
--   monad transformer providing the active <a>Style</a> for the given
--   <tt>action</tt>.
runStyleT :: Monad m => Term -> StateT Style m a -> m a

-- | The action <tt>(runWithStyle cmd action)</tt> runs the <a>StateT</a>
--   monad transformer providing the active <a>Style</a> for the given
--   <tt>action</tt>.
--   
--   The output on <a>stdout</a> within the <tt>action</tt> is modified by
--   the given <tt>StyleSet</tt> commands <tt>cmd</tt>. The <a>Style</a> is
--   restored to the defaults afterwards.
runWithStyle :: (MonadIO m, Foldable f) => f SetStyle -> StateT Style m a -> m a

-- | The action <tt>(setStyle cmd)</tt> modifies the active <a>Style</a> by
--   executing the <tt>StyleSet</tt> commands <tt>cmd</tt>.
--   
--   The style changes are applied immediately.
setStyle :: (MonadIO m, MonadState s m, HasStyle s, Foldable f) => f SetStyle -> m ()

-- | The action <tt>(styleCode cmd)</tt> returns the ANSI code
--   corresponding to the <tt>StyleSet</tt> commands <tt>cmd</tt>.
setStyleCode :: (MonadState s m, HasStyle s, Foldable f) => f SetStyle -> m String

-- | The action <tt>(withStyle cmd action)</tt> executes the
--   <tt>action</tt> with the active <a>Style</a> modified by the
--   <tt>StyleSet</tt> commands <tt>cmd</tt>.
--   
--   The style is restored to the previous <a>Style</a> afterwards.
withStyle :: (MonadIO m, MonadState s m, HasStyle s, Foldable f) => f SetStyle -> m a -> m a

-- | The action <tt>(changeStyle cmd)</tt> modifies the active <a>Style</a>
--   by executing the <tt>StyleSet</tt> commands <tt>cmd</tt> without
--   applying the changes.
--   
--   You have to call applyStyle or applyStyleCode afterwards!
changeStyle :: (MonadState s m, HasStyle s, Foldable f) => f SetStyle -> m ()

-- | The action <tt>applyStyle</tt> applies the latest style changes.
applyStyle :: (MonadIO m, MonadState s m, HasStyle s) => m ()

-- | The action <tt>applyStyleCode</tt> returns the ANSI code for the
--   latest style changes.
applyStyleCode :: (MonadState s m, HasStyle s) => m String
instance GHC.Show.Show System.Console.Style.StyleState
instance GHC.Classes.Ord System.Console.Style.StyleState
instance GHC.Classes.Eq System.Console.Style.StyleState
instance GHC.Show.Show System.Console.Style.SetStyle
instance GHC.Classes.Ord System.Console.Style.SetStyle
instance GHC.Classes.Eq System.Console.Style.SetStyle
instance GHC.Show.Show System.Console.Style.Term
instance GHC.Classes.Eq System.Console.Style.Term
instance GHC.Show.Show System.Console.Style.Color
instance GHC.Classes.Ord System.Console.Style.Color
instance GHC.Classes.Eq System.Console.Style.Color
instance System.Console.Style.HasStyle System.Console.Style.Style
