2009-01-07 16:06:43 -05:00
|
|
|
! Copyright (C) 2006, 2009 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-02-09 01:25:05 -05:00
|
|
|
USING: accessors continuations kernel models namespaces arrays
|
2009-02-14 20:48:32 -05:00
|
|
|
fry prettyprint ui ui.commands ui.gadgets ui.gadgets.labeled assocs
|
2009-01-07 16:06:43 -05:00
|
|
|
ui.gadgets.tracks ui.gadgets.buttons ui.gadgets.panes
|
2009-02-14 01:45:10 -05:00
|
|
|
ui.gadgets.status-bar ui.gadgets.scrollers ui.gadgets.borders
|
2009-02-09 01:25:05 -05:00
|
|
|
ui.gadgets.tables ui.gestures sequences inspector
|
2009-02-12 03:09:22 -05:00
|
|
|
models.filter fonts ;
|
2009-02-05 05:00:27 -05:00
|
|
|
QUALIFIED-WITH: ui.tools.inspector i
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: ui.tools.traceback
|
|
|
|
|
2009-02-09 01:25:05 -05:00
|
|
|
TUPLE: stack-entry object string ;
|
|
|
|
|
|
|
|
: <stack-entry> ( object -- stack-entry )
|
|
|
|
dup unparse-short stack-entry boa ;
|
|
|
|
|
|
|
|
SINGLETON: stack-entry-renderer
|
|
|
|
|
|
|
|
M: stack-entry-renderer row-columns drop string>> 1array ;
|
|
|
|
|
|
|
|
M: stack-entry-renderer row-value drop object>> ;
|
|
|
|
|
|
|
|
: <stack-table> ( model -- table )
|
|
|
|
[ [ <stack-entry> ] map ] <filter> <table>
|
2009-02-12 03:09:22 -05:00
|
|
|
monospace-font >>font
|
2009-02-09 01:25:05 -05:00
|
|
|
[ i:inspector ] >>action
|
|
|
|
stack-entry-renderer >>renderer
|
|
|
|
t >>single-click? ;
|
|
|
|
|
|
|
|
: <stack-display> ( model quot title -- gadget )
|
|
|
|
[ '[ dup _ when ] <filter> <stack-table> <scroller> ] dip
|
2009-02-14 20:48:32 -05:00
|
|
|
<labeled-gadget> ;
|
2009-02-09 01:25:05 -05:00
|
|
|
|
2007-11-16 01:19:13 -05:00
|
|
|
: <callstack-display> ( model -- gadget )
|
2008-08-31 17:17:46 -04:00
|
|
|
[ [ call>> callstack. ] when* ]
|
2009-02-14 01:45:10 -05:00
|
|
|
<pane-control> t >>scrolls? <scroller>
|
2009-02-14 20:48:32 -05:00
|
|
|
"Call stack" <labeled-gadget> ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-11-16 01:19:13 -05:00
|
|
|
: <datastack-display> ( model -- gadget )
|
2009-02-09 01:25:05 -05:00
|
|
|
[ data>> ] "Data stack" <stack-display> ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-11-16 01:19:13 -05:00
|
|
|
: <retainstack-display> ( model -- gadget )
|
2009-02-09 01:25:05 -05:00
|
|
|
[ retain>> ] "Retain stack" <stack-display> ;
|
2008-02-21 02:25:59 -05:00
|
|
|
|
2008-07-10 21:32:17 -04:00
|
|
|
TUPLE: traceback-gadget < track ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-21 02:25:59 -05:00
|
|
|
M: traceback-gadget pref-dim* drop { 550 600 } ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: <traceback-gadget> ( model -- gadget )
|
2009-02-14 01:45:10 -05:00
|
|
|
[
|
|
|
|
vertical traceback-gadget new-track
|
|
|
|
{ 3 3 } >>gap
|
|
|
|
] dip
|
2009-02-05 05:12:57 -05:00
|
|
|
[ >>model ]
|
|
|
|
[
|
2009-02-14 01:45:10 -05:00
|
|
|
[ vertical <track> { 3 3 } >>gap ] dip
|
|
|
|
[
|
|
|
|
[ horizontal <track> { 3 3 } >>gap ] dip
|
|
|
|
[ <datastack-display> 1/2 track-add ]
|
|
|
|
[ <retainstack-display> 1/2 track-add ] bi
|
|
|
|
1/3 track-add
|
|
|
|
]
|
|
|
|
[ <callstack-display> 2/3 track-add ] bi
|
|
|
|
{ 3 3 } <filled-border> 1 track-add
|
|
|
|
] bi
|
2008-11-20 22:58:30 -05:00
|
|
|
add-toolbar ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-27 18:15:52 -05:00
|
|
|
: variables ( traceback -- )
|
2009-02-05 05:00:27 -05:00
|
|
|
model>> [ dup [ name>> vars-in-scope ] when ] <filter> i:inspect-model ;
|
2008-02-27 18:15:52 -05:00
|
|
|
|
2007-09-20 18:09:08 -04:00
|
|
|
: traceback-window ( continuation -- )
|
2008-11-24 13:29:24 -05:00
|
|
|
<model> <traceback-gadget> "Traceback" open-status-window ;
|
2009-01-07 16:06:43 -05:00
|
|
|
|
|
|
|
: inspect-continuation ( traceback -- )
|
2009-02-05 05:00:27 -05:00
|
|
|
control-value i:inspector ;
|
2009-01-07 16:06:43 -05:00
|
|
|
|
|
|
|
traceback-gadget "toolbar" f {
|
|
|
|
{ T{ key-down f f "v" } variables }
|
|
|
|
{ T{ key-down f f "n" } inspect-continuation }
|
|
|
|
} define-command-map
|