! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets USING: generic hashtables inspector io jedit kernel lists memory namespaces parser prettyprint sequences styles vectors words ; SYMBOL: commands global [ 100 commands set ] bind : define-command ( class name quot -- ) 3list commands get push ; : applicable ( object -- ) commands get >list [ car "predicate" word-prop call ] subset-with ; DEFER: pane-call : command-menu ( pane -- menu ) presented get dup applicable [ 3dup third [ [ swap literal, % ] make-list , , [ pane-call drop ] % ] make-list >r second r> cons ] map 2nip ; : init-commands ( gadget pane -- ) over presented paint-prop [ [ drop ] swap unit [ command-menu show-menu ] append3 button-gestures ] [ 2drop ] ifte ; : ( style text -- label )