! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs colors colors.constants combinators concurrency.messaging formatting fry inspector kernel make models models.arrow namespaces sequences threads tools.walker ui ui.commands ui.gadgets ui.gadgets.buttons ui.gadgets.labels ui.gadgets.status-bar ui.theme ui.gadgets.toolbar ui.gadgets.tracks ui.gestures ui.pens.solid ui.tools.browser ui.tools.common ui.tools.listener ui.tools.traceback ; IN: ui.tools.walker TUPLE: walker-gadget < tool status continuation thread traceback closing? ; : walker-command ( walker msg -- ) swap dup thread>> thread-registered? [ thread>> send-synchronous drop ] [ 2drop ] if ; : com-step ( walker -- ) step walker-command ; : com-into ( walker -- ) step-into walker-command ; : com-out ( walker -- ) step-out walker-command ; : com-back ( walker -- ) step-back walker-command ; : com-continue ( walker -- ) step-all walker-command ; : com-abandon ( walker -- ) abandon walker-command ; M: walker-gadget ungraft* [ t >>closing? drop ] [ com-continue ] [ call-next-method ] tri ; M: walker-gadget focusable-child* traceback>> ; : thread-status-text ( status -- string ) { { +stopped+ "Stopped" } { +suspended+ "Suspended" } { +running+ "Running" } } at "(" ")" surround ; : thread-status-foreground ( status -- color ) { { +stopped+ [ thread-status-stopped-foreground ] } { +suspended+ [ thread-status-suspended-foreground ] } { +running+ [ thread-status-running-foreground ] } { f [ text-color ] } } case ; : thread-status-background ( status -- color ) { { +stopped+ [ thread-status-stopped-background ] } { +suspended+ [ thread-status-suspended-background ] } { +running+ [ thread-status-running-background ] } { f [ content-background ] } } case ; TUPLE: thread-status < label ; M: thread-status model-changed [ value>> ] dip { [ [ thread-status-text ] [ string<< ] bi* ] [ [ thread-status-foreground ] [ font>> foreground<< ] bi* ] [ [ thread-status-background ] [ parent>> parent>> interior<< ] bi* ] } 2cleave ; : ( model -- gadget ) "" thread-status new-label swap >>model ; : add-thread-status ( track -- track ) horizontal { 5 5 } >>gap "Thread:"