Paste: editor and action gestures

Author: Georg Simon
Mode: factor
Date: Mon, 24 Aug 2015 10:09:02
Plain Text |
! editor passes C+c, C+s, and so on to it's parent. All parents should
! pass them too. In world waits a gesture-handler. It handles keypresses
! for which action gestures exist. The corresponding action gesture is
! sent to editor. editor either handles the action gesture or passes it to
! it's parent.
USING:
    accessors io kernel prettyprint 
    ui ui.gadgets.borders ui.gadgets.editors ui.gestures words
    ;
IN: editor-gestures

: .. ( obj -- )
    . flush
    ;
TUPLE: main-gadget < border
    ;
M: main-gadget handle-gesture ( gesture gadget -- ? )
    drop ! gadget
    [ ]
    [ dup key-down? [ sym>> ] [ drop f ] if ]
    [ word? ]
    tri
    or [ .. ] [ drop ] if
    t ! as some gestures are handled by world
    ;
: <main-gadget> ( child -- border )
    main-gadget new-border { 9 9 } >>size
    ;
: main ( -- )
    [   <editor>
        "Try copy and paste here, DELETE, UP, and C+s."
        over set-editor-string
        <main-gadget> "" open-window
        ]
    with-ui
    ;
MAIN: main

New Annotation

Summary:
Author:
Mode:
Body: