redact-0.5.0.0: hide secret text on the terminal
CopyrightCopyright (c) 2020-2023 Travis Cardwell
LicenseMIT
Safe HaskellSafe-Inferred
LanguageHaskell2010

Redact.Monad.Terminal

Description

 
Synopsis

MonadTerminal

class Monad m => MonadTerminal m where Source #

Terminal output

Since: 0.4.0.0

Methods

putStr :: Text -> m () Source #

Write a string to the terminal

putStrLn :: Text -> m () Source #

Write a string to the terminal, appending a newline

setSGR :: [SGR] -> m () Source #

Set Select Graphic Rendition mode

Instances

Instances details
MonadTerminal IO Source # 
Instance details

Defined in Redact.Monad.Terminal

Methods

putStr :: Text -> IO () Source #

putStrLn :: Text -> IO () Source #

setSGR :: [SGR] -> IO () Source #

API

redactSGRs :: Color -> ColorIntensity -> [SGR] Source #

Construct SGRs for redacted text

Since: 0.4.0.0

resetSGRs :: [SGR] Source #

SGRs for resetting to normal mode

Since: 0.4.0.0

reset :: MonadTerminal m => m () Source #

Reset the terminal color mode and go to the next line

Since: 0.4.0.0

putLines :: forall m. MonadTerminal m => [SGR] -> [Line] -> m () Source #

Put redacted text to the terminal

It is assumed that the terminal is set to display normal colors when this function is called. If the first Line is a RedactLine, then an extra blank line is first output in order to set the colors. The terminal is set to display normal colors when this function exits.

Since: 0.4.0.0

Internal

initialize Source #

Arguments

:: MonadTerminal m 
=> [SGR]

SGRs for redacted text

-> Line

first line

-> m () 

Initialize the terminal colors

When the first line is a RedactLine, an extra blank line is output in order to set the terminal colors.

putLine Source #

Arguments

:: forall m. MonadTerminal m 
=> [SGR]

SGRs for redacted text

-> Line

line to put

-> Maybe Line

Just next line or Nothing if end

-> m () 

Put a line of redacted text to the terminal

The colors for the line is assumed to be already set. Be sure to call initialize before putting the first line.