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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Sep 4 23:22:49 MSD 2010


Author: ancestor
Date: 2010-09-04 23:22:49 +0400 (Sat, 04 Sep 2010)
New Revision: 380

Modified:
   trunk/plugins/highlightex/highlightex.tcl
   trunk/plugins/highlightex/msgs/ru.msg
Log:
1) Bold font support was added for extended messages highlight in highlightex.tcl.

Modified: trunk/plugins/highlightex/highlightex.tcl
===================================================================
--- trunk/plugins/highlightex/highlightex.tcl	2010-09-02 23:22:25 UTC (rev 379)
+++ trunk/plugins/highlightex/highlightex.tcl	2010-09-04 19:22:49 UTC (rev 380)
@@ -1,137 +1,174 @@
 # Copyright (c) 2010 ancestor <xmpp: ancestor at jabber.org>
-# Extended Highlight plugin v0.6
+# Extended Highlight plugin v0.7
 # Special thanks to teo.
 
 namespace eval highlightex {
-	::msgcat::mcload [file join [file dirname [info script]] msgs]
+    ::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
+    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::defvar options(highlight_color) red3 \
-	[::msgcat::mc "Color for highlight."] \
-	-type string -group Highlightex \
-	-command [namespace current]::set_highlight_color
+    custom::defvar options(use_bold_font) 0 \
+	[::msgcat::mc "Use bold font for highlight."] \
+	-type boolean -group Highlightex \
+    -command [namespace current]::set_bold_font
+
+    custom::defvar options(highlight_color) red3 \
+    [::msgcat::mc "Highlight color."] \
+    -type string -group Highlightex \
+    -command [namespace current]::set_highlight_color
 }
 
 ########################################################################################
 
 proc highlightex::process_highlights_ex {atLevel accVar} {
-	upvar #$atLevel $accVar chunks
-	
-	variable options
+    upvar #$atLevel $accVar chunks
+    
+    variable options
 
-	set out {}
-	set allstr ""
-	set fnick 0
-	set nick ""
+    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 {$tags == "server" || $tags == "highlight" || $s == " "} {
-			# pass through
-			lappend out $s $type $tags
-			continue
-		}	
-				
-		if {$fnick == 1} {	
-			set tags highlight
-		}
-		lappend out $s $type $tags
-	}
-	set chunks $out
+    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 {$tags == "server" || $tags == "highlightex" || $s == " "} {
+            # pass through
+            lappend out $s $type $tags
+            continue
+        }
+                
+        if {$fnick == 1} {
+            set tags highlightex
+        }
+        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"]
+    variable options
+    
+    set tags [$chatwin tag names "@$x,$y"]
 
-	set hght_tag ""
+    set hght_tag ""
 
-	set hght_col $options(highlight_color)
+    set hght_col $options(highlight_color)
 
-	if {[set idx [lsearch -glob $tags highlight*]] >= 0} {
-		set hght_tag [lindex $tags $idx]
-	}
-	
-	if {$hght_tag == ""} return	
+    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]
+    $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
+    variable options
 
-	set new [tk_chooseColor -initialcolor $hght_col \
-		-title [::msgcat::mc "Edit highlight color"]]
+    set new [tk_chooseColor -initialcolor $hght_col \
+        -title [::msgcat::mc "Edit highlight color"]]
 
-	if {$new == ""} return
+    if {$new == ""} return
 
-	set options(highlight_color) $new
+    set options(highlight_color) $new
 }
 
 proc highlightex::set_highlight_color {args} {
-	variable options
-	set hcolor $options(highlight_color)
+    variable options
+    set hcolor $options(highlight_color)
 
-	option add *Chat.highlightforeground $hcolor
+    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
-		}
-	}
+    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 highlightex -foreground $hcolor
+        }
+    }
 }
 
+proc highlightex::set_bold_font {args} {
+    variable options
+    set hcolor $options(highlight_color)
+
+    foreach tmpchatid [array names ::chat::chat_id] {
+        set chatid $::chat::chat_id($tmpchatid)
+        
+        if {[chat::is_groupchat $chatid]} {
+            set w [chat::chat_win $chatid]
+
+            if {$options(use_bold_font)} {
+                $w tag configure highlightex -foreground $hcolor -font $::ChatBoldFont
+            } else {
+                $w tag configure highlightex -foreground $hcolor -font $::ChatFont
+            }
+        }
+    }
+}
+
+proc highlightex::configure_highlightex_tag {w} {
+    variable options
+    set hcolor $options(highlight_color)
+    
+    if {$options(use_bold_font)} {
+        $w tag configure highlightex -foreground $hcolor -font $::ChatBoldFont
+    }
+}
+
 ########################################################################################
 
 proc highlightex::load {} {	
-	if {[lsearch $::richtext::registered highlightex] == -1} {
-		::richtext::register_entity highlightex \
-			-parser [namespace current]::process_highlights_ex \
-			-parser-priority 60
-	}
+    custom::defgroup Highlightex [::msgcat::mc "Highlightex options."] -group Plugins -type visible
 
-	hook::add chat_win_popup_menu_hook [namespace current]::add_chat_win_popup_highlightex_menu 10
+    if {[lsearch $::richtext::registered highlightex] == -1} {
+        ::richtext::register_entity highlightex \
+        	-configurator [namespace current]::configure_highlightex_tag \
+            -parser [namespace current]::process_highlights_ex \
+            -parser-priority 60
+    }
 
-	::richtext::entity_state highlightex 1
+    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
+    ::richtext::entity_state highlightex 0
 
-	option add *Chat.highlightforeground red3
+    option add *Chat.highlightforeground red3
 
-	hook::remove chat_win_popup_menu_hook [namespace current]::add_chat_win_popup_highlightex_menu 10
+    hook::remove chat_win_popup_menu_hook [namespace current]::add_chat_win_popup_highlightex_menu 10
+
+    custom::defgroup Highlightex [::msgcat::mc "Highlightex options."] -group Plugins -type hidden
 }
\ No newline at end of file

Modified: trunk/plugins/highlightex/msgs/ru.msg
===================================================================
--- trunk/plugins/highlightex/msgs/ru.msg	2010-09-02 23:22:25 UTC (rev 379)
+++ trunk/plugins/highlightex/msgs/ru.msg	2010-09-04 19:22:49 UTC (rev 380)
@@ -1,3 +1,6 @@
 ::msgcat::mcset ru "Whether the Highlightex plugin is loaded." "Загружен ли плагин Highlightex."
+::msgcat::mcset ru "Highlightex options." "Настройки подсветки сообщений с ником."
 ::msgcat::mcset ru "Edit highlight color..." "Изменение цвета подсветки сообщений..."
-::msgcat::mcset ru "Edit highlight color" "Изменение цвета подсветки"
\ No newline at end of file
+::msgcat::mcset ru "Edit highlight color" "Изменение цвета подсветки"
+::msgcat::mcset ru "Use bold font for highlight." "Использовать жирный шрифт."
+::msgcat::mcset ru "Highlight color." "Цвет подстветки."
\ No newline at end of file



More information about the Tkabber-dev mailing list