2005-06-27 16:50:21 -04:00
|
|
|
! Copyright (C) 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2005-08-31 21:06:13 -04:00
|
|
|
IN: gadgets-presentations
|
|
|
|
USING: compiler gadgets gadgets-buttons gadgets-labels
|
|
|
|
gadgets-menus gadgets-panes generic hashtables inference
|
|
|
|
inspector io jedit kernel lists memory namespaces parser
|
|
|
|
prettyprint sequences styles vectors words ;
|
2005-07-06 03:29:42 -04:00
|
|
|
|
|
|
|
SYMBOL: commands
|
|
|
|
|
2005-08-25 15:27:38 -04:00
|
|
|
{ } clone commands global set-hash
|
2005-07-06 03:29:42 -04:00
|
|
|
|
|
|
|
: 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-26 00:55:56 -04:00
|
|
|
[
|
|
|
|
[ swap literalize , % ] [ ] make ,
|
|
|
|
[ pane get pane-call ] %
|
|
|
|
] [ ] make ;
|
2005-07-13 22:51:43 -04:00
|
|
|
|
|
|
|
: command-menu ( presented -- menu )
|
|
|
|
dup applicable
|
|
|
|
[ [ third command-quot ] keep second swons ] map-with
|
|
|
|
<menu> ;
|
|
|
|
|
2005-08-26 21:42:43 -04:00
|
|
|
: init-commands ( gadget -- gadget )
|
|
|
|
dup presented paint-prop [
|
2005-07-13 22:51:43 -04:00
|
|
|
[
|
|
|
|
\ drop ,
|
2005-08-04 00:48:07 -04:00
|
|
|
literalize ,
|
2005-07-13 22:51:43 -04:00
|
|
|
[ command-menu show-menu ] %
|
2005-08-25 15:27:38 -04:00
|
|
|
] [ ] make
|
2005-08-26 21:42:43 -04:00
|
|
|
<roll-button>
|
|
|
|
] when* ;
|
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
|
2005-08-26 21:42:43 -04:00
|
|
|
[ 2nip ] [ drop <styled-label> init-commands ] ifte ;
|
2005-07-13 18:08:54 -04:00
|
|
|
|
2005-08-31 21:06:13 -04:00
|
|
|
: <object-presentation> ( object -- gadget )
|
|
|
|
dup presented swons unit swap unparse-short <presentation> ;
|
|
|
|
|
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
|
|
|
|
2005-08-21 14:40:12 -04:00
|
|
|
[ drop t ] "Prettyprint" [ . ] define-command
|
2005-07-13 18:08:54 -04:00
|
|
|
[ drop t ] "Inspect" [ inspect ] define-command
|
2005-08-26 00:55:56 -04:00
|
|
|
[ drop t ] "Inspect variable" [ get inspect ] define-command
|
|
|
|
[ drop t ] "Inspect references" [ references inspect ] define-command
|
|
|
|
[ drop t ] "Push on data stack" [ ] define-command
|
2005-07-06 03:29:42 -04:00
|
|
|
|
2005-08-26 00:55:56 -04:00
|
|
|
[ word? ] "See word" [ see ] define-command
|
|
|
|
[ word? ] "Word usage" [ usage . ] define-command
|
|
|
|
[ word? ] "Open in jEdit" [ jedit ] define-command
|
|
|
|
[ word? ] "Reload original source" [ reload ] define-command
|
|
|
|
[ compound? ] "Annotate with watchpoint" [ watch ] define-command
|
|
|
|
[ compound? ] "Annotate with breakpoint" [ break ] define-command
|
|
|
|
[ compound? ] "Annotate with profiling" [ profile ] define-command
|
|
|
|
[ word? ] "Compile" [ recompile ] define-command
|
|
|
|
[ word? ] "Show stack effect" [ unit infer . ] define-command
|
|
|
|
[ word? ] "Show dataflow IR" [ word-def t dataflow. ] define-command
|
|
|
|
[ word? ] "Show linear IR" [ precompile ] define-command
|
2005-07-06 03:29:42 -04:00
|
|
|
|
2005-08-26 00:55:56 -04:00
|
|
|
[ [ gadget? ] is? ] "Display gadget" [ gadget. ] define-command
|