{-# LINE 2 "./Graphics/Rendering/Pango/Markup.chs" #-}
module Graphics.Rendering.Pango.Markup (
SpanAttribute(..),
markSpan,
parseMarkup
) where
import qualified Graphics.Rendering.Pango.Enums as Pango
import Graphics.Rendering.Pango.Attributes ( parseMarkup )
data SpanAttribute
= FontDescr String
| FontFamily String
| FontSize Pango.Size
| FontStyle Pango.FontStyle
| FontWeight Pango.Weight
| FontVariant Pango.Variant
| FontStretch Pango.Stretch
| FontForeground String
| FontBackground String
| FontUnderline Pango.Underline
| FontRise Double
| FontLang Pango.Language
| FontGravity Pango.PangoGravity
| FontGravityHint Pango.PangoGravityHint
instance Show SpanAttribute where
showsPrec :: Int -> SpanAttribute -> ShowS
showsPrec Int
_ (FontDescr String
str) = String -> ShowS
showString String
" font_desc="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.String -> ShowS
forall a. Show a => a -> ShowS
shows String
str
showsPrec Int
_ (FontFamily String
str) = String -> ShowS
showString String
" font_family="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.String -> ShowS
forall a. Show a => a -> ShowS
shows String
str
showsPrec Int
_ (FontSize Size
size) = String -> ShowS
showString String
" size="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Size -> ShowS
forall a. Show a => a -> ShowS
shows Size
size
showsPrec Int
_ (FontStyle FontStyle
style) = String -> ShowS
showString String
" style="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.FontStyle -> ShowS
forall a. Show a => a -> ShowS
shows FontStyle
style
showsPrec Int
_ (FontWeight Weight
w) = String -> ShowS
showString String
" weight="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Weight -> ShowS
forall a. Show a => a -> ShowS
shows Weight
w
showsPrec Int
_ (FontVariant Variant
v) = String -> ShowS
showString String
" variant="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Variant -> ShowS
forall a. Show a => a -> ShowS
shows Variant
v
showsPrec Int
_ (FontStretch Stretch
s) = String -> ShowS
showString String
" stretch="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Stretch -> ShowS
forall a. Show a => a -> ShowS
shows Stretch
s
showsPrec Int
_ (FontForeground String
c) = String -> ShowS
showString String
" foreground="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.String -> ShowS
forall a. Show a => a -> ShowS
shows String
c
showsPrec Int
_ (FontBackground String
c) = String -> ShowS
showString String
" background="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.String -> ShowS
forall a. Show a => a -> ShowS
shows String
c
showsPrec Int
_ (FontUnderline Underline
u) = String -> ShowS
showString String
" underline="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Underline -> ShowS
forall a. Show a => a -> ShowS
shows Underline
u
showsPrec Int
_ (FontRise Double
r) = String -> ShowS
showString String
" rise="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.String -> ShowS
forall a. Show a => a -> ShowS
shows
(Integer -> String
forall a. Show a => a -> String
show (Double -> Integer
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
round (Double
rDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
10000)))
showsPrec Int
_ (FontLang Language
l) = String -> ShowS
showString String
" lang="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Language -> ShowS
forall a. Show a => a -> ShowS
shows Language
l
showsPrec Int
_ (FontGravity PangoGravity
g) = String -> ShowS
showString String
" gravity="ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.PangoGravity -> ShowS
forall a. Show a => a -> ShowS
shows PangoGravity
g
showsPrec Int
_ (FontGravityHint PangoGravityHint
h) = String -> ShowS
showString String
" gravity_hint"ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.PangoGravityHint -> ShowS
forall a. Show a => a -> ShowS
shows PangoGravityHint
h
markSpan :: [SpanAttribute] -> String -> String
markSpan :: [SpanAttribute] -> ShowS
markSpan [SpanAttribute]
attrs String
text = String -> ShowS
showString String
"<span"ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
(ShowS -> ShowS -> ShowS) -> ShowS -> [ShowS] -> ShowS
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) (Char -> ShowS
showChar Char
'>') ((SpanAttribute -> ShowS) -> [SpanAttribute] -> [ShowS]
forall a b. (a -> b) -> [a] -> [b]
map SpanAttribute -> ShowS
forall a. Show a => a -> ShowS
shows [SpanAttribute]
attrs)ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
String -> ShowS
showString String
textShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
String -> ShowS
showString String
"</span>" ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String
""