Hi everybody,
the attached patch [1] implements the "MSN joined" chat style, that is
similar to the MSN chat style except that consecutive messages from
the same user are joined together. This is an example:

MSN style:

John says:
Hi!
John says:
How are you?
Jack says:
Fine, thanks.
Jack says:
And you?

MSN joined style:

John says:
Hi!
How are you?
Jack says:
Fine, thanks.
And you?

The reason for which I am sending this patch to the mailing list is
that I really don't like the way I implemented it. In fact, to be
consistent with the rest of the code in PutMessageWrapped, the custom
chat style string is saved in the config key that is used for the
user-specified chat style.

Because of this, the customchatstyle config key continuously changes
from "\$tstamp [trans says \$nick]: \$newline" to "" and back, and I
don't think this is a desirable behavior. Moreover, this may lead to
problems in case of multiple chat windows when contacts are sending
messages simultaneously.

I propose for the custom chat style section of PutMessageWrapped to be
rewritten [2] to conform to the system used in DisplayOIM (a local
customchatstyle variable is initialized to [::config::getKey
customchatstyle], and is eventually modified according to the chat
style settings). This would have the positive side-effect that if the
user sets a custom chat style, then selects one of the standard chat
styles, then returns to the custom chat style, aMSN will have
remembered the latest custom chat style used.

Please let me know what do you think about this.
Thank you.

[1] msnjoinedstyle.diff
[2] msnjoinedstyle-with-putmessagewrapped-modification.diff
Index: chatwindow.tcl
===================================================================
--- chatwindow.tcl      (revisione 9627)
+++ chatwindow.tcl      (copia locale)
@@ -1562,6 +1562,8 @@
                        -value "msn" -variable [::config::getVar chatstyle]
                $stylemenu add radiobutton -label "[trans ircstyle]" \
                        -value "irc" -variable [::config::getVar chatstyle]
+               $stylemenu add radiobutton -label "[trans msnjoinedstyle]" \
+                       -value "msn-joined" -variable [::config::getVar 
chatstyle]
                $stylemenu add radiobutton -label "[trans customstyle]..." \
                        -value "custom" -variable [::config::getVar chatstyle] \
                        -command "::amsn::enterCustomStyle"
Index: gui.tcl
===================================================================
--- gui.tcl     (revisione 9627)
+++ gui.tcl     (copia locale)
@@ -2928,6 +2928,19 @@
                        irc {
                                ::config::setKey customchatstyle "\$tstamp 
<\$nick> "
                        }
+                       msn-joined {
+                               variable ::amsn::lastnick_$chatid
+                               if {!([info exists ::amsn::lastnick_$chatid])} {
+                                       set ::amsn::lastnick_$chatid ""
+                                       bind [::ChatWindow::For $chatid] 
<Destroy> "+catch {unset ::amsn::lastnick_$chatid}"
+                               }
+                               if {$nick != [set ::amsn::lastnick_$chatid]} {
+                                       set ::amsn::lastnick_$chatid $nick
+                                       ::config::setKey customchatstyle 
"\$tstamp [trans says \$nick]: \$newline"
+                               } else {
+                                       ::config::setKey customchatstyle ""
+                               }
+                       }
                        - {
                        }
                }
@@ -7926,6 +7939,23 @@
                                        set customchatstyle "<\$nick> "
                                }
                        }
+                       msn-joined {
+                               variable ::amsn::lastnick_$chatid
+                               if {!([info exists ::amsn::lastnick_$chatid])} {
+                                       set ::amsn::lastnick_$chatid ""
+                                       bind [::ChatWindow::For $chatid] 
<Destroy> "+catch {unset ::amsn::lastnick_$chatid}"
+                               }
+                               if {$nick != [set ::amsn::lastnick_$chatid]} {
+                                       set ::amsn::lastnick_$chatid $nick
+                                       if {$unixtimestamp} {
+                                               set customchatstyle "\$tstamp 
[trans says \$nick]: \$newline"
+                                       } else {
+                                               set customchatstyle "[trans 
says \$nick]: \$newline"
+                                       }
+                               } else {
+                                       set customchatstyle ""
+                               }
+                       }
                        - {}
                }
 
