Safe Haskell | Safe |
---|
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 e. FixedFontEditor e c => e -> e
- class FixedFontEditor e c | e -> c where
- editText :: e -> EditAction c -> EditDirection -> e
- breakPara :: e -> EditDirection -> e
- moveCursor :: e -> MoveDirection -> e
- getCursor :: e -> (Int, Int)
- getEditPoint :: e -> (Int, Int)
- setEditPoint :: e -> (Int, Int) -> e
- getParaSize :: e -> Int
- getParaCount :: e -> Int
- exportData :: e -> [UnparsedPara c]
- class FixedFontParser p c | p -> c
- class FixedFontViewer v c | v -> c where
- setViewSize :: v -> (Int, Int) -> v
- getViewSize :: v -> (Int, Int)
- getVisible :: v -> [[c]]
- updateView :: v -> ViewAction -> v
- data MoveDirection
- data UnparsedPara c = UnparsedPara {
- upText :: [c]
- type ViewerAction c = forall v. FixedFontViewer v c => v -> v
- 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
- viewerFillAction :: ViewerAction c
- viewerResizeAction :: (Int, Int) -> ViewerAction c
- viewerShiftUpAction :: Int -> ViewerAction c
- viewerShiftDownAction :: Int -> ViewerAction c
Documentation
data EditingDocument c #
Generic document editor with a dynamic viewport.
This editor bounds vertical view scrolling (see ViewAction
) to keep the
cursor within view.
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 #
Actions that modify data.
InsertText [c] | Insert a block of characters. |
DeleteText | Delete a single character. |
Instances
Eq c => Eq (EditAction c) # | |
Defined in WEditor.Base.Editor (==) :: EditAction c -> EditAction c -> Bool (/=) :: EditAction c -> EditAction c -> Bool | |
Show c => Show (EditAction c) # | |
Defined in WEditor.Base.Editor showsPrec :: Int -> EditAction c -> ShowS show :: EditAction c -> String showList :: [EditAction c] -> ShowS |
data EditDirection #
Modification direction, relative to the cursor.
EditBefore | Apply the edit before the cursor. |
EditAfter | Apply the edit after the cursor. |
Instances
Eq EditDirection # | |
Defined in WEditor.Base.Editor (==) :: EditDirection -> EditDirection -> Bool (/=) :: EditDirection -> EditDirection -> Bool | |
Show EditDirection # | |
Defined in WEditor.Base.Editor 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
.
class FixedFontEditor e c | e -> c where #
Generic text editor for fixed-width fonts.
e
: Editor type providing the operations.c
: Character type.
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.
Instances
FixedFontEditor (EditingDocument c) c # | |
Defined in WEditor.Document editText :: EditingDocument c -> EditAction c -> EditDirection -> EditingDocument c # breakPara :: EditingDocument c -> EditDirection -> EditingDocument c # moveCursor :: EditingDocument c -> MoveDirection -> EditingDocument c # getCursor :: EditingDocument c -> (Int, Int) # getEditPoint :: EditingDocument c -> (Int, Int) # setEditPoint :: EditingDocument c -> (Int, Int) -> EditingDocument c # getParaSize :: EditingDocument c -> Int # getParaCount :: EditingDocument c -> Int # exportData :: EditingDocument c -> [UnparsedPara c] # |
class FixedFontParser p c | p -> c #
Line parser for fixed-width fonts.
p
: Parser type providing the operations.c
: Character type.
Instances
FixedFontParser (BreakWords c) c # | |
Defined in WEditor.LineWrap type BreakType (BreakWords c) # setLineWidth :: BreakWords c -> Int -> BreakWords c # breakLines :: BreakWords c -> [c] -> [VisibleLine c (BreakType (BreakWords c))] # emptyLine :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) # renderLine :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) -> [c] # tweakCursor :: BreakWords c -> VisibleLine c (BreakType (BreakWords c)) -> Int -> Int # splitLine :: BreakWords c -> Int -> VisibleLine c (BreakType (BreakWords c)) -> (VisibleLine c (BreakType (BreakWords c)), VisibleLine c (BreakType (BreakWords c))) # |
class FixedFontViewer v c | v -> c where #
Generic editor viewport for fixed-width fonts.
v
: Viewer type providing the operations.c
: Character type.
setViewSize :: v -> (Int, Int) -> v #
Set the (width,height)
size of the viewport. Setting either to <=0
disables bounding in that dimension.
getViewSize :: v -> (Int, Int) #
Get the (width,height)
size of the viewport.
getVisible :: v -> [[c]] #
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 #
Apply a view change.
Instances
FixedFontViewer (EditingDocument c) c # | |
Defined in WEditor.Document setViewSize :: EditingDocument c -> (Int, Int) -> EditingDocument c # getViewSize :: EditingDocument c -> (Int, Int) # getVisible :: EditingDocument c -> [[c]] # updateView :: EditingDocument c -> ViewAction -> EditingDocument c # |
data MoveDirection #
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 # | |
Defined in WEditor.Base.Editor (==) :: MoveDirection -> MoveDirection -> Bool (/=) :: MoveDirection -> MoveDirection -> Bool | |
Show MoveDirection # | |
Defined in WEditor.Base.Editor showsPrec :: Int -> MoveDirection -> ShowS show :: MoveDirection -> String showList :: [MoveDirection] -> ShowS |
data UnparsedPara c #
Single paragraph that has not been parsed into lines.
UnparsedPara | |
|
Instances
Eq c => Eq (UnparsedPara c) # | |
Defined in WEditor.Base.Para (==) :: UnparsedPara c -> UnparsedPara c -> Bool (/=) :: UnparsedPara c -> UnparsedPara c -> Bool | |
Ord c => Ord (UnparsedPara c) # | |
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) # | |
Defined in WEditor.Base.Para showsPrec :: Int -> UnparsedPara c -> ShowS show :: UnparsedPara c -> String showList :: [UnparsedPara c] -> ShowS |
type ViewerAction c = forall v. FixedFontViewer v c => v -> v #
Any action that updates a FixedFontViewer
.
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.
viewerFillAction :: ViewerAction c #
Action to attempt to fill the viewport.
viewerResizeAction :: (Int, Int) -> ViewerAction c #
Action to resize the viewport.
viewerShiftUpAction :: Int -> ViewerAction c #
Action to shift the view upward.
viewerShiftDownAction :: Int -> ViewerAction c #
Action to shift the view downward.