Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Generic line-parsing functionality.
Synopsis
- class FixedFontParser a c | a -> c where
- type BreakType a :: *
- setLineWidth :: a -> Int -> a
- breakLines :: a -> [c] -> [VisibleLine c (BreakType a)]
- emptyLine :: a -> VisibleLine c (BreakType a)
- renderLine :: a -> VisibleLine c (BreakType a) -> [c]
- tweakCursor :: a -> VisibleLine c (BreakType a) -> Int -> Int
- splitLine :: a -> Int -> VisibleLine c (BreakType a) -> (VisibleLine c (BreakType a), VisibleLine c (BreakType a))
Documentation
class FixedFontParser a c | a -> c where Source #
Line parser for fixed-width fonts.
setLineWidth :: a -> Int -> a Source #
Change the max line width used for parsing. A width of zero must result in breakLines skipping line breaks.
breakLines :: a -> [c] -> [VisibleLine c (BreakType a)] Source #
Break the sequence into lines.
The following must hold for all possible inputs to a FixedFontParser
p
:
concat (map vlText (breakLines p line)) == line
Implement renderLine
and tweakCursor
to make visual adjustments (such
as adding hyphens or indentation) if necessary.
emptyLine :: a -> VisibleLine c (BreakType a) Source #
A place-holder line for empty paragraphs.
renderLine :: a -> VisibleLine c (BreakType a) -> [c] Source #
Render the line for viewing. Implement tweakCursor
if renderLine
changes the positions of any characters on the line.
tweakCursor :: a -> VisibleLine c (BreakType a) -> Int -> Int Source #
Adjust the horizontal cursor position.
:: a | |
-> Int | Index to split at. |
-> VisibleLine c (BreakType a) | Line to split. |
-> (VisibleLine c (BreakType a), VisibleLine c (BreakType a)) | End of original paragraph and beginning of next paragraph. |
Split the line to create a paragraph break.
Instances
FixedFontParser (BreakWords c) c Source # | |
Defined in WEditor.LineWrap type BreakType (BreakWords c) :: Type Source # 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 # |