! 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 -- list ) commands get >list [ car call ] subset-with ; : command-quot ( presented quot -- quot ) [ swap literal, % ] make-list [ pane get pane-call drop ] cons ; : command-menu ( presented -- menu ) dup applicable [ [ third command-quot ] keep second swons ] map-with ; : init-commands ( gadget -- ) dup presented paint-prop dup [ [ \ drop , literal, [ command-menu show-menu ] % ] make-list button-gestures ] [ 2drop ] ifte ; : ( style text -- label )