]> gitweb.factorcode.org Git - factor.git/commitdiff
irc.ui: Update to work with the latest irc.client changes
authorBruno Deferrari <utizoc@gmail.com>
Sun, 5 Oct 2008 23:33:53 +0000 (21:33 -0200)
committerBruno Deferrari <utizoc@gmail.com>
Sun, 5 Oct 2008 23:33:53 +0000 (21:33 -0200)
extra/irc/ui/commands/commands.factor
extra/irc/ui/ui.factor

index 184a2b4de8fb75d1fe45b42f4bfe4572dba1b444..4bb77e7490c34b1d344ee3eba45d2947741a4adb 100755 (executable)
@@ -8,7 +8,7 @@ IN: irc.ui.commands
 : say ( string -- )\r
     irc-tab get\r
     [ window>> client>> profile>> nickname>> <own-message> print-irc ]\r
-    [ listener>> write-message ] 2bi ;\r
+    [ chat>> speak ] 2bi ;\r
 \r
 : join ( string -- )\r
     irc-tab get window>> join-channel ;\r
@@ -18,7 +18,7 @@ IN: irc.ui.commands
 \r
 : whois ( string -- )\r
     "WHOIS" swap { } clone swap  <irc-client-message>\r
-    irc-tab get listener>> write-message ;\r
+    irc-tab get listener>> speak ;\r
 \r
 : quote ( string -- )\r
     drop ; ! THIS WILL CHANGE\r
index c171fef0b639bb6ea0e69ef07a25860dcb217206..50dc9378a2c03fc1b55379a4e6df74a05695224c 100755 (executable)
@@ -15,7 +15,7 @@ RENAME: join sequences => sjoin
 \r
 IN: irc.ui\r
 \r
-SYMBOL: listener\r
+SYMBOL: chat\r
 \r
 SYMBOL: client\r
 \r
@@ -24,7 +24,7 @@ TUPLE: ui-window < tabbed client ;
 M: ui-window ungraft*\r
     client>> terminate-irc ;\r
 \r
-TUPLE: irc-tab < frame listener client window ;\r
+TUPLE: irc-tab < frame chat client window ;\r
 \r
 : write-color ( str color -- )\r
     foreground associate format ;\r
@@ -117,7 +117,7 @@ M: irc-disconnected write-irc
 M: irc-connected write-irc\r
     drop "* Connected" dark-green write-color ;\r
 \r
-M: irc-listener-end write-irc\r
+M: irc-chat-end write-irc\r
     drop ;\r
 \r
 M: irc-message write-irc\r
@@ -135,7 +135,7 @@ M: object time-happened drop now ;
 \r
 : send-message ( message -- )\r
     [ print-irc ]\r
-    [ listener get write-message ] bi ;\r
+    [ chat get speak ] bi ;\r
 \r
 GENERIC: handle-inbox ( tab message -- )\r
 \r
@@ -150,7 +150,7 @@ M: object handle-inbox
 \r
 : display ( stream tab -- )\r
     '[ _ [ [ t ]\r
-           [ _ dup listener>> read-message handle-inbox ]\r
+           [ _ dup chat>> hear handle-inbox ]\r
            [  ] while ] with-output-stream ] "ircv" spawn drop ;\r
 \r
 : <irc-pane> ( tab -- tab pane )\r
@@ -175,33 +175,28 @@ irc-editor "general" f {
     { T{ key-down f f "ENTER" } editor-send }\r
 } define-command-map\r
 \r
-: new-irc-tab ( listener ui-window class -- irc-tab )\r
+: new-irc-tab ( chat ui-window class -- irc-tab )\r
     new-frame\r
     swap >>window\r
-    swap >>listener\r
+    swap >>chat\r
     <irc-pane> [ <scroller> @center grid-add ] keep\r
     <irc-editor> <scroller> @bottom grid-add ;\r
 \r
-GENERIC: init-listener ( listener -- )\r
-M: object init-listener drop ;\r
-M: irc-channel-listener init-listener join-irc-channel ;\r
-\r
 M: irc-tab graft*\r
-    [ listener>> dup ] [ window>> client>> ] bi add-listener\r
-    init-listener ;\r
+    [ chat>> ] [ window>> client>> ] bi attach-chat ;\r
 \r
 M: irc-tab ungraft*\r
-    listener>> remove-listener ;\r
+    chat>> dettach-chat ;\r
 \r
 TUPLE: irc-channel-tab < irc-tab userlist ;\r
 \r
-: <irc-channel-tab> ( listener ui-window -- irc-tab )\r
+: <irc-channel-tab> ( chat ui-window -- irc-tab )\r
     irc-channel-tab new-irc-tab\r
     <pile> [ <scroller> @right grid-add ] keep >>userlist ;\r
 \r
 : update-participants ( tab -- )\r
     [ userlist>> [ clear-gadget ] keep ]\r
-    [ listener>> participants>> ] bi\r
+    [ chat>> participants>> ] bi\r
     [ +operator+ value-labels dark-green add-gadget-color ]\r
     [ +voice+ value-labels blue add-gadget-color ]\r
     [ +normal+ value-labels black add-gadget-color ] tri drop ;\r
@@ -211,22 +206,22 @@ M: participant-changed handle-inbox
 \r
 TUPLE: irc-server-tab < irc-tab ;\r
 \r
-: <irc-server-tab> ( listener -- irc-tab )\r
+: <irc-server-tab> ( chat -- irc-tab )\r
     f irc-server-tab new-irc-tab ;\r
 \r
-: <irc-nick-tab> ( listener ui-window -- irc-tab )\r
+: <irc-nick-tab> ( chat ui-window -- irc-tab )\r
     irc-tab new-irc-tab ;\r
 \r
 M: irc-tab pref-dim*\r
     drop { 480 480 } ;\r
 \r
 : join-channel ( name ui-window -- )\r
-    [ dup <irc-channel-listener> ] dip\r
+    [ dup <irc-channel-chat> ] dip\r
     [ <irc-channel-tab> swap ] keep\r
     add-page ;\r
 \r
 : query-nick ( nick ui-window -- )\r
-    [ dup <irc-nick-listener> ] dip\r
+    [ dup <irc-nick-chat> ] dip\r
     [ <irc-nick-tab> swap ] keep\r
     add-page ;\r
 \r
@@ -237,16 +232,15 @@ M: irc-tab pref-dim*
 \r
 : ui-connect ( profile -- ui-window )\r
     <irc-client>\r
-    { [ [ <irc-server-listener> ] dip add-listener ]\r
-      [ listeners>> +server-listener+ swap at <irc-server-tab> dup\r
+    { [ [ <irc-server-chat> ] dip attach-chat ]\r
+      [ chats>> +server-chat+ swap at <irc-server-tab> dup\r
         "Server" associate ui-window new-tabbed [ swap (>>window) ] keep ]\r
       [ >>client ]\r
       [ connect-irc ] } cleave ;\r
 \r
 : server-open ( server port nick password channels -- )\r
-    [ <irc-profile> ui-connect [ irc-window ] keep ] dip 2drop ;\r
-! FIXME: should join channels only after we have been logged in\r
-!    [ over join-channel ] each drop ;\r
+    [ <irc-profile> ui-connect [ irc-window ] keep ] dip\r
+    [ over join-channel ] each drop ;\r
 \r
 : main-run ( -- ) run-ircui ;\r
 \r