[Tkabber-dev] r309 - in trunk/plugins: . highlightex highlightex/msgs

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Feb 23 01:04:18 MSK 2010


Author: ancestor
Date: 2010-02-23 01:04:18 +0300 (Tue, 23 Feb 2010)
New Revision: 309

Added:
   trunk/plugins/highlightex/
   trunk/plugins/highlightex/INSTALL
   trunk/plugins/highlightex/highlightex.tcl
   trunk/plugins/highlightex/license.terms
   trunk/plugins/highlightex/msgs/
   trunk/plugins/highlightex/msgs/ru.msg
Log:
1) New plugin: highlightex.tcl - allows to highlight messages with current nickname.

Added: trunk/plugins/highlightex/INSTALL
===================================================================
--- trunk/plugins/highlightex/INSTALL	                        (rev 0)
+++ trunk/plugins/highlightex/INSTALL	2010-02-22 22:04:18 UTC (rev 309)
@@ -0,0 +1,15 @@
+To install this plugin just place its directory (highlightex) 
+into Tkabber's plugin directory. Most likely it is either 
+~/.tkabber/plugins
+or
+X:\Documents and Settings\YourUser\Application Data\Tkabber\plugins
+where X: is the drive your system is installed on.
+
+So, you'll have something like this:
+~/.tkabber/plugins/highlightex/highlightex.tcl
+or
+X:\Documents and Settings\YourUser\Application Data\Tkabber\plugins\highlightex\highlightex.tcl
+
+After that you have to restart Tkabber and go to 
+Customize -> Plugins Management and enable the plugin 
+in order to get its functionality.

Added: trunk/plugins/highlightex/highlightex.tcl
===================================================================
--- trunk/plugins/highlightex/highlightex.tcl	                        (rev 0)
+++ trunk/plugins/highlightex/highlightex.tcl	2010-02-22 22:04:18 UTC (rev 309)
@@ -0,0 +1,134 @@
+# Copyright (c) 2010 ancestor <xmpp: ancestor at jabber.org>
+# Extended Highlight plugin v0.5
+# Special thanks to teo.
+
+namespace eval highlightex {
+	::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+	if {![::plugins::is_registered highlightex]} {
+		::plugins::register highlightex \
+				-namespace [namespace current] \
+				-source [info script] \
+				-description [::msgcat::mc "Whether the Highlightex plugin is loaded."] \
+				-loadcommand [namespace code load] \
+				-unloadcommand [namespace code unload]
+		return
+	}
+	
+	custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
+	custom::defgroup Highlightex [::msgcat::mc "Highlightex options."] -group Plugins -type hidden
+
+	custom::defvar options(highlight_color) red3 \
+	[::msgcat::mc "Color for highlight."] \
+	-type string -group Highlightex \
+	-command [namespace current]::set_highlight_color
+}
+
+########################################################################################
+
+proc highlightex::process_highlights_ex {atLevel accVar} {
+    upvar #$atLevel $accVar chunks
+	
+    variable options
+
+    set out {}
+	set allstr ""
+	set fnick 0
+	set nick ""
+	
+	foreach {s type tags} $chunks {
+		if {$allstr == ""} {
+			set allstr $s	
+		} else {
+			set allstr "$allstr $s"
+		}
+	}
+	
+	if {[::richtext::property_exists mynick]} {
+		set nick [::richtext::property_get mynick]
+		set re_esc_nick [::plugins::emoticons::re_escape $nick]
+				
+		if {[regexp $re_esc_nick $allstr] == 1} {	
+			set fnick 1
+		}
+	}
+	
+    	foreach {s type tags} $chunks {
+		if {$type != "text" || $tags == "server" || $s == " "} {
+			# pass through
+			lappend out $s $type $tags
+			continue
+		}	
+				
+		if {$fnick == 1} {	
+			set tags highlight
+		}
+		lappend out $s $type $tags
+	}
+	set chunks $out
+}
+
+proc highlightex::add_chat_win_popup_highlightex_menu {m chatwin X Y x y} {
+	variable options
+	
+	set tags [$chatwin tag names "@$x,$y"]
+
+	set hght_tag ""
+
+	set hght_col $options(highlight_color)
+
+	if {[set idx [lsearch -glob $tags highlight*]] >= 0} {
+		set hght_tag [lindex $tags $idx]
+	}
+	
+	if {$hght_tag == ""} return	
+
+	$m add command -label [::msgcat::mc "Edit highlight color..."] \
+	-command [list [namespace current]::edit_highlight_color $chatwin $hght_col]
+}
+
+proc highlightex::edit_highlight_color {chatwin hght_col} {
+	variable options
+
+	set new [tk_chooseColor -initialcolor $hght_col \
+		-title [::msgcat::mc "Edit highlight color"]]
+
+	if {$new == ""} return
+
+	set options(highlight_color) $new
+}
+
+proc highlightex::set_highlight_color {args} {
+	variable options
+	set hcolor $options(highlight_color)
+
+	option add *Chat.highlightforeground $hcolor
+
+	foreach tmpchatid [array names ::chat::chat_id] {
+		set chatid $::chat::chat_id($tmpchatid)
+		
+		if {[chat::is_groupchat $chatid]} {
+			set w [chat::chat_win $chatid]
+			$w tag configure highlight -foreground $hcolor
+		}
+	}
+}
+
+########################################################################################
+
+proc highlightex::load {} {
+	::richtext::register_entity highlightex \
+		-parser [namespace current]::process_highlights_ex \
+		-parser-priority 60
+	
+	hook::add chat_win_popup_menu_hook [namespace current]::add_chat_win_popup_highlightex_menu 10
+
+	::richtext::entity_state highlightex 1
+}
+
+proc highlightex::unload {} {
+	::richtext::entity_state highlightex 0
+	option add *Chat.highlightforeground red3
+
+	hook::remove chat_win_popup_menu_hook [namespace current]::add_chat_win_popup_highlightex_menu 10
+}
\ No newline at end of file

Added: trunk/plugins/highlightex/license.terms
===================================================================
--- trunk/plugins/highlightex/license.terms	                        (rev 0)
+++ trunk/plugins/highlightex/license.terms	2010-02-22 22:04:18 UTC (rev 309)
@@ -0,0 +1,19 @@
+Copyright (c) 2010 ancestor <xmpp:ancestor at jabber.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.

Added: trunk/plugins/highlightex/msgs/ru.msg
===================================================================
--- trunk/plugins/highlightex/msgs/ru.msg	                        (rev 0)
+++ trunk/plugins/highlightex/msgs/ru.msg	2010-02-22 22:04:18 UTC (rev 309)
@@ -0,0 +1,3 @@
+::msgcat::mcset ru "Whether the Highlightex plugin is loaded." "Загружен ли плагин Highlightex."
+::msgcat::mcset ru "Edit highlight color..." "Изменение цвета подсветки сообщений..."
+::msgcat::mcset ru "Edit highlight color" "Изменение цвета подсветки"
\ No newline at end of file



More information about the Tkabber-dev mailing list