2006-09-14 16:15:39 -04:00
|
|
|
! Copyright (C) 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
IN: gadgets-workspace
|
|
|
|
USING: definitions gadgets gadgets-browser gadgets-dataflow
|
|
|
|
gadgets-help gadgets-listener gadgets-text gadgets-workspace
|
|
|
|
hashtables help inference kernel namespaces parser prettyprint
|
|
|
|
scratchpad sequences strings styles syntax test tools words
|
2006-10-06 04:15:34 -04:00
|
|
|
generic models io ;
|
2006-09-14 16:15:39 -04:00
|
|
|
|
|
|
|
V{ } clone operations set-global
|
|
|
|
|
|
|
|
: define-operation ( class props -- )
|
|
|
|
<operation> operations get push-new ;
|
|
|
|
|
|
|
|
M: operation invoke-command ( target operation -- )
|
|
|
|
dup command-quot swap operation-listener?
|
2006-10-04 00:40:10 -04:00
|
|
|
[ curry call-listener ] [ call ] if ;
|
2006-09-14 16:15:39 -04:00
|
|
|
|
|
|
|
: modify-listener-operation ( quot operation -- operation )
|
|
|
|
clone t over set-operation-listener?
|
|
|
|
modify-operation ;
|
|
|
|
|
2006-09-20 03:22:26 -04:00
|
|
|
: modify-listener-operations ( operations quot -- operations )
|
|
|
|
swap [ modify-listener-operation ] map-with ;
|
2006-09-14 16:15:39 -04:00
|
|
|
|
|
|
|
! Objects
|
|
|
|
[ drop t ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 1 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Inspect" }
|
|
|
|
{ +quot+ [ inspect ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-20 03:22:26 -04:00
|
|
|
[ drop t ] H{
|
|
|
|
{ +mouse+ T{ button-up f { S+ } 1 } }
|
|
|
|
{ +name+ "Push" }
|
|
|
|
{ +quot+ [ ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-20 22:31:17 -04:00
|
|
|
! Commands
|
|
|
|
[ [ command? ] is? ] H{
|
|
|
|
{ +mouse+ T{ button-up f { S+ } 3 } }
|
|
|
|
{ +name+ "Inspect" }
|
|
|
|
{ +quot+ [ inspect ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-14 16:15:39 -04:00
|
|
|
! Input
|
|
|
|
[ input? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 1 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Input" }
|
|
|
|
{ +quot+ [ listener-gadget call-tool ] }
|
|
|
|
} define-operation
|
|
|
|
|
2006-10-06 04:15:34 -04:00
|
|
|
! Pathnames
|
|
|
|
[ pathname? ] H{
|
|
|
|
{ +mouse+ T{ button-up f f 1 } }
|
|
|
|
{ +name+ "Edit" }
|
|
|
|
{ +quot+ [ edit-file ] }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ pathname? ] H{
|
|
|
|
{ +mouse+ T{ button-up f f 2 } }
|
|
|
|
{ +name+ "Run file" }
|
|
|
|
{ +quot+ [ listener-gadget call-tool ] }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-14 16:15:39 -04:00
|
|
|
! Words
|
|
|
|
[ word? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 1 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Browse" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { A+ } "b" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ browser call-tool ] }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ word? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 2 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Edit" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { A+ } "e" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ edit ] }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ word? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 3 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Documentation" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { A+ } "h" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ help-gadget call-tool ] }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ word? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f { S+ } 3 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Usage" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { A+ } "u" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ usage. ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ word? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f { S+ } 2 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Reload" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { A+ } "r" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ reload ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ word? ] H{
|
|
|
|
{ +name+ "Watch" }
|
|
|
|
{ +quot+ [ watch ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-30 00:03:46 -04:00
|
|
|
[ word? ] H{
|
|
|
|
{ +name+ "Word dataflow" }
|
|
|
|
{ +keyboard+ T{ key-down f { A+ } "d" } }
|
|
|
|
{ +quot+ [ word-def show-dataflow ] }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-14 16:15:39 -04:00
|
|
|
! Vocabularies
|
|
|
|
[ vocab-link? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 1 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Browse" }
|
|
|
|
{ +quot+ [ browser call-tool ] }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
! Link
|
|
|
|
[ link? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 1 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Follow" }
|
|
|
|
{ +quot+ [ help-gadget call-tool ] }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ link? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 2 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Edit" }
|
|
|
|
{ +quot+ [ edit ] }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-19 02:53:14 -04:00
|
|
|
[ link? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f { S+ } 2 } }
|
2006-09-19 02:53:14 -04:00
|
|
|
{ +name+ "Reload" }
|
|
|
|
{ +quot+ [ reload ] }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-14 16:15:39 -04:00
|
|
|
[ word-link? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 3 } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +name+ "Definition" }
|
|
|
|
{ +quot+ [ link-name browser call-tool ] }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
! Quotations
|
|
|
|
[ quotation? ] H{
|
|
|
|
{ +name+ "Infer" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { C+ A+ } "i" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ infer . ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ quotation? ] H{
|
2006-09-30 00:03:46 -04:00
|
|
|
{ +name+ "Quotation dataflow" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { C+ A+ } "d" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ show-dataflow ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ quotation? ] H{
|
|
|
|
{ +name+ "Walk" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { C+ A+ } "w" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ walk ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
[ quotation? ] H{
|
|
|
|
{ +name+ "Time" }
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +keyboard+ T{ key-down f { C+ A+ } "t" } }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ time ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
|
|
|
! Dataflow nodes
|
|
|
|
|
|
|
|
[ [ node? ] is? ] H{
|
2006-09-20 03:22:26 -04:00
|
|
|
{ +mouse+ T{ button-up f f 1 } }
|
2006-09-30 00:03:46 -04:00
|
|
|
{ +name+ "Show dataflow" }
|
2006-09-14 16:15:39 -04:00
|
|
|
{ +quot+ [ dataflow-gadget call-tool ] }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-30 00:03:46 -04:00
|
|
|
[ [ node? ] is? ] H{
|
|
|
|
{ +mouse+ T{ button-up f { S+ } 3 } }
|
|
|
|
{ +name+ "Inspect" }
|
|
|
|
{ +quot+ [ inspect ] }
|
|
|
|
{ +listener+ t }
|
|
|
|
} define-operation
|
|
|
|
|
2006-09-14 16:15:39 -04:00
|
|
|
! Define commands in terms of operations
|
|
|
|
|
|
|
|
! Tile commands
|
2006-09-20 03:22:26 -04:00
|
|
|
tile "Word commands"
|
|
|
|
\ word class-operations [ tile-definition ] modify-operations
|
2006-09-14 16:15:39 -04:00
|
|
|
[ command-name "Browse" = not ] subset
|
2006-09-20 03:22:26 -04:00
|
|
|
define-commands
|
2006-09-14 16:15:39 -04:00
|
|
|
|
|
|
|
! Interactor commands
|
|
|
|
: word-action ( target -- quot )
|
2006-09-20 03:22:26 -04:00
|
|
|
selected-word search ;
|
|
|
|
|
|
|
|
: quot-action ( interactor -- quot )
|
2006-10-06 04:15:34 -04:00
|
|
|
dup editor-text swap select-all parse ;
|
2006-09-20 03:22:26 -04:00
|
|
|
|
|
|
|
interactor "Word commands"
|
|
|
|
\ word class-operations
|
|
|
|
[ word-action ] modify-listener-operations
|
|
|
|
define-commands
|
|
|
|
|
|
|
|
interactor "Quotation commands"
|
|
|
|
quotation class-operations
|
|
|
|
[ quot-action ] modify-listener-operations
|
|
|
|
define-commands
|