 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors colors kernel concurrency.messaging colors.constants inspector formatting
-ui.tools.listener ui.tools.traceback ui.gadgets.buttons
-ui.gadgets.status-bar ui.gadgets.toolbar ui.gadgets.theme ui.gadgets.tracks
-ui.commands ui.gadgets
-models models.arrow ui.tools.browser ui.tools.common ui.gestures
-ui.gadgets.labels ui.pens.solid ui threads namespaces make tools.walker assocs
-combinators fry ;
+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.gadgets.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

      { f           [ content-background ] }
    } case ;

TUPLE: thread-status < label thread ;

M: thread-status model-changed
    [ value>> ] dip {
        [ [ thread>> thread-status-text ] [ string<< ] bi ]
        [ [ thread-status-color <solid> ] [ parent>> interior<< ] bi* ]
    } 2cleave ;

: <thread-status> ( model thread -- gadget )
    "" thread-status new-label
        swap >>thread
        swap >>model ;

: add-thread-status ( track -- track )
    dup status>> self <thread-status> margins
    f track-add ;

: add-traceback ( track -- track )
    dup traceback>> 1 track-add ;

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 ] }
