[Tkabber-dev] r815 - in trunk/tkabber: . plugins/richtext

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Nov 29 20:37:02 MSK 2006


Author: sergei
Date: 2006-11-29 20:36:59 +0300 (Wed, 29 Nov 2006)
New Revision: 815

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/richtext/highlight.tcl
   trunk/tkabber/plugins/richtext/urls.tcl
Log:
	* plugins/richtext/highlight.tcl: Fixed initializing plugin state.

	* plugins/richtext/urls.tcl: Changed the way of storing URLs in
	  text widget. Instead of hiding them in text, add them to tag
	  list.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2006-11-29 06:49:06 UTC (rev 814)
+++ trunk/tkabber/ChangeLog	2006-11-29 17:36:59 UTC (rev 815)
@@ -1,5 +1,11 @@
 2006-11-29  Sergei Golovan  <sgolovan at nes.ru>
 
+	* plugins/richtext/highlight.tcl: Fixed initializing plugin state.
+
+	* plugins/richtext/urls.tcl: Changed the way of storing URLs in
+	  text widget. Instead of hiding them in text, add them to tag
+	  list.
+
 	* plugins/richtext/stylecodes.tcl, plugins/richtext/emoticons.tcl:
 	  Swapped priorities to make emoticons pluging move first (thanks
 	  to Konstantin Khomoutov).
@@ -13,8 +19,7 @@
 
 	* chats.tcl: Fixed error messages processing.
 
-	* msgs/pl.msg, trans/pl.msg: Updated (thanks to Irek
-	  Chmielowiec).
+	* msgs/pl.msg, trans/pl.msg: Updated (thanks to Irek Chmielowiec).
 
 2006-11-26  Sergei Golovan  <sgolovan at nes.ru>
 

Modified: trunk/tkabber/plugins/richtext/highlight.tcl
===================================================================
--- trunk/tkabber/plugins/richtext/highlight.tcl	2006-11-29 06:49:06 UTC (rev 814)
+++ trunk/tkabber/plugins/richtext/highlight.tcl	2006-11-29 17:36:59 UTC (rev 815)
@@ -22,12 +22,6 @@
     custom::defvar options(highlight_whole_words) 1 \
 	[::msgcat::mc "Highlight only whole words in messages."] \
 	-type boolean -group Highlight
-
-    ::richtext::register_entity highlight \
-	-configurator [namespace current]::configure_richtext_widget \
-	-parser [namespace current]::process_highlights \
-	-renderer [namespace current]::render_highlight \
-	-parser-priority 60
 }
 
 proc highlight::configure_richtext_widget {w} {
@@ -141,4 +135,14 @@
     ::richtext::entity_state highlight $options(enable_highlighting)
 }
 
+namespace eval highlight {
+    ::richtext::register_entity highlight \
+	-configurator [namespace current]::configure_richtext_widget \
+	-parser [namespace current]::process_highlights \
+	-renderer [namespace current]::render_highlight \
+	-parser-priority 60
+
+    on_state_changed
+}
+
 # vim:ts=8:sw=4:sts=4:noet

Modified: trunk/tkabber/plugins/richtext/urls.tcl
===================================================================
--- trunk/tkabber/plugins/richtext/urls.tcl	2006-11-29 06:49:06 UTC (rev 814)
+++ trunk/tkabber/plugins/richtext/urls.tcl	2006-11-29 17:36:59 UTC (rev 815)
@@ -160,14 +160,15 @@
     
     set title [url_get_title $url $args]
     if {$title != {}} {
-	$w insert end $url {uri transient}
+	set uri_tag [list [list uri $url]]
 	set url $title
 	set show_hints true
     } else {
+	set url_tag [list]
 	set show_hints false
     }
 
-    $w insert end $url [lfuse $tags $privtag]
+    $w insert end $url [lfuse $tags [list $privtag] $uri_tag]
 
     $w tag add $type $url_start {end - 1 char}
 
@@ -258,14 +259,18 @@
 
 # Returns a URL containing the $x,$y point in the text widget $w:
 proc urls::get_url {w x y} {
-    lassign [$w tag prevrange url "@$x,$y"] a b
+    set tags [$w tag names "@$x,$y"]
+    set idx [lsearch $tags href_*]
+    
+    if {$idx < 0} return
 
-    set uri [$w tag nextrange uri $a $b]
-    if {$uri != {}} {
-	lassign $uri a b
+    set idx1 [lsearch $tags uri*]
+    if {$idx1 >= 0} {
+	return [lindex [lindex $tags $idx1] 1]
+    } else {
+	lassign [$w tag prevrange url "@$x,$y"] a b
+	return [$w get $a $b]
     }
-
-    $w get $a $b
 }
 
 # Copies an URL under $x,$y in $w into CLIPBOARD:



More information about the Tkabber-dev mailing list