2013-03-02 22:07:45 +00:00
|
|
|
|
2013-04-28 12:21:46 +00:00
|
|
|
module Text where
|
2013-03-02 22:07:45 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Functions for displaying text
|
|
|
|
|
2013-09-10 06:07:49 +00:00
|
|
|
# Creating Text
|
2013-09-10 03:57:06 +00:00
|
|
|
@docs toText
|
|
|
|
|
2013-09-10 06:07:49 +00:00
|
|
|
# Creating Elements
|
|
|
|
@docs plainText, asText, text, centered, justified, righted
|
2013-09-10 03:57:06 +00:00
|
|
|
|
2013-09-10 06:07:49 +00:00
|
|
|
# Formatting
|
|
|
|
@docs color, typeface, height, link
|
|
|
|
|
|
|
|
# Simple Formatting
|
|
|
|
@docs monospace, header, bold, italic, underline, overline, strikethrough
|
2013-09-10 03:57:06 +00:00
|
|
|
|
|
|
|
-}
|
|
|
|
|
2013-07-29 17:26:53 +00:00
|
|
|
import open Basics
|
2013-07-27 11:08:46 +00:00
|
|
|
import Color (Color)
|
|
|
|
import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
|
|
|
|
import Maybe (Maybe)
|
|
|
|
import JavaScript (JSString)
|
2013-07-29 21:23:04 +00:00
|
|
|
import Native.Text
|
2013-03-05 18:06:52 +00:00
|
|
|
|
2013-07-27 11:08:46 +00:00
|
|
|
data Text = Text
|
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Convert a string into text which can be styled and displayed. -}
|
2013-03-05 18:06:52 +00:00
|
|
|
toText : String -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
toText = Native.Text.toText
|
2013-03-05 18:06:52 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Set the typeface of some text. The first argument should be a comma
|
|
|
|
separated listing of the desired typefaces
|
|
|
|
|
|
|
|
"helvetica, arial, sans-serif"
|
|
|
|
|
|
|
|
Works the same as the CSS font-family property.
|
|
|
|
-}
|
2013-03-24 12:45:56 +00:00
|
|
|
typeface : String -> Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
typeface = Native.Text.typeface
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Switch to a monospace typeface. Good for code snippets. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
monospace : Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
monospace = Native.Text.monospace
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Make text big and noticable. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
header : Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
header = Native.Text.header
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Create a link. -}
|
2013-04-29 01:52:13 +00:00
|
|
|
link : String -> Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
link = Native.Text.link
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Set the height of text in pixels. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
height : Float -> Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
height = Native.Text.height
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Set the color of a string. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
color : Color -> Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
color = Native.Text.color
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Make a string bold. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
bold : Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
bold = Native.Text.bold
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Italicize a string. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
italic : Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
italic = Native.Text.italic
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Draw a line above a string. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
overline : Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
overline = Native.Text.overline
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Underline a string. -}
|
2013-03-05 18:06:52 +00:00
|
|
|
underline : Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
underline = Native.Text.underline
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Draw a line through a string. -}
|
2013-03-05 18:06:52 +00:00
|
|
|
strikeThrough : Text -> Text
|
2013-07-29 21:23:04 +00:00
|
|
|
strikeThrough = Native.Text.strikeThrough
|
2013-03-05 18:06:52 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Display justified, styled text. -}
|
2013-03-05 18:06:52 +00:00
|
|
|
justified : Text -> Element
|
2013-07-29 21:23:04 +00:00
|
|
|
justified = Native.Text.justified
|
2013-03-05 18:06:52 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Display centered, styled text. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
centered : Text -> Element
|
2013-07-29 21:23:04 +00:00
|
|
|
centered = Native.Text.centered
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Display right justified, styled text. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
righted : Text -> Element
|
2013-07-29 21:23:04 +00:00
|
|
|
righted = Native.Text.righted
|
2013-03-24 12:45:56 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Display styled text. -}
|
2013-03-24 12:45:56 +00:00
|
|
|
text : Text -> Element
|
2013-07-29 21:23:04 +00:00
|
|
|
text = Native.Text.text
|
2013-04-10 07:52:53 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Display a plain string. -}
|
2013-04-10 07:52:53 +00:00
|
|
|
plainText : String -> Element
|
2013-07-29 21:23:04 +00:00
|
|
|
plainText = Native.Text.plainText
|
2013-05-17 20:46:08 +00:00
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| for internal use only -}
|
2013-09-01 23:07:08 +00:00
|
|
|
markdown : Element
|
|
|
|
markdown = Native.Text.markdown
|
|
|
|
|
2013-09-10 03:57:06 +00:00
|
|
|
{-| Convert anything to it's textual representation and make it displayable in
|
|
|
|
browser
|
|
|
|
|
|
|
|
asText == text . monospace . show
|
|
|
|
|
|
|
|
Excellent for debugging.
|
|
|
|
-}
|
2013-03-05 18:06:52 +00:00
|
|
|
asText : a -> Element
|
2013-07-29 21:23:04 +00:00
|
|
|
asText = Native.Text.asText
|