Safe HaskellSafe

WEditor.Base.Editor

Description

Generic text-editing functionality.

Synopsis

Documentation

data EditAction c #

Actions that modify data.

Constructors

InsertText [c]

Insert a block of characters.

DeleteText

Delete a single character.

Instances

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

Defined in WEditor.Base.Editor

Methods

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

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

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

Defined in WEditor.Base.Editor

Methods

showsPrec :: Int -> EditAction c -> ShowS

show :: EditAction c -> String

showList :: [EditAction c] -> ShowS

data EditDirection #

Modification direction, relative to the cursor.

Constructors

EditBefore

Apply the edit before the cursor.

EditAfter

Apply the edit after the cursor.

Instances

Instances details
Eq EditDirection # 
Instance details

Defined in WEditor.Base.Editor

Show EditDirection # 
Instance details

Defined in WEditor.Base.Editor

Methods

showsPrec :: Int -> EditDirection -> ShowS

show :: EditDirection -> String

showList :: [EditDirection] -> ShowS

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

Any action that updates a FixedFontEditor.

data MoveDirection #

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.

Instances

Instances details
Eq MoveDirection # 
Instance details

Defined in WEditor.Base.Editor

Show MoveDirection # 
Instance details

Defined in WEditor.Base.Editor

Methods

showsPrec :: Int -> MoveDirection -> ShowS

show :: MoveDirection -> String

showList :: [MoveDirection] -> ShowS

class FixedFontEditor e c | e -> c where #

Generic text editor for fixed-width fonts.

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

Methods

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

Apply an edit action.

breakPara :: e -> EditDirection -> e #

Break the current paragraph at the cursor.

moveCursor :: e -> MoveDirection -> e #

Apply e cursor movement.

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

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

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

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 #

Set the absolute (paragraph,char) edit position.

getParaSize :: e -> Int #

Get the number of characters in the current paragraph.

getParaCount :: e -> Int #

Get the number of paragraphs in the document.

exportData :: e -> [UnparsedPara c] #

Export the modified data.

editorAppendAction :: [c] -> EditorAction c #

Action for normal character insertion.

editorBackspaceAction :: EditorAction c #

Action for the Backspace key.

editorDeleteAction :: EditorAction c #

Action for the Delete key.

editorDownAction :: EditorAction c #

Action for the down-arrow key.

editorEndAction :: EditorAction c #

Action for the End key.

editorEnterAction :: EditorAction c #

Action for the Enter key.

editorHomeAction :: EditorAction c #

Action for the Home key.

editorInsertAction :: [c] -> EditorAction c #

Action to insert after the cursor.

editorLeftAction :: EditorAction c #

Action for the left-arrow key.

editorPageDownAction :: EditorAction c #

Action for the PageDown key.

editorPageUpAction :: EditorAction c #

Action for the PageUp key.

editorRightAction :: EditorAction c #

Action for the right-arrow key.

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

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

editorUpAction :: EditorAction c #

Action for the up-arrow key.