Maintainer | gtk2hs-users@lists.sourceforge.net |
---|---|
Stability | provisional |
Portability | portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell98 |
This module defines some helper functions for generating texts with embedded attributes. Note that there is no need to use these functions. In particular, if you set markup in labels that are subject to internationalization, it can be of advantage to write out the markup instead of using the functions in this module.
In order to display a string that may contain markup characters, use
escapeMarkup
.
When you write markup directly, you can make use of the following convenience tags:
b
- Bold
big
- Makes font relatively larger
i
- Italic
s
- Strikethrough
sub
- Subscript
sup
- Superscript
small
- Makes font relatively smaller
tt
- Monospace font
u
- Underline
- data SpanAttribute
- = FontDescr String
- | FontFamily String
- | FontSize Size
- | FontStyle FontStyle
- | FontWeight Weight
- | FontVariant Variant
- | FontStretch Stretch
- | FontForeground String
- | FontBackground String
- | FontUnderline Underline
- | FontRise Double
- | FontLang Language
- | FontGravity PangoGravity
- | FontGravityHint PangoGravityHint
- markSpan :: [SpanAttribute] -> String -> String
- parseMarkup :: (GlibString markup, GlibString string) => markup -> Char -> IO ([[PangoAttribute]], Char, string)
Documentation
data SpanAttribute Source
These are all the attributes the markSpan
function can express.
FontDescr String | Choose a font by textual description.
|
FontFamily String | Specify the family of font to use.
|
FontSize Size | Change the size of the current font.
|
FontStyle FontStyle | Change the slant of the current font. |
FontWeight Weight | Change the thickness of the current font.
|
FontVariant Variant | Choosing an alternative rendering for lower case letters.
|
FontStretch Stretch | Choose a different width.
|
FontForeground String | Foreground color.
|
FontBackground String | Background color. |
FontUnderline Underline | Specify underlining of text. |
FontRise Double | Specify a vertical displacement.
|
FontLang Language | Give a hint about the language to be displayed.
|
FontGravity PangoGravity | Gravity of text, use for ratation. |
FontGravityHint PangoGravityHint | Intensity of gravity. |
markSpan :: [SpanAttribute] -> String -> String Source
Create the most generic span attribute.
:: (GlibString markup, GlibString string) | |
=> markup | the string containing markup |
-> Char |
|
-> IO ([[PangoAttribute]], Char, string) | list of attributes, the accelerator character found and the input string without markup |
Parse the marked-up text (see Markup
format) to create a plain-text string and an attribute list.
- The attribute list is a list of lists of attribute. Each list describes the attributes for the same span.
- If
accelMarker
is not'\0'
(a zero character), the given character will mark the character following it as an accelerator. For example,accelMarker
might be an ampersand or underscore. All characters marked as an accelerator will receive aUnderlineLow
attribute, and the first character so marked will be returned asaccelChar
. If no accelerator character is found, theaccelMarker
character itself is returned. TwoaccelMarker
characters following each other produce a single literalaccelMarker
character. - If a parsing error occurs a
GError
is thrown.