module Text.Show.Text.Text.PrettyPrint (
showbDoc
, showbMode
, showbStylePrec
, showbTextDetailsPrec
#if MIN_VERSION_pretty(1,1,2)
, showbPrettyLevelPrec
#endif
) where
#if !(MIN_VERSION_base(4,8,0))
import Data.Monoid (mempty)
#endif
import Prelude hiding (Show)
import Text.PrettyPrint.HughesPJ (Doc, Mode, Style(..), TextDetails(..),
fullRender, style)
#if MIN_VERSION_pretty(1,1,2)
import Text.PrettyPrint.HughesPJClass (PrettyLevel)
#endif
import Text.Show.Text (Show(showb, showbPrec), Builder, fromString)
import Text.Show.Text.TH (deriveShowPragmas, defaultInlineShowb, defaultInlineShowbPrec)
import Text.Show.Text.Utils ((<>), s)
#include "inline.h"
showbDoc :: Doc -> Builder
showbDoc doc = fullRender (mode style) (lineLength style)
(ribbonsPerLine style)
txtPrinter mempty doc
txtPrinter :: TextDetails -> Builder -> Builder
txtPrinter (Chr c) b = s c <> b
txtPrinter (Str s') b = fromString s' <> b
txtPrinter (PStr s') b = fromString s' <> b
showbMode :: Mode -> Builder
showbMode = showb
showbStylePrec :: Int -> Style -> Builder
showbStylePrec = showbPrec
showbTextDetailsPrec :: Int -> TextDetails -> Builder
showbTextDetailsPrec = showbPrec
#if MIN_VERSION_pretty(1,1,2)
showbPrettyLevelPrec :: Int -> PrettyLevel -> Builder
showbPrettyLevelPrec = showbPrec
#endif
instance Show Doc where
showb = showbDoc
INLINE_INST_FUN(showb)
$(deriveShowPragmas defaultInlineShowb ''Mode)
$(deriveShowPragmas defaultInlineShowbPrec ''Style)
$(deriveShowPragmas defaultInlineShowbPrec ''TextDetails)
#if MIN_VERSION_pretty(1,1,2)
$(deriveShowPragmas defaultInlineShowbPrec ''PrettyLevel)
#endif