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