Command framework
parent
ac44141c4a
commit
758ccb33fc
|
@ -1,5 +1,17 @@
|
||||||
+ 0.84:
|
+ 0.84:
|
||||||
|
|
||||||
|
new browser:
|
||||||
|
- show currently selected vocab & words
|
||||||
|
- scroll to existing won't work
|
||||||
|
- initial scroll dim is wrong
|
||||||
|
- show callers
|
||||||
|
|
||||||
|
listener:
|
||||||
|
- show IN:
|
||||||
|
|
||||||
|
- commands
|
||||||
|
- list of key bindings
|
||||||
|
|
||||||
- RT_WORD should refer to XTs not word objects.
|
- RT_WORD should refer to XTs not word objects.
|
||||||
- services do not launch if factor not running
|
- services do not launch if factor not running
|
||||||
- roundoff is still not quite right with tracks
|
- roundoff is still not quite right with tracks
|
||||||
|
@ -34,6 +46,7 @@
|
||||||
|
|
||||||
+ ui:
|
+ ui:
|
||||||
|
|
||||||
|
- closing walker should continue; clicking continue should close walker
|
||||||
- continuation handling in walker is screwy
|
- continuation handling in walker is screwy
|
||||||
- graphical module manager tool
|
- graphical module manager tool
|
||||||
- figure out what goes in the .app and what doesn't
|
- figure out what goes in the .app and what doesn't
|
||||||
|
@ -75,7 +88,6 @@
|
||||||
- TYPEDEF: float FTFloat ; ==> \ float \ FTFloat "c-type" swp
|
- TYPEDEF: float FTFloat ; ==> \ float \ FTFloat "c-type" swp
|
||||||
- make typedef aliasing explicit
|
- make typedef aliasing explicit
|
||||||
- seeing a C struct word should show its def
|
- seeing a C struct word should show its def
|
||||||
- TUPLE: module files tests articles article main ;
|
|
||||||
- file out
|
- file out
|
||||||
|
|
||||||
+ compiler/ffi:
|
+ compiler/ffi:
|
||||||
|
@ -105,6 +117,7 @@
|
||||||
|
|
||||||
+ misc:
|
+ misc:
|
||||||
|
|
||||||
|
- move jedit word to contrib
|
||||||
- growable data heap
|
- growable data heap
|
||||||
- incremental GC
|
- incremental GC
|
||||||
- UDP
|
- UDP
|
||||||
|
|
|
@ -188,6 +188,7 @@ sequences vectors words ;
|
||||||
"/library/ui/world.factor"
|
"/library/ui/world.factor"
|
||||||
"/library/ui/paint.factor"
|
"/library/ui/paint.factor"
|
||||||
"/library/ui/gestures.factor"
|
"/library/ui/gestures.factor"
|
||||||
|
"/library/ui/commands.factor"
|
||||||
"/library/ui/gadgets/controls.factor"
|
"/library/ui/gadgets/controls.factor"
|
||||||
"/library/ui/gadgets/grid-lines.factor"
|
"/library/ui/gadgets/grid-lines.factor"
|
||||||
"/library/ui/gadgets/theme.factor"
|
"/library/ui/gadgets/theme.factor"
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
IN: temporary
|
||||||
|
USING: gadgets test ;
|
||||||
|
|
||||||
|
[ "A+a" ] [ T{ key-down f { A+ } "a" } gesture>string ] unit-test
|
||||||
|
[ "b" ] [ T{ key-down f f "b" } gesture>string ] unit-test
|
||||||
|
[ "Mouse Down 2" ] [ T{ button-down f 2 } gesture>string ] unit-test
|
||||||
|
[ "Test (Mouse Down 2)" ]
|
||||||
|
[ T{ command f f "Test" T{ button-down f 2 } [ ] } command-string ] unit-test
|
|
@ -86,6 +86,7 @@ SYMBOL: failures
|
||||||
"gadgets/document"
|
"gadgets/document"
|
||||||
"gadgets/rectangles"
|
"gadgets/rectangles"
|
||||||
"gadgets/fields"
|
"gadgets/fields"
|
||||||
|
"gadgets/commands"
|
||||||
"generic"
|
"generic"
|
||||||
"help/porter-stemmer"
|
"help/porter-stemmer"
|
||||||
"help/topics"
|
"help/topics"
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
! Copyright (C) 2006 Slava Pestov.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
IN: gadgets
|
||||||
|
USING: kernel gadgets sequences strings math words generic
|
||||||
|
namespaces hashtables ;
|
||||||
|
|
||||||
|
TUPLE: command class group name gesture quot ;
|
||||||
|
|
||||||
|
GENERIC: gesture>string ( gesture -- string )
|
||||||
|
|
||||||
|
M: key-down gesture>string
|
||||||
|
dup key-down-mods [ word-name ] map concat >string
|
||||||
|
swap key-down-sym append ;
|
||||||
|
|
||||||
|
M: button-up gesture>string
|
||||||
|
"Mouse Up" swap button-up-#
|
||||||
|
[ " " swap number>string append3 ] when* ;
|
||||||
|
|
||||||
|
M: button-down gesture>string
|
||||||
|
"Mouse Down" swap button-down-#
|
||||||
|
[ " " swap number>string append3 ] when* ;
|
||||||
|
|
||||||
|
M: object gesture>string drop f ;
|
||||||
|
|
||||||
|
: command-string ( command -- string )
|
||||||
|
dup command-name swap command-gesture [
|
||||||
|
gesture>string [
|
||||||
|
[ swap % " (" % % ")" % ] "" make
|
||||||
|
] when*
|
||||||
|
] when* ;
|
||||||
|
|
||||||
|
: invoke-command ( gadget command -- )
|
||||||
|
dup command-class rot [ class over eq? ] find-parent nip
|
||||||
|
swap command-quot call ;
|
||||||
|
|
||||||
|
: add-command ( class command -- )
|
||||||
|
over "commands" word-prop
|
||||||
|
[ command-name over command-name = not ] subset
|
||||||
|
swap add "commands" set-word-prop ;
|
||||||
|
|
||||||
|
: define-commands ( class specs -- )
|
||||||
|
[ dupd first4 <command> ] map
|
||||||
|
2dup [ add-command ] each-with
|
||||||
|
[ command-gesture ] subset
|
||||||
|
[ dup command-gesture swap command-quot ] map>hash
|
||||||
|
"gestures" set-word-prop ;
|
||||||
|
|
||||||
|
: commands ( gadget -- seq )
|
||||||
|
delegates [ class "commands" word-prop ] map concat ;
|
||||||
|
|
||||||
|
world {
|
||||||
|
{ f "Cut" T{ key-down f { C+ } "x" } [ T{ cut-action } send-action ] }
|
||||||
|
{ f "Copy" T{ key-down f { C+ } "c" } [ T{ copy-action } send-action ] }
|
||||||
|
{ f "Paste" T{ key-down f { C+ } "v" } [ T{ paste-action } send-action ] }
|
||||||
|
{ f "Select all" T{ key-down f { C+ } "a" } [ T{ select-all-action } send-action ] }
|
||||||
|
} define-commands
|
|
@ -52,6 +52,11 @@ C: button ( gadget quot -- button )
|
||||||
: <bevel-button> ( gadget quot -- button )
|
: <bevel-button> ( gadget quot -- button )
|
||||||
<button> dup bevel-button-theme ;
|
<button> dup bevel-button-theme ;
|
||||||
|
|
||||||
|
: <command-button> ( command -- button )
|
||||||
|
dup command-string
|
||||||
|
swap [ invoke-command ] curry
|
||||||
|
<bevel-button> ;
|
||||||
|
|
||||||
: repeat-button-down ( button -- )
|
: repeat-button-down ( button -- )
|
||||||
dup 100 add-timer button-clicked ;
|
dup 100 add-timer button-clicked ;
|
||||||
|
|
||||||
|
|
|
@ -187,10 +187,3 @@ V{ } clone hand-buttons set-global
|
||||||
|
|
||||||
: send-action ( world gesture -- )
|
: send-action ( world gesture -- )
|
||||||
swap world-focus handle-gesture drop ;
|
swap world-focus handle-gesture drop ;
|
||||||
|
|
||||||
world H{
|
|
||||||
{ T{ key-down f { C+ } "x" } [ T{ cut-action } send-action ] }
|
|
||||||
{ T{ key-down f { C+ } "c" } [ T{ copy-action } send-action ] }
|
|
||||||
{ T{ key-down f { C+ } "v" } [ T{ paste-action } send-action ] }
|
|
||||||
{ T{ key-down f { C+ } "a" } [ T{ select-all-action } send-action ] }
|
|
||||||
} set-gestures
|
|
||||||
|
|
|
@ -137,17 +137,10 @@ C: browser-tracks ( browser -- browser-track )
|
||||||
browser-tabs dup length [ swap first 2array ] 2map
|
browser-tabs dup length [ swap first 2array ] 2map
|
||||||
<radio-box> ;
|
<radio-box> ;
|
||||||
|
|
||||||
: <browser-toolbar> ( browser -- toolbar )
|
|
||||||
[
|
|
||||||
<browser-tabs> ,
|
|
||||||
<spacing> ,
|
|
||||||
"Apropos" [ drop apropos-window ] <bevel-button> ,
|
|
||||||
] make-toolbar ;
|
|
||||||
|
|
||||||
C: browser ( -- browser )
|
C: browser ( -- browser )
|
||||||
0 <model> over set-browser-page
|
0 <model> over set-browser-page
|
||||||
dup dup {
|
dup dup {
|
||||||
{ [ <browser-toolbar> ] f f @top }
|
{ [ <browser-tabs> ] f f @top }
|
||||||
{ [ <browser-tracks> ] set-browser-track f @center }
|
{ [ <browser-tracks> ] set-browser-track f @center }
|
||||||
} make-frame* ;
|
} make-frame* ;
|
||||||
|
|
||||||
|
|
|
@ -13,25 +13,18 @@ TUPLE: help-gadget history ;
|
||||||
|
|
||||||
: go-home ( help -- ) "handbook" swap show-help ;
|
: go-home ( help -- ) "handbook" swap show-help ;
|
||||||
|
|
||||||
: find-help-gadget [ help-gadget? ] find-parent ;
|
help-gadget {
|
||||||
|
{ f "Back" T{ key-down f f "b" } [ help-gadget-history go-back ] }
|
||||||
: history-action find-help-gadget help-gadget-history ;
|
{ f "Forward" T{ key-down f f "f" } [ help-gadget-history go-forward ] }
|
||||||
|
{ f "Home" T{ key-down f f "h" } [ go-home ] }
|
||||||
: <help-toolbar> ( -- gadget )
|
} define-commands
|
||||||
[
|
|
||||||
"Back" [ history-action go-back ] <bevel-button> ,
|
|
||||||
"Forward" [ history-action go-forward ] <bevel-button> ,
|
|
||||||
"Home" [ find-help-gadget go-home ] <bevel-button> ,
|
|
||||||
<spacing> ,
|
|
||||||
"Search" [ drop search-help-window ] <bevel-button> ,
|
|
||||||
] make-toolbar ;
|
|
||||||
|
|
||||||
: <help-pane> ( -- gadget )
|
: <help-pane> ( -- gadget )
|
||||||
gadget get help-gadget-history [ help ] <pane-control> ;
|
gadget get help-gadget-history [ help ] <pane-control> ;
|
||||||
|
|
||||||
C: help-gadget ( -- gadget )
|
C: help-gadget ( -- gadget )
|
||||||
f <history> over set-help-gadget-history {
|
f <history> over set-help-gadget-history {
|
||||||
{ [ <help-toolbar> ] f f @top }
|
{ [ gadget get <toolbar> ] f f @top }
|
||||||
{ [ <help-pane> <scroller> ] f f @center }
|
{ [ <help-pane> <scroller> ] f f @center }
|
||||||
} make-frame* ;
|
} make-frame* ;
|
||||||
|
|
||||||
|
@ -39,12 +32,8 @@ M: help-gadget gadget-title
|
||||||
help-gadget-history
|
help-gadget-history
|
||||||
[ "Help - " swap article-title append ] <filter> ;
|
[ "Help - " swap article-title append ] <filter> ;
|
||||||
|
|
||||||
M: help-gadget pref-dim*
|
M: help-gadget pref-dim* drop { 500 600 } ;
|
||||||
drop { 500 600 } ;
|
|
||||||
|
|
||||||
: help-tool
|
: help-tool [ help-gadget? ] [ <help-gadget> ] [ show-help ] ;
|
||||||
[ help-gadget? ]
|
|
||||||
[ <help-gadget> ]
|
|
||||||
[ show-help ] ;
|
|
||||||
|
|
||||||
M: link show help-tool call-tool ;
|
M: link show help-tool call-tool ;
|
||||||
|
|
|
@ -1,40 +1,28 @@
|
||||||
! Copyright (C) 2006 Slava Pestov
|
! Copyright (C) 2006 Slava Pestov
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: gadgets-launchpad
|
IN: gadgets
|
||||||
USING: gadgets gadgets-borders gadgets-browser
|
USING: gadgets-presentations memory io gadgets-panes
|
||||||
gadgets-buttons gadgets-labels gadgets-listener gadgets-panes
|
gadgets-scrolling namespaces help kernel gadgets-listener
|
||||||
gadgets-presentations gadgets-scrolling gadgets-search
|
gadgets-browser ;
|
||||||
gadgets-theme generic help inspector io kernel memory namespaces
|
|
||||||
prettyprint sequences words ;
|
|
||||||
|
|
||||||
: <launchpad> ( menu -- )
|
|
||||||
[ first2 [ drop ] append <bevel-button> ] map make-pile
|
|
||||||
1 over set-pack-fill
|
|
||||||
{ 5 5 } over set-pack-gap
|
|
||||||
<default-border> dup highlight-theme ;
|
|
||||||
|
|
||||||
: pane-window ( quot title -- )
|
|
||||||
>r make-pane <scroller> r> open-titled-window ;
|
|
||||||
|
|
||||||
: handbook-window ( -- )
|
: handbook-window ( -- )
|
||||||
T{ link f "handbook" } show ;
|
T{ link f "handbook" } show ;
|
||||||
|
|
||||||
: memory-window ( -- )
|
: memory-window ( -- )
|
||||||
[ heap-stats. terpri room. ] "Memory" pane-window ;
|
[ heap-stats. terpri room. ] make-pane <scroller>
|
||||||
|
"Memory" open-titled-window ;
|
||||||
|
|
||||||
: globals-window ( -- )
|
: globals-window ( -- )
|
||||||
global show ;
|
global show ;
|
||||||
|
|
||||||
: default-launchpad
|
world {
|
||||||
{
|
{ f "Listener" f [ drop listener-window ] }
|
||||||
{ "Listener" [ listener-window ] }
|
{ f "Browser" f [ drop browser-window ] }
|
||||||
{ "Browser" [ browser-window ] }
|
{ f "Apropos" f [ drop apropos-window ] }
|
||||||
{ "Documentation" [ handbook-window ] }
|
{ f "Help" f [ drop handbook-window ] }
|
||||||
{ "Globals" [ globals-window ] }
|
{ f "Search Help" f [ drop search-help-window ] }
|
||||||
{ "Memory" [ memory-window ] }
|
{ f "Globals" f [ drop globals-window ] }
|
||||||
{ "Save image" [ save ] }
|
{ f "Memory" f [ drop memory-window ] }
|
||||||
{ "Exit" [ 0 exit ] }
|
{ f "Save image" f [ drop save ] }
|
||||||
} <launchpad> ;
|
{ f "Exit" f [ drop 0 exit ] }
|
||||||
|
} define-commands
|
||||||
: launchpad-window ( -- )
|
|
||||||
default-launchpad open-window ;
|
|
||||||
|
|
|
@ -45,15 +45,13 @@ namespaces sequences shells threads vectors ;
|
||||||
|
|
||||||
TUPLE: walker-gadget model quot ns ;
|
TUPLE: walker-gadget model quot ns ;
|
||||||
|
|
||||||
: find-walker-gadget [ walker-gadget? ] find-parent ;
|
|
||||||
|
|
||||||
: update-stacks ( walker -- )
|
: update-stacks ( walker -- )
|
||||||
meta-interp get over walker-gadget-model set-model
|
meta-interp get over walker-gadget-model set-model
|
||||||
meta-callframe swap walker-gadget-quot set-model ;
|
meta-callframe swap walker-gadget-quot set-model ;
|
||||||
|
|
||||||
: with-walker ( gadget quot -- )
|
: with-walker ( gadget quot -- )
|
||||||
swap find-walker-gadget
|
swap dup walker-gadget-ns
|
||||||
dup walker-gadget-ns [ slip update-stacks ] bind ; inline
|
[ slip update-stacks ] bind ; inline
|
||||||
|
|
||||||
: walker-step [ step ] with-walker ;
|
: walker-step [ step ] with-walker ;
|
||||||
: walker-step-in [ step-in ] with-walker ;
|
: walker-step-in [ step-in ] with-walker ;
|
||||||
|
@ -61,14 +59,13 @@ TUPLE: walker-gadget model quot ns ;
|
||||||
: walker-step-all [ step-all ] with-walker ;
|
: walker-step-all [ step-all ] with-walker ;
|
||||||
: walker-step-back [ step-back ] with-walker ;
|
: walker-step-back [ step-back ] with-walker ;
|
||||||
|
|
||||||
: <walker-toolbar> ( -- gadget )
|
walker-gadget {
|
||||||
[
|
{ f "Step" T{ key-down f f "s" } [ walker-step ] }
|
||||||
"Step" [ walker-step ] <bevel-button> ,
|
{ f "Step in" T{ key-down f f "i" } [ walker-step-in ] }
|
||||||
"Step in" [ walker-step-in ] <bevel-button> ,
|
{ f "Step out" T{ key-down f f "o" } [ walker-step-out ] }
|
||||||
"Step out" [ walker-step-out ] <bevel-button> ,
|
{ f "Step back" T{ key-down f f "b" } [ walker-step-back ] }
|
||||||
"Continue" [ walker-step-all ] <bevel-button> ,
|
{ f "Continue" T{ key-down f f "c" } [ walker-step-all ] }
|
||||||
"Step back" [ walker-step-back ] <bevel-button> ,
|
} define-commands
|
||||||
] make-toolbar ;
|
|
||||||
|
|
||||||
: init-walker-models ( walker -- )
|
: init-walker-models ( walker -- )
|
||||||
f <model> over set-walker-gadget-model
|
f <model> over set-walker-gadget-model
|
||||||
|
@ -93,18 +90,10 @@ M: walker-gadget pref-dim*
|
||||||
|
|
||||||
C: walker-gadget ( -- gadget )
|
C: walker-gadget ( -- gadget )
|
||||||
dup init-walker-models {
|
dup init-walker-models {
|
||||||
{ [ <walker-toolbar> ] f f @top }
|
{ [ gadget get <toolbar> ] f f @top }
|
||||||
{ [ walker-models <walker-track> ] f f @center }
|
{ [ walker-models <walker-track> ] f f @center }
|
||||||
} make-frame* ;
|
} make-frame* ;
|
||||||
|
|
||||||
\ walker-gadget H{
|
|
||||||
{ T{ key-down f f "s" } [ walker-step ] }
|
|
||||||
{ T{ key-down f f "i" } [ walker-step-in ] }
|
|
||||||
{ T{ key-down f f "o" } [ walker-step-out ] }
|
|
||||||
{ T{ key-down f f "a" } [ walker-step-all ] }
|
|
||||||
{ T{ key-down f f "b" } [ walker-step-back ] }
|
|
||||||
} set-gestures
|
|
||||||
|
|
||||||
: walk ( quot -- )
|
: walk ( quot -- )
|
||||||
continuation dup continuation-data pop*
|
continuation dup continuation-data pop*
|
||||||
<walker-gadget> [ (walk) ] keep open-window stop ;
|
<walker-gadget> [ (walk) ] keep open-window stop ;
|
||||||
|
|
|
@ -138,8 +138,8 @@ C: titled-gadget ( gadget title -- )
|
||||||
: restore-windows? ( -- ? )
|
: restore-windows? ( -- ? )
|
||||||
windows get [ empty? not ] [ f ] if* ;
|
windows get [ empty? not ] [ f ] if* ;
|
||||||
|
|
||||||
: make-toolbar ( quot -- gadget )
|
: <toolbar> ( gadget -- toolbar )
|
||||||
{ } make make-shelf dup highlight-theme ; inline
|
commands [ <command-button> ] map make-shelf ;
|
||||||
|
|
||||||
: error-window ( error -- )
|
: error-window ( error -- )
|
||||||
[ print-error ] make-pane "Error" open-titled-window ;
|
[ print-error ] make-pane "Error" open-titled-window ;
|
||||||
|
|
Loading…
Reference in New Issue