Safe HaskellSafe

WEditor.LineWrap

Description

Line-wrapping implementations. (See FixedFontParser for custom wrapping.)

Synopsis

Documentation

data BreakWords c #

Wrapping policy that breaks lines based on words. Use breakWords to construct a new value.

Instances

Instances details
Show (BreakWords c) # 
Instance details

Defined in WEditor.LineWrap

Methods

showsPrec :: Int -> BreakWords c -> ShowS

show :: BreakWords c -> String

showList :: [BreakWords c] -> ShowS

FixedFontParser (BreakWords c) c # 
Instance details

Defined in WEditor.LineWrap

Associated Types

type BreakType (BreakWords c) #

type BreakType (BreakWords c) # 
Instance details

Defined in WEditor.LineWrap

data LineBreak #

Line break type for a single paragraph line.

Instances

Instances details
Eq LineBreak # 
Instance details

Defined in WEditor.LineWrap

Methods

(==) :: LineBreak -> LineBreak -> Bool

(/=) :: LineBreak -> LineBreak -> Bool

Ord LineBreak # 
Instance details

Defined in WEditor.LineWrap

Methods

compare :: LineBreak -> LineBreak -> Ordering

(<) :: LineBreak -> LineBreak -> Bool

(<=) :: LineBreak -> LineBreak -> Bool

(>) :: LineBreak -> LineBreak -> Bool

(>=) :: LineBreak -> LineBreak -> Bool

max :: LineBreak -> LineBreak -> LineBreak

min :: LineBreak -> LineBreak -> LineBreak

Show LineBreak # 
Instance details

Defined in WEditor.LineWrap

Methods

showsPrec :: Int -> LineBreak -> ShowS

show :: LineBreak -> String

showList :: [LineBreak] -> ShowS

class WordSplitter s c | s -> c where #

Word-splitting operations for use with BreakWords.

  • s: Splitter type providing the operations.
  • c: Character type.

Minimal complete definition

Nothing

Methods

splitWord #

Arguments

:: s 
-> Int

Space available on the first line.

-> Int

Space available on new lines.

-> [c]

The word to break.

-> Maybe [Int]

List of segment sizes.

Determine where to break a word.

  • The splitter can refuse to process the word by returning Nothing.
  • The segment sizes must provide space for a hyphen if appendHyphen extends the line.
  • Once the word has been split up by BreakWords, the segments are processed as follows:

    1. The last segment is prepended to the next line to be parsed. This means that if the word is not split, it gets deferred to the next line.
    2. If there are more segments, the first is appended to the current line being parsed.
    3. All remaining segments are put on separate lines between the current and next lines.

isWordChar :: s -> c -> Bool #

Predicate for characters that should be treated as a part of a word.

isWhitespace :: s -> c -> Bool #

Predicate for detecting whitespace between words.

appendHyphen :: s -> [c] -> [c] #

Append the canonical hyphen character to show word breaks.

endsWithHyphen :: s -> [c] -> Bool #

Check the word segment for an existing hyphenation.

Instances

Instances details
WordSplitter LangHyphen Char # 
Instance details

Defined in WEditorHyphen.LangHyphen

Methods

splitWord :: LangHyphen -> Int -> Int -> [Char] -> Maybe [Int] #

isWordChar :: LangHyphen -> Char -> Bool #

isWhitespace :: LangHyphen -> Char -> Bool #

appendHyphen :: LangHyphen -> [Char] -> [Char] #

endsWithHyphen :: LangHyphen -> [Char] -> Bool #

breakExact :: BreakWords c #

Wrapping policy that breaks at exactly the viewer width.

breakWords :: (Show s, WordSplitter s c) => s -> BreakWords c #

Wrapping policy that breaks lines based on words.

lazyHyphen :: (WordChar c, HyphenChar c) => LazyHyphen c #

Hyphenates words using simple aesthetics, without dictionary awareness.

lineBreakEnd :: LineBreak #

The line is at the end of the paragraph.

lineBreakHyphen :: LineBreak #

The line ends with a hyphenated word.

lineBreakSimple :: LineBreak #

The line is nothing special.

noHyphen :: WordChar c => NoHyphen c #

Avoids splitting words unless they are longer than a single line.