word-wrap-0.5: A library for word-wrapping

Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.Wrap

Synopsis

- data FillStrategy
  - = NoFill
  - | FillIndent Int
  - | FillPrefix Text
- data FillScope
  - = FillAfterFirst
  - | FillAll
- data WrapSettings = WrapSettings {
  - preserveIndentation :: Bool
  - breakLongWords :: Bool
  - fillStrategy :: FillStrategy
  - fillScope :: FillScope
  }
- defaultWrapSettings :: WrapSettings
- wrapTextToLines :: WrapSettings -> Int -> Text -> [Text]
- wrapText :: WrapSettings -> Int -> Text -> Text

# Documentation

data FillStrategy Source #

How should wrapped lines be filled (i.e. what kind of prefix should be attached?)

Constructors

NoFill | Don't do any filling (default)
FillIndent Int | Indent by this many spaces
FillPrefix Text | Prepend this text

#### Instances

Instances details

Read FillStrategy Source # |
Instance details Defined in Text.Wrap Methods readsPrec :: Int -> ReadS FillStrategy Source # readList :: ReadS [FillStrategy] Source # readPrec :: ReadPrec FillStrategy Source # readListPrec :: ReadPrec [FillStrategy] Source #
Show FillStrategy Source # |
Instance details Defined in Text.Wrap Methods showsPrec :: Int -> FillStrategy -> ShowS Source # show :: FillStrategy -> String Source # showList :: [FillStrategy] -> ShowS Source #
Eq FillStrategy Source # |
Instance details Defined in Text.Wrap Methods (==) :: FillStrategy -> FillStrategy -> Bool Source # (/=) :: FillStrategy -> FillStrategy -> Bool Source #

data FillScope Source #

To which lines should the fill strategy be applied?

Constructors

FillAfterFirst | Apply any fill prefix only to lines after the first line (default)
FillAll | Apply any fill prefix to all lines, even if there is only one line

#### Instances

Instances details

Read FillScope Source # |
Instance details Defined in Text.Wrap Methods readsPrec :: Int -> ReadS FillScope Source # readList :: ReadS [FillScope] Source # readPrec :: ReadPrec FillScope Source # readListPrec :: ReadPrec [FillScope] Source #
Show FillScope Source # |
Instance details Defined in Text.Wrap Methods showsPrec :: Int -> FillScope -> ShowS Source # show :: FillScope -> String Source # showList :: [FillScope] -> ShowS Source #
Eq FillScope Source # |
Instance details Defined in Text.Wrap Methods (==) :: FillScope -> FillScope -> Bool Source # (/=) :: FillScope -> FillScope -> Bool Source #

data WrapSettings Source #

Settings to control how wrapping is performed.

Constructors

WrapSettings |

Fields

- preserveIndentation :: Bool

  Whether to indent new lines created by wrapping when their original line was indented.

- breakLongWords :: Bool

  Whether to break in the middle of the first word on a line when that word exceeds the wrapping width.

- fillStrategy :: FillStrategy

  What kind of prefix should be applied to lines after wrapping? (default: none)

- fillScope :: FillScope

  To which lines should the fill strategy be applied? (default: all but the first)

#### Instances

Instances details

Read WrapSettings Source # |
Instance details Defined in Text.Wrap Methods readsPrec :: Int -> ReadS WrapSettings Source # readList :: ReadS [WrapSettings] Source # readPrec :: ReadPrec WrapSettings Source # readListPrec :: ReadPrec [WrapSettings] Source #
Show WrapSettings Source # |
Instance details Defined in Text.Wrap Methods showsPrec :: Int -> WrapSettings -> ShowS Source # show :: WrapSettings -> String Source # showList :: [WrapSettings] -> ShowS Source #
Eq WrapSettings Source # |
Instance details Defined in Text.Wrap Methods (==) :: WrapSettings -> WrapSettings -> Bool Source # (/=) :: WrapSettings -> WrapSettings -> Bool Source #

defaultWrapSettings :: WrapSettings Source #

wrapTextToLines :: WrapSettings -> Int -> Text -> [Text] Source #

Wrap text at the specified width. Newlines and whitespace in the input text are preserved. Returns the lines of text in wrapped form. New lines introduced due to wrapping will have leading whitespace stripped prior to having any fill applied. Preserved indentation is always placed before any fill.

wrapText :: WrapSettings -> Int -> Text -> Text Source #

Like `wrapTextToLines`, but returns the wrapped text reconstructed with newlines inserted at wrap points.