Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Generic document-editing components.
Synopsis
- data EditingDocument c
- editDocument :: FixedFontParser a c => a -> [UnparsedPara c] -> EditingDocument c
- data EditAction c
- = InsertText [c]
- | DeleteText
- data EditDirection
- type EditorAction c = forall a. FixedFontEditor a c => a -> a
- class FixedFontEditor a c | a -> c where
- editText :: a -> EditAction c -> EditDirection -> a
- breakPara :: a -> EditDirection -> a
- moveCursor :: a -> MoveDirection -> a
- getCursor :: a -> (Int, Int)
- getEditPoint :: a -> (Int, Int)
- setEditPoint :: a -> (Int, Int) -> a
- getParaSize :: a -> Int
- getParaCount :: a -> Int
- exportData :: a -> [UnparsedPara c]
- class FixedFontParser a c | a -> c
- class FixedFontViewer a c | a -> c where
- setViewSize :: a -> (Int, Int) -> a
- getViewSize :: a -> (Int, Int)
- getVisible :: a -> [[c]]
- data MoveDirection
- data UnparsedPara c = UnparsedPara {
- upText :: [c]
- type ViewerAction c = forall a. FixedFontViewer a c => a -> a
- editorAppendAction :: [c] -> EditorAction c
- editorBackspaceAction :: EditorAction c
- editorDeleteAction :: EditorAction c
- editorDownAction :: EditorAction c
- editorEndAction :: EditorAction c
- editorEnterAction :: EditorAction c
- editorHomeAction :: EditorAction c
- editorInsertAction :: [c] -> EditorAction c
- editorLeftAction :: EditorAction c
- editorPageDownAction :: EditorAction c
- editorPageUpAction :: EditorAction c
- editorRightAction :: EditorAction c
- editorSetPositionAction :: (Int, Int) -> EditorAction c
- editorUpAction :: EditorAction c
- viewerResizeAction :: (Int, Int) -> ViewerAction c
Documentation
data EditingDocument c Source #
Generic document editor with a dynamic viewport.
Instances
:: 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.
InsertText [c] | Insert a block of characters. |
DeleteText | Delete a single character. |
Instances
Eq c => Eq (EditAction c) Source # | |
Defined in WEditor.Base.Editor (==) :: EditAction c -> EditAction c -> Bool # (/=) :: EditAction c -> EditAction c -> Bool # | |
Show c => Show (EditAction c) Source # | |
Defined in WEditor.Base.Editor showsPrec :: Int -> EditAction c -> ShowS # show :: EditAction c -> String # showList :: [EditAction c] -> ShowS # |
data EditDirection Source #
Modification direction, relative to the cursor.
EditBefore | Apply the edit before the cursor. |
EditAfter | Apply the edit after the cursor. |
Instances
Eq EditDirection Source # | |
Defined in WEditor.Base.Editor (==) :: EditDirection -> EditDirection -> Bool # (/=) :: EditDirection -> EditDirection -> Bool # | |
Show EditDirection Source # | |
Defined in WEditor.Base.Editor showsPrec :: Int -> EditDirection -> ShowS # show :: EditDirection -> String # showList :: [EditDirection] -> ShowS # |
type EditorAction c = forall a. FixedFontEditor a c => a -> a Source #
Any action that updates a FixedFontEditor
.
class FixedFontEditor a c | a -> c where Source #
Generic text editor for fixed-width fonts.
editText :: a -> EditAction c -> EditDirection -> a Source #
Apply an edit action.
breakPara :: a -> EditDirection -> a Source #
Break the current paragraph at the cursor.
moveCursor :: a -> MoveDirection -> a Source #
Apply a cursor movement.
getCursor :: a -> (Int, Int) Source #
Get the (row,col) cursor position relative to the viewport.
getEditPoint :: a -> (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 :: a -> (Int, Int) -> a Source #
Set the absolute (paragraph,char) edit position.
getParaSize :: a -> Int Source #
Get the number of characters in the current paragraph.
getParaCount :: a -> Int Source #
Get the number of paragraphs in the document.
exportData :: a -> [UnparsedPara c] Source #
Export the modified data.
Instances
FixedFontEditor (EditingDocument c) c Source # | |
Defined in WEditor.Document editText :: EditingDocument c -> EditAction c -> EditDirection -> EditingDocument c Source # breakPara :: EditingDocument c -> EditDirection -> EditingDocument c Source # moveCursor :: EditingDocument c -> MoveDirection -> EditingDocument c Source # getCursor :: EditingDocument c -> (Int, Int) Source # getEditPoint :: EditingDocument c -> (Int, Int) Source # setEditPoint :: EditingDocument c -> (Int, Int) -> EditingDocument c Source # getParaSize :: EditingDocument c -> Int Source # getParaCount :: EditingDocument c -> Int Source # exportData :: EditingDocument c -> [UnparsedPara c] Source # |
class FixedFontParser a c | a -> c Source #
Line parser for fixed-width fonts.
Instances
FixedFontParser (BreakWords c) c Source # | |
Defined in WEditor.LineWrap type BreakType (BreakWords c) :: Type Source # defaultBreak :: BreakWords c -> BreakType (BreakWords c) Source # setLineWidth :: BreakWords c -> Int -> BreakWords c Source # breakLines :: BreakWords c -> [c] -> [VisibleLine c (BreakType (BreakWords c))] Source # renderLine :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) -> [c] Source # tweakCursor :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) -> Int -> Int Source # |
class FixedFontViewer a c | a -> c where Source #
Generic editor viewport for fixed-width fonts.
setViewSize :: a -> (Int, Int) -> a Source #
Sets the (width,height) size of the viewport. A width < 0 must disable line wrapping, and a height < 0 must disable vertical bounding.
getViewSize :: a -> (Int, Int) Source #
Gets the (width,height) size of the viewport.
getVisible :: a -> [[c]] Source #
Gets the visible lines in the viewport. This does not need to completely fill the viewport area, but it must not exceed it.
Instances
FixedFontViewer (EditingDocument c) c Source # | |
Defined in WEditor.Document setViewSize :: EditingDocument c -> (Int, Int) -> EditingDocument c Source # getViewSize :: EditingDocument c -> (Int, Int) Source # getVisible :: EditingDocument c -> [[c]] Source # |
data MoveDirection Source #
Actions that change the cursor position without changing data.
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
Eq MoveDirection Source # | |
Defined in WEditor.Base.Editor (==) :: MoveDirection -> MoveDirection -> Bool # (/=) :: MoveDirection -> MoveDirection -> Bool # | |
Show MoveDirection Source # | |
Defined in WEditor.Base.Editor showsPrec :: Int -> MoveDirection -> ShowS # show :: MoveDirection -> String # showList :: [MoveDirection] -> ShowS # |
data UnparsedPara c Source #
Single paragraph that has not been parsed into lines.
UnparsedPara | |
|
Instances
Eq c => Eq (UnparsedPara c) Source # | |
Defined in WEditor.Base.Para (==) :: UnparsedPara c -> UnparsedPara c -> Bool # (/=) :: UnparsedPara c -> UnparsedPara c -> Bool # | |
Ord c => Ord (UnparsedPara c) Source # | |
Defined in WEditor.Base.Para compare :: UnparsedPara c -> UnparsedPara c -> Ordering # (<) :: UnparsedPara c -> UnparsedPara c -> Bool # (<=) :: UnparsedPara c -> UnparsedPara c -> Bool # (>) :: UnparsedPara c -> UnparsedPara c -> Bool # (>=) :: UnparsedPara c -> UnparsedPara c -> Bool # max :: UnparsedPara c -> UnparsedPara c -> UnparsedPara c # min :: UnparsedPara c -> UnparsedPara c -> UnparsedPara c # | |
Show c => Show (UnparsedPara c) Source # | |
Defined in WEditor.Base.Para showsPrec :: Int -> UnparsedPara c -> ShowS # show :: UnparsedPara c -> String # showList :: [UnparsedPara c] -> ShowS # |
type ViewerAction c = forall a. FixedFontViewer a c => a -> a 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.
viewerResizeAction :: (Int, Int) -> ViewerAction c Source #
Action to resize the viewport.