Index: chatwindow.tcl
===================================================================
--- chatwindow.tcl      (revisione 9627)
+++ chatwindow.tcl      (copia locale)
@@ -1562,6 +1562,8 @@
                        -value "msn" -variable [::config::getVar chatstyle]
                $stylemenu add radiobutton -label "[trans ircstyle]" \
                        -value "irc" -variable [::config::getVar chatstyle]
+               $stylemenu add radiobutton -label "[trans msnjoinedstyle]" \
+                       -value "msn-joined" -variable [::config::getVar 
chatstyle]
                $stylemenu add radiobutton -label "[trans customstyle]..." \
                        -value "custom" -variable [::config::getVar chatstyle] \
                        -command "::amsn::enterCustomStyle"
Index: gui.tcl
===================================================================
--- gui.tcl     (revisione 9627)
+++ gui.tcl     (copia locale)
@@ -2920,20 +2920,34 @@
                        set tstamp ""
                }
 
+               set customchat [::config::getKey customchatstyle]
                switch [::config::getKey chatstyle] {
                        msn {
-                               ::config::setKey customchatstyle "\$tstamp 
[trans says \$nick]: \$newline"
+                               set customchat "\$tstamp [trans says \$nick]: 
\$newline"
                        }
 
                        irc {
-                               ::config::setKey customchatstyle "\$tstamp 
<\$nick> "
+                               set customchat "\$tstamp <\$nick> "
                        }
+                       msn-joined {
+                               variable ::amsn::lastnick_$chatid
+                               if {!([info exists ::amsn::lastnick_$chatid])} {
+                                       set ::amsn::lastnick_$chatid ""
+                                       bind [::ChatWindow::For $chatid] 
<Destroy> "+catch {unset ::amsn::lastnick_$chatid}"
+                               }
+                               if {$nick != [set ::amsn::lastnick_$chatid]} {
+                                       set ::amsn::lastnick_$chatid $nick
+                                       set customchat "\$tstamp [trans says 
\$nick]: \$newline"
+                               } else {
+                                       set customchat ""
+                               }
+                       }
                        - {
                        }
                }
 
                #By default, quote backslashes and variables
-               set customchat [string map {"\\" "\\\\" "\$" "\\\$" "\(" "\\\(" 
} [::config::getKey customchatstyle]]
+               set customchat [string map {"\\" "\\\\" "\$" "\\\$" "\(" "\\\(" 
} $customchat]
                #Now, let's unquote the variables we want to replace
                set customchat [string map { "\\\$nick" "\${nick}" "\\\$tstamp" 
"\${tstamp}" "\\\$newline" "\n" } $customchat]
 
@@ -7926,6 +7940,23 @@
                                        set customchatstyle "<\$nick> "
                                }
                        }
+                       msn-joined {
+                               variable ::amsn::lastnick_$chatid
+                               if {!([info exists ::amsn::lastnick_$chatid])} {
+                                       set ::amsn::lastnick_$chatid ""
+                                       bind [::ChatWindow::For $chatid] 
<Destroy> "+catch {unset ::amsn::lastnick_$chatid}"
+                               }
+                               if {$nick != [set ::amsn::lastnick_$chatid]} {
+                                       set ::amsn::lastnick_$chatid $nick
+                                       if {$unixtimestamp} {
+                                               set customchatstyle "\$tstamp 
[trans says \$nick]: \$newline"
+                                       } else {
+                                               set customchatstyle "[trans 
says \$nick]: \$newline"
+                                       }
+                               } else {
+                                       set customchatstyle ""
+                               }
+                       }
                        - {}
                }
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Amsn-devel mailing list
Amsn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amsn-devel

Reply via email to