factor/extra/ui/tools/debugger/debugger.factor

62 lines
1.9 KiB
Factor
Raw Normal View History

! Copyright (C) 2006, 2008 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays ui ui.commands ui.gestures ui.gadgets
2007-09-20 18:09:08 -04:00
ui.gadgets.worlds ui.gadgets.packs ui.gadgets.buttons
ui.gadgets.labels ui.gadgets.panes ui.gadgets.presentations
ui.gadgets.viewports ui.gadgets.lists ui.gadgets.tracks
ui.gadgets.scrollers ui.gadgets.panes hashtables io kernel math
models namespaces sequences sequences words continuations
debugger prettyprint ui.tools.traceback help editors ;
IN: ui.tools.debugger
: <restart-list> ( restarts restart-hook -- gadget )
[ restart-name ] rot <model> <list> ;
TUPLE: debugger < track restarts ;
2007-09-20 18:09:08 -04:00
: <debugger-display> ( restart-list error -- gadget )
[
<pane> [ [ print-error ] with-pane ] keep gadget,
gadget,
] make-filled-pile ;
: <debugger> ( error restarts restart-hook -- gadget )
{ 0 1 } debugger new-track
2007-09-20 18:09:08 -04:00
[
2008-07-11 15:43:51 -04:00
toolbar,
<restart-list> g-> set-debugger-restarts
swap <debugger-display> <scroller> 1 track,
] make-gadget ;
2007-09-20 18:09:08 -04:00
M: debugger focusable-child* debugger-restarts ;
: debugger-window ( error -- )
#! No restarts for the debugger window
f [ drop ] <debugger> "Error" open-window ;
[ debugger-window ] ui-error-hook set-global
M: world-error error.
"An error occurred while drawing the world " write
dup world>> pprint-short "." print
2007-09-20 18:09:08 -04:00
"This world has been deactivated to prevent cascading errors." print
error>> error. ;
2007-09-20 18:09:08 -04:00
debugger "gestures" f {
{ T{ button-down } request-focus }
} define-command-map
2008-06-08 16:32:55 -04:00
: com-traceback ( -- ) error-continuation get traceback-window ;
2007-09-20 18:09:08 -04:00
\ com-traceback H{ { +nullary+ t } } define-command
\ :help H{ { +nullary+ t } { +listener+ t } } define-command
2007-11-28 02:13:02 -05:00
\ :edit H{ { +nullary+ t } { +listener+ t } } define-command
2007-09-20 18:09:08 -04:00
debugger "toolbar" f {
{ T{ key-down f f "s" } com-traceback }
{ T{ key-down f f "h" } :help }
{ T{ key-down f f "e" } :edit }
} define-command-map