Safe Haskell | Safe |
---|
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 #
Wrapping policy that breaks lines based on words. Use breakWords
to
construct a new value.
Instances
Show (BreakWords c) # | |
Defined in WEditor.LineWrap showsPrec :: Int -> BreakWords c -> ShowS show :: BreakWords c -> String showList :: [BreakWords c] -> ShowS | |
FixedFontParser (BreakWords c) c # | |
Defined in WEditor.LineWrap type BreakType (BreakWords c) # setLineWidth :: BreakWords c -> Int -> BreakWords c # breakLines :: BreakWords c -> [c] -> [VisibleLine c (BreakType (BreakWords c))] # emptyLine :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) # renderLine :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) -> [c] # tweakCursor :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) -> Int -> Int # splitLine :: BreakWords c -> Int -> VisibleLine c (BreakType (BreakWords c)) -> (VisibleLine c (BreakType (BreakWords c)), VisibleLine c (BreakType (BreakWords c))) # | |
type BreakType (BreakWords c) # | |
Defined in WEditor.LineWrap |
Line break type for a single paragraph line.
class WordSplitter s c | s -> c where #
Word-splitting operations for use with BreakWords
.
s
: Splitter type providing the operations.c
: Character type.
Nothing
:: 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 #
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
WordSplitter LangHyphen Char # | |
Defined in WEditorHyphen.LangHyphen 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.
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.