Safe Haskell | None |
---|---|
Language | Haskell2010 |
Text formatting helpers, ported from String as needed. There may be better alternatives out there.
Synopsis
- textUnbracket :: Text -> Text
- quoteIfSpaced :: Text -> Text
- escapeDoubleQuotes :: Text -> Text
- stripquotes :: Text -> Text
- textstrip :: Text -> Text
- textlstrip :: Text -> Text
- textrstrip :: Text -> Text
- textElideRight :: Int -> Text -> Text
- textConcatTopPadded :: [Text] -> Text
- fitText :: Maybe Int -> Maybe Int -> Bool -> Bool -> Text -> Text
- textWidth :: Text -> Int
- textTakeWidth :: Int -> Text -> Text
- textPadLeftWide :: Int -> Text -> Text
- textPadRightWide :: Int -> Text -> Text
- tests_Text :: Test ()
Documentation
textUnbracket :: Text -> Text Source #
quoteIfSpaced :: Text -> Text Source #
Wrap a string in double quotes, and -prefix any embedded single quotes, if it contains whitespace and is not already single- or double-quoted.
escapeDoubleQuotes :: Text -> Text Source #
stripquotes :: Text -> Text Source #
Strip one matching pair of single or double quotes on the ends of a string.
textlstrip :: Text -> Text Source #
Remove leading whitespace.
textrstrip :: Text -> Text Source #
Remove trailing whitespace.
textConcatTopPadded :: [Text] -> Text Source #
Join several multi-line strings as side-by-side rectangular strings of the same height, top-padded. Treats wide characters as double width.
fitText :: Maybe Int -> Maybe Int -> Bool -> Bool -> Text -> Text Source #
General-purpose wide-char-aware single-line text layout function. It can left- or right-pad a short string to a minimum width. It can left- or right-clip a long string to a maximum width, optionally inserting an ellipsis (the third argument). It clips and pads on the right when the fourth argument is true, otherwise on the left. It treats wide characters as double width.
textWidth :: Text -> Int Source #
Calculate the designated render width of a string, taking into account wide characters and line breaks (the longest line within a multi-line string determines the width ).
textTakeWidth :: Int -> Text -> Text Source #
Double-width-character-aware string truncation. Take as many characters as possible from a string without exceeding the specified width. Eg textTakeWidth 3 "りんご" = "り".
textPadLeftWide :: Int -> Text -> Text Source #
Left-pad a text to the specified width. Treats wide characters as double width. Works on multi-line texts too (but will rewrite non-unix line endings).
textPadRightWide :: Int -> Text -> Text Source #
Right-pad a string to the specified width. Treats wide characters as double width. Works on multi-line strings too (but will rewrite non-unix line endings).
tests_Text :: Test () Source #