factor/library/ui/presentations.factor

63 lines
2.2 KiB
Factor
Raw Normal View History

! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: gadgets-presentations
USING: arrays compiler gadgets gadgets-buttons gadgets-labels
2005-09-25 20:41:49 -04:00
gadgets-menus gadgets-outliner gadgets-panes generic hashtables
inference inspector io jedit kernel lists memory namespaces
2005-10-01 01:44:49 -04:00
parser prettyprint sequences strings styles 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 -- )
3array commands get push ;
2005-07-06 03:29:42 -04:00
: applicable ( object -- seq )
commands get [ first call ] subset-with ;
: command-quot ( presented quot -- quot )
2005-09-25 20:41:49 -04:00
[ \ drop , curry , [ pane get pane-call ] % ] [ ] make ;
: command-menu ( presented -- menu )
dup applicable
[ [ third command-quot ] keep second swons ] map-with
2005-09-24 23:21:09 -04:00
<menu> ;
2005-09-01 18:28:46 -04:00
2005-09-24 23:21:09 -04:00
: <command-button> ( gadget object -- button )
2005-10-08 01:15:14 -04:00
[ [ nip command-menu ] curry <menu-button> ] keep
summary over set-gadget-help ;
2005-09-24 23:21:09 -04:00
2005-08-26 21:42:43 -04:00
: init-commands ( gadget -- gadget )
2005-09-24 23:21:09 -04:00
dup presented paint-prop [ <command-button> ] when* ;
: <styled-label> ( style text -- label )
2005-10-07 20:26:21 -04:00
<label> dup rot dup [ alist>hash ] when add-paint ;
: <presentation> ( style text -- presentation )
gadget pick assoc dup
2005-09-25 20:41:49 -04:00
[ nip ] [ drop dupd <styled-label> init-commands ] if
outline rot assoc [ <outliner> ] when* ;
2005-07-13 18:08:54 -04:00
: gadget. ( gadget -- )
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-09-27 14:12:17 -04:00
[ drop t ] "Describe" [ describe ] define-command
2005-08-26 00:55:56 -04:00
[ 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
2005-09-27 14:12:17 -04:00
[ word? ] "Word call hierarchy" [ uses. ] define-command
[ word? ] "Word caller hierarchy" [ usage. ] define-command
2005-08-26 00:55:56 -04:00
[ 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
2005-09-08 22:23:54 -04:00
[ word? ] "Infer stack effect" [ unit infer . ] 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