WEditor-0.2.1.1: Generic text-editor logic for use with fixed-width fonts.

Safe HaskellSafe
LanguageHaskell2010

WEditor.LineWrap

Description

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

Synopsis

Documentation

data BreakWords c Source #

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

data LineBreak Source #

Line break type for a single paragraph line.

class WordSplitter s c | s -> c where Source #

Word-splitting operations for use with BreakWords.

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

Minimal complete definition

Nothing

Methods

splitWord Source #

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 Source #

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

isWhitespace :: s -> c -> Bool Source #

Predicate for detecting whitespace between words.

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

Append the canonical hyphen character to show word breaks.

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

Check the word segment for an existing hyphenation.

breakExact :: BreakWords c Source #

Wrapping policy that breaks at exactly the viewer width.

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

Wrapping policy that breaks lines based on words.

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

Hyphenates words using simple aesthetics, without dictionary awareness.

lineBreakEnd :: LineBreak Source #

The line is at the end of the paragraph.

lineBreakHyphen :: LineBreak Source #

The line ends with a hyphenated word.

lineBreakSimple :: LineBreak Source #

The line is nothing special.

noHyphen :: WordChar c => NoHyphen c Source #

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