2011-10-03 03:24:13 -04:00
|
|
|
! Copyright (C) 2006, 2011 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-11-24 13:29:24 -05:00
|
|
|
USING: accessors arrays hashtables io kernel math models
|
2011-10-03 03:24:13 -04:00
|
|
|
colors.constants namespaces sequences words continuations
|
|
|
|
debugger prettyprint help editors fonts ui ui.commands
|
2015-07-30 13:43:32 -04:00
|
|
|
ui.debugger ui.gestures ui.gadgets ui.pens.solid
|
2011-10-03 03:24:13 -04:00
|
|
|
ui.gadgets.worlds ui.gadgets.packs ui.gadgets.buttons
|
|
|
|
ui.gadgets.labels ui.gadgets.presentations ui.gadgets.panes
|
2015-07-30 13:43:32 -04:00
|
|
|
ui.gadgets.viewports ui.gadgets.tables ui.gadgets.theme
|
|
|
|
ui.gadgets.tracks ui.gadgets.toolbar
|
2011-10-03 03:24:13 -04:00
|
|
|
ui.gadgets.scrollers ui.gadgets.borders ui.gadgets.status-bar
|
2015-07-21 15:12:09 -04:00
|
|
|
ui.tools.traceback ui.tools.inspector ui.tools.browser ui.tools.common ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: ui.tools.debugger
|
|
|
|
|
2008-11-24 13:29:24 -05:00
|
|
|
TUPLE: debugger < track error restarts restart-hook restart-list continuation ;
|
|
|
|
|
|
|
|
<PRIVATE
|
|
|
|
|
2009-02-09 01:25:05 -05:00
|
|
|
SINGLETON: restart-renderer
|
|
|
|
|
|
|
|
M: restart-renderer row-columns
|
|
|
|
drop [ name>> ] [ "Abort" ] if* "• " prepend 1array ;
|
|
|
|
|
2008-11-24 13:29:24 -05:00
|
|
|
: <restart-list> ( debugger -- gadget )
|
2009-02-16 05:25:15 -05:00
|
|
|
dup restarts>> f prefix <model> restart-renderer <table>
|
2013-03-23 20:39:48 -04:00
|
|
|
[ [ \ continue-restart invoke-command ] when* ] >>action
|
2009-02-09 01:25:05 -05:00
|
|
|
swap restart-hook>> >>hook
|
|
|
|
t >>selection-required?
|
|
|
|
t >>single-click? ; inline
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2011-10-03 03:24:13 -04:00
|
|
|
: <error-pane> ( error -- pane )
|
|
|
|
<pane> [ [ print-error ] with-pane ] keep ; inline
|
|
|
|
|
2009-02-09 01:25:05 -05:00
|
|
|
: <error-display> ( debugger -- gadget )
|
|
|
|
[ <filled-pile> ] dip
|
|
|
|
[ error>> <error-pane> add-gadget ]
|
|
|
|
[
|
|
|
|
dup restart-hook>> [
|
|
|
|
[ "To continue, pick one of the options below:" <label> add-gadget ] dip
|
|
|
|
restart-list>> add-gadget
|
|
|
|
] [ drop ] if
|
|
|
|
] bi ;
|
2008-07-13 16:07:48 -04:00
|
|
|
|
2008-11-24 13:29:24 -05:00
|
|
|
PRIVATE>
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-02-19 17:54:27 -05:00
|
|
|
: <debugger> ( error continuation restarts restart-hook -- debugger )
|
2015-07-21 14:51:28 -04:00
|
|
|
vertical debugger new-track with-lines
|
2008-11-24 13:29:24 -05:00
|
|
|
swap >>restart-hook
|
|
|
|
swap >>restarts
|
2009-02-09 01:25:05 -05:00
|
|
|
swap >>continuation
|
2008-11-24 13:29:24 -05:00
|
|
|
swap >>error
|
|
|
|
dup <restart-list> >>restart-list
|
2015-07-21 14:51:28 -04:00
|
|
|
dup <error-display> margins white-interior f track-add
|
|
|
|
add-toolbar ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-02-09 01:25:05 -05:00
|
|
|
M: debugger focusable-child*
|
|
|
|
dup restart-hook>> [ restart-list>> ] [ drop t ] if ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-02-09 01:25:05 -05:00
|
|
|
: debugger-window ( error continuation -- )
|
2015-09-08 19:15:10 -04:00
|
|
|
! No restarts for the debugger window
|
2009-02-13 02:00:02 -05:00
|
|
|
f f <debugger> "Error" open-status-window ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-11-19 22:57:59 -05:00
|
|
|
GENERIC: error-in-debugger? ( error -- ? )
|
|
|
|
|
2009-05-13 23:42:38 -04:00
|
|
|
M: world-error error-in-debugger?
|
|
|
|
world>> children>> [ f ] [ first debugger? ] if-empty ;
|
2008-11-19 22:57:59 -05:00
|
|
|
|
|
|
|
M: object error-in-debugger? drop f ;
|
|
|
|
|
|
|
|
[
|
2009-02-09 01:25:05 -05:00
|
|
|
dup error-in-debugger?
|
2011-10-03 03:24:13 -04:00
|
|
|
[ error-alert ] [ error-continuation get debugger-window ] if
|
2008-11-19 22:57:59 -05:00
|
|
|
] ui-error-hook set-global
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
debugger "gestures" f {
|
|
|
|
{ T{ button-down } request-focus }
|
|
|
|
} define-command-map
|
|
|
|
|
2009-02-09 01:25:05 -05:00
|
|
|
: com-inspect ( debugger -- ) error>> inspector ;
|
2008-11-24 13:29:24 -05:00
|
|
|
|
2009-02-09 01:25:05 -05:00
|
|
|
: com-traceback ( debugger -- ) continuation>> traceback-window ;
|
2008-11-24 13:29:24 -05:00
|
|
|
|
2014-12-17 20:38:14 -05:00
|
|
|
: com-help ( debugger -- ) error>> error-help-window ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2009-08-04 22:14:43 -04:00
|
|
|
: com-edit ( debugger -- ) error>> edit-error ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-11-24 13:29:24 -05:00
|
|
|
\ com-edit H{ { +listener+ t } } define-command
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
debugger "toolbar" f {
|
2009-02-09 01:25:05 -05:00
|
|
|
{ T{ key-down f { C+ } "i" } com-inspect }
|
|
|
|
{ T{ key-down f { C+ } "t" } com-traceback }
|
|
|
|
{ T{ key-down f { C+ } "h" } com-help }
|
|
|
|
{ T{ key-down f { C+ } "e" } com-edit }
|
2007-09-20 18:09:08 -04:00
|
|
|
} define-command-map
|