Safe HaskellSafe

WEditor.Base.Parser

Description

Generic line-parsing functionality.

Synopsis

Documentation

class FixedFontParser p c | p -> c where #

Line parser for fixed-width fonts.

  • p: Parser type providing the operations.
  • c: Character type.

Minimal complete definition

setLineWidth, breakLines, emptyLine, renderLine, splitLine

Associated Types

type BreakType p :: * #

Type used to differentiate between line-break types.

Methods

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.

splitLine #

Arguments

:: p 
-> Int

Index to split at.

-> VisibleLine c (BreakType p)

Line to split.

-> (VisibleLine c (BreakType p), VisibleLine c (BreakType p))

New lines at (bottom,top) of previous/next paragraphs.

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

Instances details
FixedFontParser (BreakWords c) c # 
Instance details

Defined in WEditor.LineWrap

Associated Types

type BreakType (BreakWords c) #