module Text.Trifecta.Util.Pretty
( AnsiStyle
, renderIO
, char
, bold
, debold
, underlined
, deunderline
, renderPretty
, columns
) where
import Prettyprinter
import Prettyprinter.Render.Terminal
import Prettyprinter.Render.Terminal.Internal (ansiBold, ansiUnderlining)
char :: Char -> Doc a
char :: forall a. Char -> Doc a
char = forall a ann. Pretty a => a -> Doc ann
pretty
renderPretty :: Double -> Int -> Doc AnsiStyle -> SimpleDocStream AnsiStyle
renderPretty :: Double -> Int -> Doc AnsiStyle -> SimpleDocStream AnsiStyle
renderPretty Double
ribbonFraction Int
page
= forall ann. LayoutOptions -> Doc ann -> SimpleDocStream ann
layoutSmart LayoutOptions { layoutPageWidth :: PageWidth
layoutPageWidth = Int -> Double -> PageWidth
AvailablePerLine Int
page Double
ribbonFraction }
debold, deunderline :: AnsiStyle
debold :: AnsiStyle
debold = forall a. Monoid a => a
mempty { ansiBold :: Maybe Bold
ansiBold = forall a. Maybe a
Nothing }
deunderline :: AnsiStyle
deunderline = forall a. Monoid a => a
mempty { ansiUnderlining :: Maybe Underlined
ansiUnderlining = forall a. Maybe a
Nothing}
columns :: (Maybe Int -> Doc AnsiStyle) -> Doc AnsiStyle
columns :: (Maybe Int -> Doc AnsiStyle) -> Doc AnsiStyle
columns Maybe Int -> Doc AnsiStyle
f = forall ann. (PageWidth -> Doc ann) -> Doc ann
pageWidth (Maybe Int -> Doc AnsiStyle
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. PageWidth -> Maybe Int
toMaybeInt) where
toMaybeInt :: PageWidth -> Maybe Int
toMaybeInt (AvailablePerLine Int
cpl Double
_) = forall a. a -> Maybe a
Just Int
cpl
toMaybeInt PageWidth
Unbounded = forall a. Maybe a
Nothing