[Tkabber-dev] r275 - trunk/plugins/juick

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Jan 29 01:09:46 MSK 2010


Author: Totktonada
Date: 2010-01-29 01:09:46 +0300 (Fri, 29 Jan 2010)
New Revision: 275

Modified:
   trunk/plugins/juick/BUGS
   trunk/plugins/juick/TODO
   trunk/plugins/juick/juick.tcl
Log:


Modified: trunk/plugins/juick/BUGS
===================================================================
--- trunk/plugins/juick/BUGS	2010-01-28 17:14:06 UTC (rev 274)
+++ trunk/plugins/juick/BUGS	2010-01-28 22:09:46 UTC (rev 275)
@@ -1,4 +1,4 @@
 # You can report about all bugs this plugin via jabber: Totktonada at totktonada.ru.
 # Mathed: "-". Fixed: "+".
 
-- Citate with smile in middle.
+- Citate with and PM smile in middle.

Modified: trunk/plugins/juick/TODO
===================================================================
--- trunk/plugins/juick/TODO	2010-01-28 17:14:06 UTC (rev 274)
+++ trunk/plugins/juick/TODO	2010-01-28 22:09:46 UTC (rev 275)
@@ -9,4 +9,6 @@
 + Colored citation
 + Copy nicks/nums/tag to clipboard (Tkabber-way)
 + Dynamic load/unload.
-+ Open things in browser.
\ No newline at end of file
++ Open things in browser.
++ Colored PM.
+- Colored post in some threads.

Modified: trunk/plugins/juick/juick.tcl
===================================================================
--- trunk/plugins/juick/juick.tcl	2010-01-28 17:14:06 UTC (rev 274)
+++ trunk/plugins/juick/juick.tcl	2010-01-28 22:09:46 UTC (rev 275)
@@ -17,6 +17,7 @@
 proc load {} {
     ::richtext::entity_state citing 1
     ::richtext::entity_state juick 1
+    ::richtext::entity_state juick_ligth 1
 
     hook::add draw_message_hook [namespace current]::ignore_server_messages 0
     hook::add draw_message_hook [namespace current]::handle_message 21
@@ -32,6 +33,7 @@
 
     ::richtext::entity_state citing 0
     ::richtext::entity_state juick 0
+    ::richtext::entity_state juick_ligth 0
 }
 
 # Determines whether given chatid correspond to Juick
@@ -125,10 +127,26 @@
     $w tag configure JMY -foreground gray
 }
 
+proc configure_juick_ligth {w} {
+#    $w tag configure JLIGTH -foreground gray
+    $w tag configure JLIGTH -background #FF9A15
+}
+
 proc configure_citing {w} {
     $w tag configure CITING -foreground gray35
 }
 
+proc spot_juick_ligth {what at startVar endVar} {
+    set matched [regexp -indices -start $at -- \
+    {(?:^Private message from @.+:\n)(.+$)} $what -> bounds]
+
+    if {!$matched} { return false }
+
+    upvar 1 $startVar uStart $endVar uEnd
+    lassign $bounds uStart uEnd
+    return true
+}
+
 proc spot_citing {what at startVar endVar} {
     set matched [regexp -indices -start $at -- \
     {(?:\n|\A)(>[^\n]+)} $what -> bounds]
@@ -159,6 +177,10 @@
 return [process $atLevel $accName citing]
 }
 
+proc process_juick_ligth {atLevel accName} {
+return [process $atLevel $accName juick_ligth]
+}
+
 proc process {atLevel accName what} {
     upvar #$atLevel $accName chunks
 
@@ -166,7 +188,7 @@
     set out {}
 
     foreach {s type tags} $chunks {
-        if {[lsearch -regexp $type (text)|(citing)]<0} {
+        if {[lsearch -regexp $type (text)|(citing)|(juick_ligth)]<0} {
             # pass through
             lappend out $s $type $tags
             continue
@@ -176,6 +198,10 @@
         lappend tags CITING
         }
 
+        if {[expr [lsearch -exact $type juick_ligth]>=0]} {
+        lappend tags JLIGTH
+        }
+
         set index 0; set uStart 0; set uEnd 0
         while {[eval {spot_$what $s $index uStart uEnd}]} {
             if {$uStart - $index > 0} {
@@ -197,7 +223,7 @@
 }
 
 proc render_juick {w type thing tags args} {
-    if {[lsearch -exact $tags CITING]<0} {
+    if {[expr [lsearch -exact $tags CITING]<0] && [expr [lsearch -exact $tags JLIGTH]<0]} {
        if {[cequal [string index $thing 0] "#" ]} {
           set type JNUM
           } else {
@@ -210,8 +236,13 @@
                            }
                  }
     } else {
-           set type CITING
+           if {[lsearch -exact $tags CITING]>=0} {
+               set type CITING
            }
+           if {[lsearch -exact $tags JLIGTH]>=0} {
+               set type JLIGTH
+           }
+    }
 
     set id JUICK-$thing
     $w insert end $thing [lfuse $tags [list $id $type JUICK]]
@@ -224,6 +255,17 @@
     return $id
 }
 
+proc render_juick_ligth {w type thing tags args} {
+    set id JLIGTH-$thing
+    $w insert end $thing [lfuse $tags [list $id $type JLIGTH]]
+    return $id
+}
+
+::richtext::register_entity juick_ligth \
+    -configurator [namespace current]::configure_juick_ligth \
+    -parser [namespace current]::process_juick_ligth \
+    -renderer [namespace current]::render_juick_ligth \
+    -parser-priority 81
 ::richtext::register_entity citing \
     -configurator [namespace current]::configure_citing \
     -parser [namespace current]::process_citing \



More information about the Tkabber-dev mailing list