WEditor-0.2.0.0: Generic text-editor logic for use with fixed-width fonts.

Safe HaskellSafe
LanguageHaskell2010

WEditor.Base.Parser

Description

Generic line-parsing functionality.

Synopsis

Documentation

class FixedFontParser a c | a -> c where Source #

Line parser for fixed-width fonts.

Minimal complete definition

setLineWidth, breakLines, emptyLine, renderLine, splitLine

Associated Types

type BreakType a :: * Source #

Type used to differentiate between line-break types.

Methods

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.

splitLine Source #

Arguments

:: 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.