Hello.
I written a plugin that it colors nicknames and psms like msn live plus do.
It works only for contact list. Nick background doesn't work, because with
canvas is more hard to draw a background (i should create a rectangle under
the nick, but a background color can be faded). If i'll found a simple way
i'll do.
the diffi file:
@@ -1175,6 +1175,12 @@
this is an event to work on parsednick
@@ -1193,9 +1199,9 @@ and @@ -1205,10 +1211,10 @@
here i have change splainf with a var in this way we can see bold, italic,
underline and overstrike style
@@ -1261,6 +1267,11 @@
this is an event to _decipher_ the nick style
@@ -1324,180 +1335,110 @@
Here I have write two event to work with psm and i have erased some
instructions that was repetitive. I try to explain, we have:
if {[::config::getKey psmplace] == 1 } {
set parsedpsm [::smiley::parseMessageToList " - $psm" 1]
instructions....
}
if {[::config::getKey psmplace] == 2 } {
set parsedpsm [::smiley::parseMessageToList "\n$psm" 1]
istructions.... (the same instruction)
}
now we'll have:
set parsedpsm ""
if {[::config::getKey psmplace] == 1 } {
set parsedpsm [::smiley::parseMessageToList " - $psm" 1]
} elseif {[::config::getKey psmplace] == 2 } {
set parsedpsm [::smiley::parseMessageToList "\n$psm" 1]
}
istructions...
we will see colored nick in contact list if someday somebody apply the
differences. In this case I'll post the plugin on forum.
What do you think about?
Square87
Index: guicontactlist.tcl
===================================================================
--- guicontactlist.tcl (revision 8233)
+++ guicontactlist.tcl (working copy)
@@ -1175,6 +1175,12 @@
set relxnickpos $xnickpos
set relynickpos $ypos
+ #this event could be used by colorednicks plugin
+ set evPar(email) email
+ set evPar(parsednick) parsednick
+ ::plugins::PostEvent parsed_nick evPar
+ set familyfont "splainf"
+
foreach unit $parsednick {
if {[lindex $unit 0] == "text"} {
# Check if we are still allowed to write text,\
@@ -1193,9 +1199,9 @@
# Check if text is not too long and should be
truncated, then
# first truncate it and restore it in $textpart
and set the linefull
- if {[expr {$relxnickpos + [font measure splainf
$textpart]}] > $maxwidth} {
+ if {[expr {$relxnickpos + [font measure
$familyfont $textpart]}] > $maxwidth} {
set textpart
[::guiContactList::truncateText $textpart \
- [expr {$maxwidth -
$relxnickpos}] splainf]
+ [expr {$maxwidth -
$relxnickpos}] $familyfont]
#If we don't truncate we don't put
ellipsis
#!$maxwidth already left space for the
ellipsis
@@ -1205,10 +1211,10 @@
set linefull 1
}
- # Draw the text
+ # draw the text
$canvas create text $relxnickpos $ynickpos
-text $textpart -anchor w -fill \
- $relnickcolour -font splainf -tags
[list contact $tag nicktext $main_part]
- set textwidth [font measure splainf $textpart]
+ $relnickcolour -font $familyfont -tags
[list contact $tag nicktext $main_part]
+ set textwidth [font measure $familyfont
$textpart]
# Append underline coords
set yunderline [expr {$ynickpos + $textheight +
1}]
@@ -1261,6 +1267,11 @@
set relnickcolour $nickcolour
}
} else {
+ set evPar(unit) unit
+ set evPar(relnickcolour) relnickcolour
+ set evPar(familyfont) familyfont
+ ::plugins::PostEvent parsed_unit evPar
+
status_log "Unknown item in parsed nickname:
$unit"
}
#END the foreach loop
@@ -1324,180 +1335,110 @@
if {$psm != "" && [::config::getKey emailsincontactlist] == 0 }
{
set relnickcolour $nickcolour
+ set parsedpsm ""
if {[::config::getKey psmplace] == 1 } {
set parsedpsm [::smiley::parseMessageToList " -
$psm" 1]
- foreach unit $parsedpsm {
- if {[lindex $unit 0] == "text"} {
- # Check if we are still allowed
to write text
- if { $linefull } {
- continue
- }
-
- # Store the text as a string
- set textpart [lindex $unit 1]
-
- # Check if it's really
containing text
- if {$textpart == ""} {
- continue
- }
-
- # Check if text is not too long
and should be truncated, then
- # first truncate it and restore
it in $textpart and set the linefull
- if {[expr {$relxnickpos + [font
measure sitalf $textpart]}] > $maxwidth} {
- set textpart
[::guiContactList::truncateText $textpart \
- [expr
{$maxwidth - $relxnickpos}] sitalf]
- set textpart
"$textpart$ellips"
-
- # This line is full,
don't draw anything anymore before we start a new line
- set linefull 1
- }
-
- # Draw the text
- $canvas create text
$relxnickpos $ynickpos -text $textpart -anchor w -fill \
- $relnickcolour -font
sitalf -tags [list contact $tag psmtext $main_part]
- set textwidth [font measure
sitalf $textpart]
-
- # Append underline coords
- set yunderline [expr {$ynickpos
+ $textheight + 1}]
- lappend underlinst [list [expr
{$relxnickpos - $xpos}] [expr {$yunderline - $ypos}] \
- $textwidth
$relnickcolour]
-
- # Change the coords
- set relxnickpos [expr
$relxnickpos + $textwidth]
- } elseif { [lindex $unit 0] == "smiley"
} {
- # Check if we are still allowed
to draw smileys
- if { $linefull } {
- continue
- }
-
- set smileyname [lindex $unit 1]
-
- if { [expr {$relxnickpos +
[image width $smileyname]}] > $maxwidth } {
- # This line is full,
don't draw anything anymore before we start a new line
- set linefull 1
-
- $canvas create text
$relxnickpos $ynickpos -text $ellips -anchor w \
- -fill
$relnickcolour -font sitalf -tags [list contact $tag psmtext $main_part]
- set textwidth [font
measure sitalf $ellips]
-
- # Append underline
coords
- set yunderline [expr
{$ynickpos + $textheight + 1}]
- lappend underlinst
[list [expr {$relxnickpos - $xpos}] \
- [expr
{$yunderline - $ypos}] $textwidth $relnickcolour]
- continue
- }
-
- # Draw the smiley
- $canvas create image
$relxnickpos $ynickpos -image $smileyname -anchor w \
- -tags [list contact
$tag psmsmiley $main_part]
-
- # Change the coords
- set relxnickpos [expr
{$relxnickpos + [image width $smileyname]}]
- } elseif {[lindex $unit 0] ==
"newline"} {
- set relxnickpos $xnickpos
- set ynickpos [expr {$ynickpos +
[image height $img]}]
- set ychange [expr {$ychange +
[image height $img]}]
-
- # New line, we can draw again !
- set linefull 0
- } elseif {[lindex $unit 0] == "colour"
&& !$force_colour} {
- # A plugin like aMSN Plus!
could make the text lists
- # contain an extra variable for
colourchanges
- set relnickcolour [lindex $unit
1]
- if {$relnickcolour == "reset"} {
- set relnickcolour
$nickcolour
- }
- }
- # END the foreach loop
- }
} elseif {[::config::getKey psmplace] == 2 } {
set parsedpsm [::smiley::parseMessageToList
"\n$psm" 1]
+ }
- foreach unit $parsedpsm {
- if {[lindex $unit 0] == "text"} {
- # Check if we are still allowed
to write text
- if { $linefull } {
- continue
- }
+ #this settings and event are used by colorednicks plugin
+ set parsednick $parsedpsm
+ set evPar(parsednick) parsednick
+ ::plugins::PostEvent parsed_nick evPar
+ set parsedpsm $parsednick
+ set familyfont "sitalf"
+
+ foreach unit $parsedpsm {
+ if {[lindex $unit 0] == "text"} {
+ # Check if we are still allowed to
write text
+ if { $linefull } {
+ continue
+ }
- # Store the text as a string
- set textpart [lindex $unit 1]
+ # Store the text as a string
+ set textpart [lindex $unit 1]
- # Check if it's really
containing text
- if {$textpart == ""} {
- continue
- }
+ # Check if it's really containing text
+ if {$textpart == ""} {
+ continue
+ }
- # Check if text is not too long
and should be truncated, then
- # first truncate it and restore
it in $textpart and set the linefull
- if {[expr {$relxnickpos + [font
measure sitalf $textpart]}] > $maxwidth} {
- set textpart
[::guiContactList::truncateText $textpart \
- [expr
{$maxwidth - $relxnickpos}] sitalf]
- set textpart
"$textpart$ellips"
+ # Check if text is not too long and
should be truncated, then
+ # first truncate it and restore it in
$textpart and set the linefull
+ if {[expr {$relxnickpos + [font measure
$familyfont $textpart]}] > $maxwidth} {
+ set textpart
[::guiContactList::truncateText $textpart \
+ [expr {$maxwidth -
$relxnickpos}] $familyfont]
+ set textpart "$textpart$ellips"
- # This line is full,
don't draw anything anymore before we start a new line
- set linefull 1
- }
+ # This line is full, don't draw
anything anymore before we start a new line
+ set linefull 1
+ }
- # Draw the text
- $canvas create text
$relxnickpos $ynickpos -text $textpart -anchor w -fill \
- $relnickcolour -font
sitalf -tags [list contact $tag psmtext $main_part]
- set textwidth [font measure
sitalf $textpart]
+ # Draw the text
+ $canvas create text $relxnickpos
$ynickpos -text $textpart -anchor w -fill \
+ $relnickcolour -font
$familyfont -tags [list contact $tag psmtext $main_part]
+ set textwidth [font measure $familyfont
$textpart]
+ # Append underline coords
+ set yunderline [expr {$ynickpos +
$textheight + 1}]
+ lappend underlinst [list [expr
{$relxnickpos - $xpos}] [expr {$yunderline - $ypos}] \
+ $textwidth $relnickcolour]
+
+ # Change the coords
+ set relxnickpos [expr $relxnickpos +
$textwidth]
+ } elseif { [lindex $unit 0] == "smiley" } {
+ # Check if we are still allowed to draw
smileys
+ if { $linefull } {
+ continue
+ }
+
+ set smileyname [lindex $unit 1]
+
+ if { [expr {$relxnickpos + [image width
$smileyname]}] > $maxwidth } {
+ # This line is full, don't draw
anything anymore before we start a new line
+ set linefull 1
+
+ $canvas create text
$relxnickpos $ynickpos -text $ellips -anchor w \
+ -fill $relnickcolour
-font sitalf -tags [list contact $tag psmtext $main_part]
+ set textwidth [font measure
sitalf $ellips]
+
# Append underline coords
set yunderline [expr {$ynickpos
+ $textheight + 1}]
- lappend underlinst [list [expr
{$relxnickpos - $xpos}] [expr {$yunderline - $ypos}] \
- $textwidth
$relnickcolour]
+ lappend underlinst [list [expr
{$relxnickpos - $xpos}] \
+ [expr {$yunderline -
$ypos}] $textwidth $relnickcolour]
+ continue
+ }
- # Change the coords
- set relxnickpos [expr
{$relxnickpos + $textwidth}]
- } elseif { [lindex $unit 0] == "smiley"
} {
- # Check if we are still allowed
to draw smileys
- if { $linefull } {
- continue
- }
-
- set smileyname [lindex $unit 1]
-
- if { [expr {$relxnickpos +
[image width $smileyname]}] > $maxwidth } {
- # This line is full,
don't draw anything anymore before we start a new line
- set linefull 1
-
- $canvas create text
$relxnickpos $ynickpos -text $ellips -anchor w \
- -fill
$relnickcolour -font sitalf -tags [list contact $tag psmtext $main_part]
- set textwidth [font
measure sitalf $ellips]
-
- # Append underline
coords
- set yunderline [expr
{$ynickpos + $textheight + 1}]
- lappend underlinst
[list [expr {$relxnickpos - $xpos}] \
- [expr
{$yunderline - $ypos}] $textwidth $relnickcolour]
- continue
- }
-
- # Draw the smiley
- $canvas create image
$relxnickpos $ynickpos -image $smileyname -anchor w \
- -tags [list contact
$tag psmsmiley $main_part]
-
- # Change the coords
- set relxnickpos [expr
{$relxnickpos + [image width $smileyname]}]
- } elseif {[lindex $unit 0] ==
"newline"} {
- set relxnickpos $xnickpos
- set ynickpos [expr {$ynickpos +
[image height $img]}]
- set ychange [expr {$ychange +
[image height $img]}]
-
- # New line, we can draw again !
- set linefull 0
- } elseif {[lindex $unit 0] == "colour"
&& !$force_colour} {
- # A plugin like aMSN Plus!
could make the text lists
- # contain an extra variable for
colourchanges
- set relnickcolour [lindex $unit
1]
- if {$relnickcolour == "reset"} {
- set relnickcolour
$nickcolour
- }
+ # Draw the smiley
+ $canvas create image $relxnickpos
$ynickpos -image $smileyname -anchor w \
+ -tags [list contact $tag
psmsmiley $main_part]
+
+ # Change the coords
+ set relxnickpos [expr {$relxnickpos +
[image width $smileyname]}]
+ } elseif {[lindex $unit 0] == "newline"} {
+ set relxnickpos $xnickpos
+ set ynickpos [expr {$ynickpos + [image
height $img]}]
+ set ychange [expr {$ychange + [image
height $img]}]
+
+ # New line, we can draw again !
+ set linefull 0
+ } elseif {[lindex $unit 0] == "colour" &&
!$force_colour} {
+ # A plugin like aMSN Plus! could make
the text lists
+ # contain an extra variable for
colourchanges
+ set relnickcolour [lindex $unit 1]
+ if {$relnickcolour == "reset"} {
+ set relnickcolour $nickcolour
}
- # END the foreach loop
+ } else {
+ set evPar(unit) unit
+ set evPar(relnickcolour) relnickcolour
+ set evPar(familyfont) familyfont
+ ::plugins::PostEvent parsed_unit evPar
+ set familyfont "$familyfont italic"
}
+ # END the foreach loop
}
} ; #end psm drawing
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Amsn-devel mailing list
Amsn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amsn-devel