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

Safe HaskellSafe
LanguageHaskell2010

WEditor.Document

Description

Generic document-editing components.

Synopsis

Documentation

editDocument Source #

Arguments

:: FixedFontParser a c 
=> a

Parser used to break paragraphs into lines.

-> [UnparsedPara c]

List of unparsed paragraphs to be edited.

-> EditingDocument c

Document editor.

Create an editor for a document.

data EditAction c Source #

Actions that modify data.

Constructors

InsertText [c]

Insert a block of characters.

DeleteText

Delete a single character.

Instances
Eq c => Eq (EditAction c) Source # 
Instance details

Defined in WEditor.Base.Editor

Methods

(==) :: EditAction c -> EditAction c -> Bool #

(/=) :: EditAction c -> EditAction c -> Bool #

Show c => Show (EditAction c) Source # 
Instance details

Defined in WEditor.Base.Editor

data EditDirection Source #

Modification direction, relative to the cursor.

Constructors

EditBefore

Apply the edit before the cursor.

EditAfter

Apply the edit after the cursor.

type EditorAction c = forall e. FixedFontEditor e c => e -> e Source #

Any action that updates a FixedFontEditor.

class FixedFontEditor e c | e -> c where Source #

Generic text editor for fixed-width fonts.

  • e: Editor type providing the operations.
  • c: Character type.

Methods

editText :: e -> EditAction c -> EditDirection -> e Source #

Apply an edit action.

breakPara :: e -> EditDirection -> e Source #

Break the current paragraph at the cursor.

moveCursor :: e -> MoveDirection -> e Source #

Apply e cursor movement.

getCursor :: e -> (Int, Int) Source #

Get the (col,row) cursor position relative to the viewport.

getEditPoint :: e -> (Int, Int) Source #

Get the absolute (paragraph,char) edit position.

The position can be restored after cursor movements by calling setEditPoint; however, calling editText or breakPara invalidates this position.

setEditPoint :: e -> (Int, Int) -> e Source #

Set the absolute (paragraph,char) edit position.

getParaSize :: e -> Int Source #

Get the number of characters in the current paragraph.

getParaCount :: e -> Int Source #

Get the number of paragraphs in the document.

exportData :: e -> [UnparsedPara c] Source #

Export the modified data.

class FixedFontParser p c | p -> c Source #

Line parser for fixed-width fonts.

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

Minimal complete definition

setLineWidth, breakLines, emptyLine, renderLine, splitLine

class FixedFontViewer v c | v -> c where Source #

Generic editor viewport for fixed-width fonts.

  • v: Viewer type providing the operations.
  • c: Character type.

Methods

setViewSize :: v -> (Int, Int) -> v Source #

Set the (width,height) size of the viewport. Setting either to <=0 disables bounding in that dimension.

getViewSize :: v -> (Int, Int) Source #

Get the (width,height) size of the viewport.

getVisible :: v -> [[c]] Source #

Get the visible lines in the viewport. This does not need to completely fill the viewport area, but it must not exceed it.

updateView :: v -> ViewAction -> v Source #

Apply a view change.

data MoveDirection Source #

Actions that change the cursor position without changing data.

Constructors

MoveUp

Move up one line.

MoveDown

Move down one line.

MovePrev

Move backward one character.

MoveNext

Move forward one character.

MoveHome

Implementation-defined home operation.

MoveEnd

Implementation-defined end operation.

MovePageUp

Implementation-defined page-up operation.

MovePageDown

Implementation-defined page-down operation.

data UnparsedPara c Source #

Single paragraph that has not been parsed into lines.

Constructors

UnparsedPara 

Fields

  • upText :: [c]

    The complete and uparsed paragraph data.

Instances
Eq c => Eq (UnparsedPara c) Source # 
Instance details

Defined in WEditor.Base.Para

Ord c => Ord (UnparsedPara c) Source # 
Instance details

Defined in WEditor.Base.Para

Show c => Show (UnparsedPara c) Source # 
Instance details

Defined in WEditor.Base.Para

type ViewerAction c = forall v. FixedFontViewer v c => v -> v Source #

Any action that updates a FixedFontViewer.

editorAppendAction :: [c] -> EditorAction c Source #

Action for normal character insertion.

editorBackspaceAction :: EditorAction c Source #

Action for the Backspace key.

editorDeleteAction :: EditorAction c Source #

Action for the Delete key.

editorDownAction :: EditorAction c Source #

Action for the down-arrow key.

editorEndAction :: EditorAction c Source #

Action for the End key.

editorEnterAction :: EditorAction c Source #

Action for the Enter key.

editorHomeAction :: EditorAction c Source #

Action for the Home key.

editorInsertAction :: [c] -> EditorAction c Source #

Action to insert after the cursor.

editorLeftAction :: EditorAction c Source #

Action for the left-arrow key.

editorPageDownAction :: EditorAction c Source #

Action for the PageDown key.

editorPageUpAction :: EditorAction c Source #

Action for the PageUp key.

editorRightAction :: EditorAction c Source #

Action for the right-arrow key.

editorSetPositionAction :: (Int, Int) -> EditorAction c Source #

Action to set the absolute (paragraph,char) edit position.

editorUpAction :: EditorAction c Source #

Action for the up-arrow key.

viewerFillAction :: ViewerAction c Source #

Action to attempt to fill the viewport.

viewerResizeAction :: (Int, Int) -> ViewerAction c Source #

Action to resize the viewport.

viewerShiftUpAction :: Int -> ViewerAction c Source #

Action to shift the view upward.

viewerShiftDownAction :: Int -> ViewerAction c Source #

Action to shift the view downward.