WEditor-0.1.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

defaultBreak, setLineWidth, breakLines, renderLine

Associated Types

type BreakType a :: * Source #

Type used to differentiate between line-break types.

Methods

defaultBreak :: a -> BreakType a Source #

An acceptable fallback line-break type.

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.

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.

emptyLine :: FixedFontParser a c => a -> VisibleLine c (BreakType a) Source #

Create an empty line.