[Tkabber-dev] r276 - branches/plugins-0.11.1/juick

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Jan 29 01:21:25 MSK 2010


Author: Totktonada
Date: 2010-01-29 01:21:25 +0300 (Fri, 29 Jan 2010)
New Revision: 276

Modified:
   branches/plugins-0.11.1/juick/BUGS
   branches/plugins-0.11.1/juick/TODO
   branches/plugins-0.11.1/juick/juick.tcl
Log:
Add colored PM.

Modified: branches/plugins-0.11.1/juick/BUGS
===================================================================
--- branches/plugins-0.11.1/juick/BUGS	2010-01-28 22:09:46 UTC (rev 275)
+++ branches/plugins-0.11.1/juick/BUGS	2010-01-28 22:21:25 UTC (rev 276)
@@ -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: branches/plugins-0.11.1/juick/TODO
===================================================================
--- branches/plugins-0.11.1/juick/TODO	2010-01-28 22:09:46 UTC (rev 275)
+++ branches/plugins-0.11.1/juick/TODO	2010-01-28 22:21:25 UTC (rev 276)
@@ -9,3 +9,5 @@
 + Colored citation
 + Copy nicks/nums/tag to clipboard (Tkabber-way)
 + Open things in browser.
++ Colored PM.
+- Colored post in some threads.

Modified: branches/plugins-0.11.1/juick/juick.tcl
===================================================================
--- branches/plugins-0.11.1/juick/juick.tcl	2010-01-28 22:09:46 UTC (rev 275)
+++ branches/plugins-0.11.1/juick/juick.tcl	2010-01-28 22:21:25 UTC (rev 276)
@@ -100,10 +100,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]
@@ -134,6 +150,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
 
@@ -141,7 +161,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
@@ -151,6 +171,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} {
@@ -172,7 +196,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 {
@@ -185,8 +209,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]]
@@ -199,6 +228,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