! Copyright (C) 2006, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays colors.constants continuations fonts fry inspector kernel models models.arrow prettyprint sequences ui.commands ui.gadgets ui.gadgets.borders ui.gadgets.buttons ui.gadgets.labeled ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.status-bar ui.gadgets.tables ui.gadgets.toolbar ui.theme ui.gadgets.theme ui.gadgets.tracks ui.gestures ui.tools.common ; QUALIFIED-WITH: ui.tools.inspector i IN: ui.tools.traceback TUPLE: stack-entry object string ; : ( object -- stack-entry ) dup [ unparse-short ] [ drop error-in-pprint ] recover stack-entry boa ; SINGLETON: stack-entry-renderer M: stack-entry-renderer row-columns drop string>> 1array ; M: stack-entry-renderer row-value drop object>> ; : ( model -- table ) [ [ ] map ] stack-entry-renderer 10 >>min-rows 10 >>max-rows 40 >>min-cols 40 >>max-cols monospace-font >>font theme-font-colors [ i:inspector ] >>action t >>single-click? ; : ( model quot title color -- gadget ) [ '[ dup _ when ] margins white-interior ] 2dip ; : ( model -- gadget ) [ [ call>> callstack. ] when* ] t >>scrolls? margins white-interior "Call stack" call-stack-color ; : ( model -- gadget ) [ data>> ] "Data stack" data-stack-color ; : ( model -- gadget ) [ retain>> ] "Retain stack" retain-stack-color ; TUPLE: traceback-gadget < tool ; : ( model -- gadget ) [ vertical traceback-gadget new-track with-lines ] dip [ >>model ] [ [ vertical with-lines ] dip [ [ horizontal with-lines ] dip [ 1/2 track-add ] [ 1/2 track-add ] bi 1/3 track-add ] [ 2/3 track-add ] bi 1 track-add ] bi add-toolbar ; : variables ( traceback -- ) model>> [ dup [ name>> vars-in-scope ] when ] i:inspect-model ; : traceback-window ( continuation -- ) "Traceback" open-status-window ; : inspect-continuation ( traceback -- ) control-value i:inspector ; traceback-gadget "toolbar" f { { T{ key-down f f "v" } variables } { T{ key-down f f "n" } inspect-continuation } } define-command-map