2005-06-27 16:50:21 -04:00
|
|
|
! Copyright (C) 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
|
|
|
IN: gadgets
|
2005-07-06 03:29:42 -04:00
|
|
|
USING: generic hashtables inspector io jedit kernel lists memory
|
|
|
|
namespaces parser prettyprint sequences styles vectors words ;
|
|
|
|
|
|
|
|
SYMBOL: commands
|
|
|
|
|
|
|
|
global [ 100 <vector> commands set ] bind
|
|
|
|
|
|
|
|
: define-command ( class name quot -- )
|
2005-07-27 20:13:11 -04:00
|
|
|
3vector commands get push ;
|
2005-07-06 03:29:42 -04:00
|
|
|
|
2005-07-22 23:21:50 -04:00
|
|
|
: applicable ( object -- seq )
|
2005-07-27 20:13:11 -04:00
|
|
|
commands get [ first call ] subset-with ;
|
2005-07-13 22:51:43 -04:00
|
|
|
|
|
|
|
: command-quot ( presented quot -- quot )
|
2005-08-03 23:56:28 -04:00
|
|
|
[ swap literalize , % ] make-list
|
2005-07-13 22:51:43 -04:00
|
|
|
[ pane get pane-call drop ] cons ;
|
|
|
|
|
|
|
|
: command-menu ( presented -- menu )
|
|
|
|
dup applicable
|
|
|
|
[ [ third command-quot ] keep second swons ] map-with
|
|
|
|
<menu> ;
|
|
|
|
|
|
|
|
: init-commands ( gadget -- )
|
|
|
|
dup presented paint-prop dup [
|
|
|
|
[
|
|
|
|
\ drop ,
|
|
|
|
literal,
|
|
|
|
[ command-menu show-menu ] %
|
|
|
|
] make-list
|
2005-07-09 18:32:31 -04:00
|
|
|
button-gestures
|
|
|
|
] [
|
|
|
|
2drop
|
|
|
|
] ifte ;
|
2005-06-27 16:50:21 -04:00
|
|
|
|
|
|
|
: <styled-label> ( style text -- label )
|
2005-07-13 22:51:43 -04:00
|
|
|
<label> swap dup [ alist>hash ] when over set-gadget-paint ;
|
2005-06-29 00:33:07 -04:00
|
|
|
|
2005-07-13 22:51:43 -04:00
|
|
|
: <presentation> ( style text -- presentation )
|
|
|
|
gadget pick assoc dup
|
|
|
|
[ 2nip ] [ drop <styled-label> dup init-commands ] ifte ;
|
2005-07-13 18:08:54 -04:00
|
|
|
|
|
|
|
: gadget. ( gadget -- )
|
2005-07-20 18:04:29 -04:00
|
|
|
gadget swons unit
|
|
|
|
"This stream does not support live gadgets"
|
2005-07-21 23:37:08 -04:00
|
|
|
swap format terpri ;
|
2005-07-13 18:08:54 -04:00
|
|
|
|
|
|
|
[ drop t ] "Prettyprint" [ prettyprint ] define-command
|
|
|
|
[ drop t ] "Inspect" [ inspect ] define-command
|
|
|
|
[ drop t ] "References" [ references inspect ] define-command
|
2005-07-06 03:29:42 -04:00
|
|
|
|
2005-07-13 18:08:54 -04:00
|
|
|
[ word? ] "See" [ see ] define-command
|
|
|
|
[ word? ] "Usage" [ usage . ] define-command
|
|
|
|
[ word? ] "jEdit" [ jedit ] define-command
|
2005-07-06 03:29:42 -04:00
|
|
|
|
2005-07-14 00:32:52 -04:00
|
|
|
[ [ gadget? ] is? ] "Display" [ gadget. ] define-command
|