 
 USING: accessors kernel threads combinators concurrency.mailboxes
        sequences strings hashtables splitting fry assocs hashtables colors
+       sorting qualified unicode.case math.order
        ui ui.gadgets ui.gadgets.panes ui.gadgets.editors
        ui.gadgets.scrollers ui.commands ui.gadgets.frames ui.gestures
        ui.gadgets.tabs ui.gadgets.grids ui.gadgets.packs ui.gadgets.labels
        io io.styles namespaces calendar calendar.format models continuations
        irc.client irc.client.private irc.messages irc.messages.private
-       irc.ui.commandparser irc.ui.load qualified ;
+       irc.ui.commandparser irc.ui.load ;
 
 RENAME: join sequences => sjoin
 

    " to " blue write-color
    channel>> write ;

M: unhandled write-irc
    "UNHANDLED: " write
    line>> blue write-color ;


GENERIC: handle-inbox ( tab message -- )

: value-labels ( assoc val -- seq )
    '[ nip , = ] assoc-filter keys [ >lower <=> ] sort [ <label> ] map ;

: add-gadget-color ( pack seq color -- pack )
    '[ , >>color add-gadget ] each ;

: update-participants ( tab -- )
    [ userlist>> [ clear-gadget ] keep ]
    [ listener>> participants>> ] bi
    [ +operator+ value-labels dark-green add-gadget-color ]
    [ +voice+ value-labels blue add-gadget-color ]
    [ +normal+ value-labels black add-gadget-color ] tri drop ;

M: participant-changed handle-inbox
    drop update-participants ;
