Attachment "tkchat.NickListv2.diff" to
ticket [1196567fff]
added by
wildcard_25
2005-05-07 00:15:30.
Index: tkchat.tcl
===================================================================
RCS file: /cvsroot/tcllib/tclapps/apps/tkchat/tkchat.tcl,v
retrieving revision 1.285
diff -u -d -r1.285 tkchat.tcl
--- tkchat.tcl 4 May 2005 16:58:45 -0000 1.285
+++ tkchat.tcl 6 May 2005 17:00:04 -0000
@@ -930,8 +915,17 @@
set clr [getColor MainFG]
}
}
- if {[lsearch -exact $Options(NickList) $nick] < 0} {
- lappend Options(NickList) $nick
+ set match 0
+ foreach nk $Options(NickList) {
+ if { [lindex $nk 0] eq $nick } {
+ lset Options(NickList) $match [lset nk 1 [clock seconds]]
+ break
+ } else {
+ incr match
+ }
+ }
+ if { $match == [llength $Options(NickList)] } {
+ lappend Options(NickList) [list $nick [clock seconds]]
set Options(Color,$nick,Web) $clr
set Options(Color,$nick,Inv) [::tkchat::invClr $clr]
set Options(Color,$nick,Mine) $clr
@@ -1352,14 +1346,16 @@
proc ::tkchat::addAction {w clr nick str {mark end} {timestamp 0} {extraOpts ""}} {
global Options
- checkNick $w $nick $clr
- checkAlert ACTION $nick $str
array set opts $extraOpts
- $w config -state normal
+
#for colors, it is better to extract the displayed nick from the one used for
#tags.
set displayNick $nick
regexp {^<(.+)>$} $nick displayNick nick
+
+ checkNick $w $nick $clr
+ checkAlert ACTION $nick $str
+ $w config -state normal
::tkchat::InsertTimestamp $w $nick $mark $timestamp
$w insert $mark " * $displayNick " [list NICK NICK-$nick]
if {[string equal $nick clock]} {
@@ -1501,14 +1497,17 @@
proc ::tkchat::addHelp {w clr name str} {
global Options
- if {[lsearch -exact $Options(NickList) $name] >= 0} {
- if { [string equal $name "ircbridge"] } {
- doIrcBridgeWhisper $clr $name $str
- } else {
- # this is an incoming private message
- addAction $w $clr $name " whispers: $str"
+ foreach nk $Options(NickList) {
+ set nk [lindex $nk 0]
+ if { $name == $nk } {
+ if { $name eq "ircbridge"] } {
+ doIrcBridgeWhisper $clr $name $str
+ } else {
+ # this is an incoming private message
+ addAction $w $clr $name " whispers: $str"
+ }
+ return
}
- return
}
if {[string match "->*" $name]} {
if { [string equal $name "->ircbridge"] } {
@@ -2303,7 +2302,8 @@
set m .mbar.vis.nicks
$m delete 0 end
set cnt 0
- foreach n [lsort -dict $::Options(NickList)] {
+ foreach n [lsort -dict -index 0 $::Options(NickList)] {
+ set n [lindex $n 0]
set tag NICK-$n
$m add checkbutton -label $n \
-onval 1 -offval 0 \
@@ -3548,7 +3548,8 @@
}
}
grid [label $f.offline -text "Offline Users" -font SYS] - - -
- foreach nick [lsort -dict $Options(NickList)] {
+ foreach nick [lsort -dict -index 0 $Options(NickList)] {
+ set nick [lindex $nick 0]
if {[lsearch -exact $Options(OnLineUsers) $nick] < 0} {
buildRow $f $nick $nick
}
@@ -3602,6 +3603,7 @@
.names config -bg "#[getColor MainBG]" -fg "#[getColor MainFG]"
$txt tag configure found -background "#[getColor SearchBG]"
foreach nk $Options(NickList) {
+ set nk [lindex $nk 0]
set clr [getColor $nk]
if {$clr == ""} {
set clr [getColor MainFG]
@@ -4284,7 +4286,7 @@
AutoConnect 0
DisplayUsers 1
Refresh 30
- NickList {}
+ NickList {{} {}}
History {}
AutoScroll 0
Geometry 600x500
@@ -4357,6 +4359,25 @@
eval $d
}
}
+ # Convert old nick list to new and remove old nicks
+ set newNicks [list]
+ foreach nk $Options(NickList) {
+ if { ![string is integer -strict [lindex $nk 1]] } {
+ set nk [list $nk]
+ }
+ if { [lindex $nk 1] eq "" } { lappend nk [clock seconds] }
+ if { [lindex $nk 1] > [clock scan "-30 day"]
+ || [lindex $nk 0] eq $Options(Username) } {
+ lappend newNicks $nk
+ } else {
+ unset "Options(Color,[lindex $nk 0],Inv)"
+ unset "Options(Color,[lindex $nk 0],Mine)"
+ unset "Options(Color,[lindex $nk 0],Web)"
+ unset "Options(Color,[lindex $nk 0],Which)"
+ unset "Options(Visibility,NICK-[lindex $nk 0])"
+ }
+ }
+ set Options(NickList) $newNicks
# Compatability issues...
if {[string is integer $Options(UseJabberSSL)]} {