2008-02-21 00:13:31 -05:00
|
|
|
! Copyright (C) 2006, 2008 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-02-21 00:13:31 -05:00
|
|
|
USING: kernel concurrency.messaging inspector ui.tools.listener
|
|
|
|
ui.tools.traceback ui.gadgets.buttons ui.gadgets.status-bar
|
|
|
|
ui.gadgets.tracks ui.commands ui.gadgets models
|
|
|
|
ui.tools.workspace ui.gestures ui.gadgets.labels ui threads
|
|
|
|
namespaces tools.walker assocs ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: ui.tools.walker
|
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
TUPLE: walker-gadget status continuation thread ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: walker-command ( walker msg -- )
|
|
|
|
over walker-gadget-thread thread-registered?
|
|
|
|
[ swap walker-gadget-thread send-synchronous drop ]
|
|
|
|
[ 2drop ] if ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: com-step ( walker -- ) step walker-command ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: com-into ( walker -- ) step-into walker-command ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: com-out ( walker -- ) step-out walker-command ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: com-back ( walker -- ) step-back walker-command ;
|
2008-02-09 15:17:40 -05:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: com-continue ( walker -- ) step-all walker-command ;
|
2007-10-04 18:45:19 -04:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: com-abandon ( walker -- ) abandon walker-command ;
|
2007-10-04 18:45:19 -04:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: com-inspect ( walker -- )
|
|
|
|
walker-continuation model-value
|
|
|
|
[ inspect ] curry call-listener ;
|
|
|
|
|
|
|
|
M: walker-gadget ungraft*
|
|
|
|
dup delegate ungraft* detach walker-command ;
|
|
|
|
|
|
|
|
: walker-state-string ( status thread -- string )
|
|
|
|
[
|
|
|
|
"Thread: " %
|
|
|
|
dup thread-name %
|
|
|
|
" (" %
|
|
|
|
swap {
|
|
|
|
{ +stopped+ "Stopped" }
|
|
|
|
{ +suspended+ "Suspended" }
|
|
|
|
{ +running+ "Running" }
|
|
|
|
{ +detached+ "Detached" }
|
|
|
|
} at %
|
|
|
|
")" %
|
|
|
|
drop
|
|
|
|
] "" make ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: <thread-status> ( model thread -- gadget )
|
|
|
|
[ walker-state-string ] curry <filter> <label-control> ;
|
2007-11-16 03:01:45 -05:00
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: <walker-gadget> ( status continuation thread -- gadget )
|
|
|
|
walker-gadget construct-boa [
|
2007-09-20 18:09:08 -04:00
|
|
|
toolbar,
|
2008-02-21 00:13:31 -05:00
|
|
|
g walker-gadget-status self <thread-status> f track,
|
|
|
|
g walker-gadget-continuation <traceback-gadget> 1 track,
|
2007-11-16 03:01:45 -05:00
|
|
|
] { 0 1 } build-track ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: walker-help "ui-walker" help-window ;
|
|
|
|
|
|
|
|
\ walker-help H{ { +nullary+ t } } define-command
|
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
walker-gadget "toolbar" f {
|
|
|
|
{ T{ key-down f f "s" } com-step }
|
|
|
|
{ T{ key-down f f "i" } com-into }
|
|
|
|
{ T{ key-down f f "o" } com-out }
|
|
|
|
{ T{ key-down f f "b" } com-back }
|
|
|
|
{ T{ key-down f f "c" } com-continue }
|
|
|
|
{ T{ key-down f f "a" } com-abandon }
|
2007-09-20 18:09:08 -04:00
|
|
|
{ T{ key-down f f "F1" } walker-help }
|
|
|
|
} define-command-map
|
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
walker-gadget "other" f {
|
|
|
|
{ T{ key-down f f "n" } com-inspect }
|
|
|
|
{ T{ key-down f f "d" } close-window }
|
2007-09-20 18:09:08 -04:00
|
|
|
} define-command-map
|
|
|
|
|
2008-02-21 00:13:31 -05:00
|
|
|
: walker-window ( -- )
|
|
|
|
f <model> f <model> 2dup start-walker-thread
|
|
|
|
[ <walker-gadget> ] keep thread-name open-status-window ;
|
|
|
|
|
|
|
|
[ [ walker-window ] with-ui ] new-walker-hook set-global
|
|
|
|
|
|
|
|
[
|
|
|
|
[
|
|
|
|
>r dup walker-gadget?
|
|
|
|
[ walker-gadget-thread r> eq? ]
|
|
|
|
[ r> 2drop f ] if
|
|
|
|
] curry find-window raise-window
|
|
|
|
] show-walker-hook set-global
|