From d1cbccca75373d1aa8ec72b6b9fe44b9f24a349f Mon Sep 17 00:00:00 2001 From: William Schlieper Date: Wed, 16 Jul 2008 19:33:33 -0400 Subject: [PATCH] Added participant lists --- extra/irc/ui/load/load.factor | 2 +- extra/irc/ui/ui.factor | 85 ++++++++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/extra/irc/ui/load/load.factor b/extra/irc/ui/load/load.factor index 6655f310e7..e6f4d07b56 100755 --- a/extra/irc/ui/load/load.factor +++ b/extra/irc/ui/load/load.factor @@ -5,7 +5,7 @@ USING: kernel io.files parser editors sequences ; IN: irc.ui.load -: file-or ( path path -- path ) over exists? ? ; +: file-or ( path path -- path ) [ [ exists? ] keep ] dip ? ; : personal-ui-rc ( -- path ) home ".ircui-rc" append-path ; diff --git a/extra/irc/ui/ui.factor b/extra/irc/ui/ui.factor index 12f9d01183..a79920efe5 100755 --- a/extra/irc/ui/ui.factor +++ b/extra/irc/ui/ui.factor @@ -5,8 +5,8 @@ USING: accessors kernel threads combinators concurrency.mailboxes sequences strings hashtables splitting fry assocs hashtables 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 - io io.styles namespaces calendar calendar.format + ui.gadgets.tabs ui.gadgets.grids ui.gadgets.lists ui.gadgets.labels + io io.styles namespaces calendar calendar.format models irc.client irc.client.private irc.messages irc.messages.private irc.ui.commandparser irc.ui.load ; @@ -18,11 +18,18 @@ SYMBOL: client TUPLE: ui-window client tabs ; +TUPLE: irc-tab < frame listener client listmodel ; + : write-color ( str color -- ) foreground associate format ; : red { 0.5 0 0 1 } ; : green { 0 0.5 0 1 } ; : blue { 0 0 1 1 } ; +: black { 0 0 0 1 } ; + +: colors H{ { +operator+ { 0 0.5 0 1 } } + { +voice+ { 0 0 1 1 } } + { +normal+ { 0 0 0 1 } } } ; : dot-or-parens ( string -- string ) dup empty? [ drop "." ] @@ -64,6 +71,14 @@ M: quit write-irc " has left IRC" red write-color trailing>> dot-or-parens red write-color ; +M: mode write-irc + "* " blue write-color + [ name>> write ] keep + " has applied mode " blue write-color + [ mode>> write ] keep + " to " blue write-color + channel>> write ; + M: irc-end write-irc drop "* You have left IRC" red write-color ; @@ -84,20 +99,39 @@ M: irc-message write-irc [ print-irc ] [ listener get write-message ] bi ; -: display ( stream listener -- ) +GENERIC: handle-inbox ( tab message -- ) + +: filter-participants ( assoc val -- alist ) + [ >alist ] dip + '[ second , = ] filter ; + +: update-participants ( tab -- ) + [ listmodel>> ] [ listener>> participants>> ] bi + [ +operator+ filter-participants ] + [ +voice+ filter-participants ] + [ +normal+ filter-participants ] tri + append append swap set-model ; + +M: participant-changed handle-inbox + drop update-participants ; + +M: object handle-inbox + nip print-irc ; + +: display ( stream tab -- ) '[ , [ [ t ] - [ , read-message print-irc ] + [ , dup listener>> read-message handle-inbox ] [ ] while ] with-output-stream ] "ircv" spawn drop ; -: ( listener -- pane ) +: ( tab -- tab pane ) - [ swap display ] keep ; + [ swap display ] 2keep ; TUPLE: irc-editor < editor outstream listener client ; -: ( page pane listener -- client editor ) - irc-editor new-editor - swap >>listener swap >>outstream +: ( tab pane -- tab editor ) + over irc-editor new-editor + swap listener>> >>listener swap >>outstream over client>> >>client ; : editor-send ( irc-editor -- ) @@ -113,25 +147,36 @@ irc-editor "general" f { { T{ key-down f f "ENTER" } editor-send } } define-command-map -TUPLE: irc-page < frame listener client ; +: ( -- gadget model ) + [ drop ] + [ first2 [