factor/basis/ui/tools/debugger/debugger.factor

63 lines
2.0 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
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 ;
2007-09-20 18:09:08 -04:00
IN: ui.tools.debugger
: <restart-list> ( restarts restart-hook -- gadget )
2008-08-31 17:17:46 -04:00
[ name>> ] rot <model> <list> ;
2007-09-20 18:09:08 -04:00
TUPLE: debugger < track restarts ;
2007-09-20 18:09:08 -04:00
: <debugger-display> ( restart-list error -- gadget )
<filled-pile>
<pane>
swapd tuck [ print-error ] with-pane
add-gadget
swap add-gadget ;
2007-09-20 18:09:08 -04:00
: <debugger> ( error restarts restart-hook -- gadget )
{ 0 1 } debugger new-track
dup <toolbar> f track-add
-rot <restart-list> >>restarts
dup restarts>> rot <debugger-display> <scroller> 1 track-add ;
2007-09-20 18:09:08 -04:00
2008-09-01 04:40:31 -04:00
M: debugger focusable-child* restarts>> ;
2007-09-20 18:09:08 -04:00
: 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