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 -- )
|
|
|
|
3list commands get push ;
|
|
|
|
|
|
|
|
: applicable ( object -- )
|
|
|
|
commands get >list
|
|
|
|
[ car "predicate" word-prop call ] subset-with ;
|
2005-06-27 16:50:21 -04:00
|
|
|
|
2005-07-07 20:17:34 -04:00
|
|
|
DEFER: pane-call
|
2005-06-29 19:40:44 -04:00
|
|
|
|
2005-07-06 03:29:42 -04:00
|
|
|
: command-menu ( pane -- menu )
|
|
|
|
presented get dup applicable [
|
|
|
|
3dup third [
|
2005-07-09 18:32:31 -04:00
|
|
|
[ swap literal, % ] make-list , ,
|
|
|
|
[ pane-call drop ] %
|
2005-07-06 03:29:42 -04:00
|
|
|
] make-list >r second r> cons
|
|
|
|
] map 2nip ;
|
2005-06-27 16:50:21 -04:00
|
|
|
|
2005-07-06 03:29:42 -04:00
|
|
|
: init-commands ( gadget pane -- )
|
2005-07-09 18:32:31 -04:00
|
|
|
over presented paint-prop [
|
|
|
|
[ drop ] swap
|
|
|
|
unit
|
|
|
|
[ command-menu <menu> show-menu ] append3
|
|
|
|
button-gestures
|
|
|
|
] [
|
|
|
|
2drop
|
|
|
|
] ifte ;
|
2005-06-27 16:50:21 -04:00
|
|
|
|
|
|
|
: <styled-label> ( style text -- label )
|
2005-06-29 00:33:07 -04:00
|
|
|
<label> swap alist>hash over set-gadget-paint ;
|
|
|
|
|
|
|
|
: <presentation> ( style text pane -- presentation )
|
2005-07-06 03:29:42 -04:00
|
|
|
>r <styled-label> dup r> init-commands ;
|
|
|
|
|
|
|
|
object "Prettyprint" [ prettyprint ] define-command
|
|
|
|
object "Inspect" [ inspect ] define-command
|
|
|
|
object "References" [ references inspect ] define-command
|
|
|
|
|
|
|
|
\ word "See" [ see ] define-command
|
|
|
|
\ word "Execute" [ execute ] define-command
|
|
|
|
\ word "Usage" [ usage . ] define-command
|
|
|
|
\ word "jEdit" [ jedit ] define-command
|