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
|
2005-09-11 20:46:55 -04:00
|
|
|
USING: arrays compiler gadgets gadgets-buttons gadgets-labels
|
2005-10-09 21:27:14 -04:00
|
|
|
gadgets-menus gadgets-outliner gadgets-panes gadgets-theme
|
|
|
|
generic hashtables inference inspector io jedit kernel lists
|
|
|
|
memory namespaces parser prettyprint sequences strings styles
|
|
|
|
words ;
|
2005-07-06 03:29:42 -04:00
|
|
|
|
|
|
|
SYMBOL: commands
|
|
|
|
|
2005-10-29 23:25:38 -04:00
|
|
|
V{ } clone commands global set-hash
|
2005-07-06 03:29:42 -04:00
|
|
|
|
|
|
|
: define-command ( class name quot -- )
|
2005-09-11 20:46:55 -04:00
|
|
|
3array 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-09-25 20:41:49 -04:00
|
|
|
[ \ drop , curry , [ pane get pane-call ] % ] [ ] make ;
|
2005-07-13 22:51:43 -04:00
|
|
|
|
2005-10-09 21:27:14 -04:00
|
|
|
TUPLE: command-button object ;
|
2005-09-01 18:28:46 -04:00
|
|
|
|
2005-10-09 21:27:14 -04:00
|
|
|
: command-menu ( command-button -- )
|
|
|
|
command-button-object dup applicable
|
|
|
|
[ [ third command-quot ] keep second swons ] map-with
|
|
|
|
<menu> show-hand-menu ;
|
|
|
|
|
|
|
|
C: command-button ( gadget object -- button )
|
2005-10-25 21:52:26 -04:00
|
|
|
[
|
|
|
|
set-command-button-object
|
|
|
|
[ command-menu ] <roll-button>
|
|
|
|
] keep
|
2005-10-09 21:27:14 -04:00
|
|
|
[ set-gadget-delegate ] keep
|
|
|
|
dup menu-button-actions ;
|
|
|
|
|
|
|
|
M: command-button gadget-help ( button -- string )
|
2005-10-25 21:52:26 -04:00
|
|
|
command-button-object dup word? [ synopsis ] [ summary ] if ;
|
2005-09-24 23:21:09 -04:00
|
|
|
|
2005-10-28 21:13:41 -04:00
|
|
|
: init-commands ( style gadget -- gadget )
|
|
|
|
presented rot assoc [ <command-button> ] when* ;
|
|
|
|
|
|
|
|
: style-font ( style -- font )
|
|
|
|
[ font swap assoc [ "Monospaced" ] unless* ] keep
|
|
|
|
[ font-style swap assoc [ plain ] unless* ] keep
|
|
|
|
font-size swap assoc [ 12 ] unless* 3array ;
|
2005-06-27 16:50:21 -04:00
|
|
|
|
|
|
|
: <styled-label> ( style text -- label )
|
2005-10-29 16:53:47 -04:00
|
|
|
<label> foreground pick assoc [ over set-label-color ] when*
|
2005-10-28 21:13:41 -04:00
|
|
|
swap style-font over set-label-font ;
|
2005-06-29 00:33:07 -04:00
|
|
|
|
2005-07-13 22:51:43 -04:00
|
|
|
: <presentation> ( style text -- presentation )
|
2005-10-28 21:13:41 -04:00
|
|
|
gadget pick assoc
|
|
|
|
[ ] [ >r dup dup r> <styled-label> init-commands ] ?if
|
2005-09-25 20:41:49 -04:00
|
|
|
outline rot assoc [ <outliner> ] when* ;
|
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-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
|