Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
WEditor.LineWrap
Description
Line-wrapping implementations. (See FixedFontParser
for custom wrapping.)
Synopsis
- data BreakWords c
- data LineBreak
- class WordSplitter s c | s -> c where
- splitWord :: s -> Int -> Int -> [c] -> Maybe [Int]
- isWordChar :: s -> c -> Bool
- isWhitespace :: s -> c -> Bool
- appendHyphen :: s -> [c] -> [c]
- endsWithHyphen :: s -> [c] -> Bool
- breakExact :: BreakWords c
- breakWords :: (Show s, WordSplitter s c) => s -> BreakWords c
- lazyHyphen :: (WordChar c, HyphenChar c) => LazyHyphen c
- lineBreakEnd :: LineBreak
- lineBreakHyphen :: LineBreak
- lineBreakSimple :: LineBreak
- noHyphen :: WordChar c => NoHyphen c
Documentation
data BreakWords c Source #
Wrapping policy that breaks lines based on words. Use breakWords
to
construct a new value.
Instances
Show (BreakWords c) Source # | |
Defined in WEditor.LineWrap Methods showsPrec :: Int -> BreakWords c -> ShowS # show :: BreakWords c -> String # showList :: [BreakWords c] -> ShowS # | |
FixedFontParser (BreakWords c) c Source # | |
Defined in WEditor.LineWrap Associated Types type BreakType (BreakWords c) :: Type Source # Methods setLineWidth :: BreakWords c -> Int -> BreakWords c Source # breakLines :: BreakWords c -> [c] -> [VisibleLine c (BreakType (BreakWords c))] Source # emptyLine :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) Source # renderLine :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) -> [c] Source # tweakCursor :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) -> Int -> Int Source # splitLine :: BreakWords c -> Int -> VisibleLine c (BreakType (BreakWords c)) -> (VisibleLine c (BreakType (BreakWords c)), VisibleLine c (BreakType (BreakWords c))) Source # | |
type BreakType (BreakWords c) Source # | |
Defined in WEditor.LineWrap |
Line break type for a single paragraph line.
Instances
Eq LineBreak Source # | |
Ord LineBreak Source # | |
Show LineBreak Source # | |
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
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:- 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.
- If there are more segments, the first is appended to the current line being parsed.
- 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.