[Tkabber-dev] r1513 - in trunk/tkabber-plugins: . quotelastmsg singularity stripes

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Oct 15 21:39:41 MSD 2008


Author: sergei
Date: 2008-10-15 21:39:41 +0400 (Wed, 15 Oct 2008)
New Revision: 1513

Added:
   trunk/tkabber-plugins/quotelastmsg/
   trunk/tkabber-plugins/quotelastmsg/AUTHORS
   trunk/tkabber-plugins/quotelastmsg/INSTALL
   trunk/tkabber-plugins/quotelastmsg/README
   trunk/tkabber-plugins/quotelastmsg/license.terms
   trunk/tkabber-plugins/quotelastmsg/msgs/
   trunk/tkabber-plugins/quotelastmsg/quotelastmsg.tcl
   trunk/tkabber-plugins/singularity/
   trunk/tkabber-plugins/singularity/AUTHORS
   trunk/tkabber-plugins/singularity/INSTALL
   trunk/tkabber-plugins/singularity/README
   trunk/tkabber-plugins/singularity/license.terms
   trunk/tkabber-plugins/singularity/msgs/
   trunk/tkabber-plugins/singularity/singularity.tcl
   trunk/tkabber-plugins/stripes/
   trunk/tkabber-plugins/stripes/AUTHORS
   trunk/tkabber-plugins/stripes/INSTALL
   trunk/tkabber-plugins/stripes/README
   trunk/tkabber-plugins/stripes/license.terms
   trunk/tkabber-plugins/stripes/stripes.tcl
Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/Makefile
   trunk/tkabber-plugins/README
Log:
	* quotelastmsg/*, singularity/*, stripes/*: Added three new plugins
	  (thanks to Konstantin Khomoutov).


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2008-10-11 13:08:59 UTC (rev 1512)
+++ trunk/tkabber-plugins/ChangeLog	2008-10-15 17:39:41 UTC (rev 1513)
@@ -1,3 +1,8 @@
+2008-10-15  Sergei Golovan <sgolovan at nes.ru>
+
+	* quotelastmsg/*, singularity/*, stripes/*: Added three new plugins
+	  (thanks to Konstantin Khomoutov).
+
 2008-08-26  Sergei Golovan <sgolovan at nes.ru>
 
 	* whiteboard/whiteboard.tcl: Converted draw actions back to radio

Modified: trunk/tkabber-plugins/Makefile
===================================================================
--- trunk/tkabber-plugins/Makefile	2008-10-11 13:08:59 UTC (rev 1512)
+++ trunk/tkabber-plugins/Makefile	2008-10-15 17:39:41 UTC (rev 1513)
@@ -26,11 +26,14 @@
 	  osd          \
 	  presencecmd  \
 	  quiz         \
+	  quotelastmsg \
 	  receipts     \
 	  renju        \
 	  reversi      \
+	  singularity  \
 	  socials      \
 	  spy          \
+	  stripes      \
 	  tclchat      \
 	  tkabber-khim \
 	  traffic      \

Modified: trunk/tkabber-plugins/README
===================================================================
--- trunk/tkabber-plugins/README	2008-10-11 13:08:59 UTC (rev 1512)
+++ trunk/tkabber-plugins/README	2008-10-15 17:39:41 UTC (rev 1513)
@@ -103,6 +103,9 @@
 quiz
     Adaptation of He3hauka (a russian quiz game for IRC).
 
+quotelastmsg
+    Quote the very last message in a chat window.
+
 receipts
     Implements XEP-0184 "Message receipts": in one-to-one chat sessions
     it is able to request confirmations of reception of outgoing
@@ -121,6 +124,9 @@
     other player has also Tkabber and the plugin installed, he will
     recieve the invitation. If he accepts, a window will open on both.
 
+singularity
+    Keep conversation with one user in one window/tab.
+
 socials
     Adds many 'social' commands like /dance. Includes english and russian
     files.
@@ -129,6 +135,9 @@
     Logs your contacts presence changes to a window or to a file. Allows
     to setup alert window for certain contacts.
 
+stripes
+    Colorises chat window background for odd and even messages differently.
+
 tclchat
     Plugin, which makes chatting in Tclers' chat (tcl at tach.tclers.tk) easier.
     It recognises a bot, which connects Jabber room with IRC channel, and maps

Added: trunk/tkabber-plugins/quotelastmsg/AUTHORS
===================================================================
--- trunk/tkabber-plugins/quotelastmsg/AUTHORS	                        (rev 0)
+++ trunk/tkabber-plugins/quotelastmsg/AUTHORS	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>


Property changes on: trunk/tkabber-plugins/quotelastmsg/AUTHORS
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/quotelastmsg/INSTALL
===================================================================
--- trunk/tkabber-plugins/quotelastmsg/INSTALL	                        (rev 0)
+++ trunk/tkabber-plugins/quotelastmsg/INSTALL	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,10 @@
+As usually, copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/quotelastmsg/
+  ~/.tkabber/plugins/quotelastmsg/quotelastmsg.tcl
+
+Restart Tkabber, to get the plugin loaded.
+
+Consult the README file for the details about using this plugin.
+


Property changes on: trunk/tkabber-plugins/quotelastmsg/INSTALL
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/quotelastmsg/README
===================================================================
--- trunk/tkabber-plugins/quotelastmsg/README	                        (rev 0)
+++ trunk/tkabber-plugins/quotelastmsg/README	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,71 @@
+$Id$
+
+"Quote last message" -- chat plugin for Tkabber.
+
+
+I. The idea
+
+This plugin provides a way to "quote" the message located at the
+very bottom of the conversation log of a chat window -- that is,
+to copy such message into the input box of the same chat window
+with some decorations added (by default the ">> " string is
+prepeneded to the message). By default, quoting is done using
+the <Alt-q> keyboard shortcut.
+
+The functionality provided by this plugin might come in handy
+when you want to refer to someone else's (or your own) message
+appeared in the course of the conversation.
+
+
+II. Configuration
+
+You can configure two parameters affecting the operation of this
+plugin: actions triggering the quotation of the last message
+and the format string used to decorate the message being quoted.
+
+Message quoting action is bound to a Tk virtual event named
+<<QuoteLastMessage>>. By default, it's bound to <Alt-q> (also to
+<Meta-q> to accound for certain Unix systems).
+To change the binding you will have to add appropriate
+command(s) to the Tkabber configuration file. For instance, to
+unbind this action from <Alt-q> and bind it to <Ctrl-Shift-m>
+write this into your condig.tcl:
+
+event delete <<QuoteLastMessage>> <Alt-q>
+event delete <<QuoteLastMessage>> <Meta-q>
+event add    <<QuoteLastMessage>> <Control-Shift-m>
+
+Full details about the "event" command can be found in [1].
+Note that you can use any event specifier, not just keyboard
+shortcuts. Refer to [2] for full details.
+
+The format string used to decorate the message being quoted can
+be changed using the Customize interface in the "Plugins ->
+Quote Last Message" group of settings (also reachable as
+"Chat -> Quote Last Message").
+The actual setting is named
+::plugins::quotelastmsg::options(format)
+and it defaults to the string ">> %m".
+
+In the format string the format specifier "%m" is substituted by
+the whole message as seen in the conversation log window, and
+the specifier "%%" is replaced by a single character "%".
+
+
+III. Bugs and limitations
+
+* There's currently no way to separately refer to the parts of
+  the message being quoted (such as its timestamp, poster's
+  nickname and the message body) in the format string.
+
+* It's impossible to embed "special chanracters" into the format
+  string (such as \n or \t).
+
+
+IV. References
+
+1. http://www.tcl.tk/man/tcl8.5/TkCmd/event.htm
+2. http://www.tcl.tk/man/tcl8.5/TkCmd/bind.htm
+
+
+vim:et:ts=4:sw=4:tw=64


Property changes on: trunk/tkabber-plugins/quotelastmsg/README
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/quotelastmsg/license.terms
===================================================================
--- trunk/tkabber-plugins/quotelastmsg/license.terms	                        (rev 0)
+++ trunk/tkabber-plugins/quotelastmsg/license.terms	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,19 @@
+Copyright (c) 2008 Konstantin Khomoutov <flatworm at users.sourceforge.net>
+
+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.


Property changes on: trunk/tkabber-plugins/quotelastmsg/license.terms
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/quotelastmsg/quotelastmsg.tcl
===================================================================
--- trunk/tkabber-plugins/quotelastmsg/quotelastmsg.tcl	                        (rev 0)
+++ trunk/tkabber-plugins/quotelastmsg/quotelastmsg.tcl	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,93 @@
+# $Id$
+# "Quote last message" chat plugin for Tkabber --
+# Allows to copy message located at the bottom of the
+# conversation log in the chat window to the input box
+# of that chat window.
+#
+# Written by Konstantin Khomoutov <flatworm at users.sourceforge.net>
+# See license.terms for the terms of distribution.
+# See README for usage details.
+
+event add <<QuoteLastMessage>> <Alt-q>
+event add <<QuoteLastMessage>> <Meta-q>
+
+namespace eval quotelastmsg {
+    variable state
+    variable options
+
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
+
+    custom::defgroup {Quote Last Message} \
+	[::msgcat::mc "Quote Last Message plugin options.\
+	    This plugin provides a way to copy a message located\
+	    at the bottom of a chat window conversation log\
+	    to the input box of that chat window."] \
+	-group Plugins \
+	-group Chat
+
+    custom::defvar options(format) {>> %m} \
+	[::msgcat::mc "Format string used to quote the message.\
+	    Format specifer \"%m\" is replaced by the whole message\
+	    being quoted. Format specifier \"%%\" is replaced by\
+	    a single character \"%\"."] \
+	-group {Quote Last Message} \
+	-type string
+
+    hook::add open_chat_post_hook \
+	[namespace current]::setup_chat_window
+    hook::add draw_message_post_hook \
+	[namespace current]::on_message_drawn
+}
+
+proc quotelastmsg::setup_chat_window {chatid type} {
+    variable state
+
+    set iw [::chat::input_win $chatid]
+    bind $iw <<QuoteLastMessage>> [list [namespace current]::quote $chatid]
+
+    set cw [::chat::chat_win $chatid]
+    set state($cw,last) 1.0
+    bind $cw <Destroy> +[list [namespace current]::cleanup $cw %W]
+}
+
+proc quotelastmsg::cleanup {w1 w2} {
+    if {![string equal $w1 $w2]} return
+
+    variable state
+    unset state($w1,last)
+}
+
+proc quotelastmsg::on_message_drawn {chatid from type body x} {
+    if {![chat::is_opened $chatid]} return
+
+    set cw [::chat::chat_win $chatid]
+
+    variable state
+    upvar 0 state($cw,last) last
+
+    set now [$cw index {end - 1 char}]
+    if {[$cw compare $last < $now]} {
+	$cw tag delete lastmsg
+	$cw tag add lastmsg $last $now
+    }
+
+    set last $now
+}
+
+proc quotelastmsg::quote chatid {
+    variable options
+
+    set cw [::chat::chat_win $chatid]
+    set iw [::chat::input_win $chatid]
+
+    set range [$cw tag prevrange lastmsg end]
+    if {$range == ""} return
+    lassign $range x y
+    $iw insert end [string map \
+	[list %% % %m [$cw get $x $y]] $options(format)]
+    $iw see end
+}
+
+# vim:ts=8:sw=4:sts=4:noet


Property changes on: trunk/tkabber-plugins/quotelastmsg/quotelastmsg.tcl
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/singularity/AUTHORS
===================================================================
--- trunk/tkabber-plugins/singularity/AUTHORS	                        (rev 0)
+++ trunk/tkabber-plugins/singularity/AUTHORS	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>


Property changes on: trunk/tkabber-plugins/singularity/AUTHORS
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/singularity/INSTALL
===================================================================
--- trunk/tkabber-plugins/singularity/INSTALL	                        (rev 0)
+++ trunk/tkabber-plugins/singularity/INSTALL	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,10 @@
+As usually, copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/singularity/
+  ~/.tkabber/plugins/singularity/singularity.tcl
+
+Restart Tkabber, to get the plugin loaded.
+
+Consult the README file for the details about using this plugin.
+


Property changes on: trunk/tkabber-plugins/singularity/INSTALL
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/singularity/README
===================================================================
--- trunk/tkabber-plugins/singularity/README	                        (rev 0)
+++ trunk/tkabber-plugins/singularity/README	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,65 @@
+$Id$
+"Singularity" -- main interface plugin for Tkabber.
+
+
+I. The Idea
+
+When you chat with someone in Tkabber, the corresponding chat
+window is opened for the full JID of that person (it is a JID
+with the resource part: node at server/resource). Since your peers
+can normally log into their XMPP accounts several times at once
+(with a different resource each time) Tkabber maintains clear
+distinction between these full JIDs.
+On the other hand, most people seldom chat from several
+connections to their account at once -- quite more often they
+move between two or more XMPP clients located in places which
+are geographically quite apart, such as their home and office.
+In this case it may be convenient to maintain just one chat
+window open for each person you're chatting with -- for
+instance, you start chatting whith your peer when he/she is at
+home, then your peer moves to their office and sends a message
+from the new location; at this point it might be convenient not
+to have two chat windows -- old and new -- open, but just the
+new one.
+
+This plugin implements the described functionality: when the new
+window for a one-on-one chat is about to be opened the plugin
+checks whether there are any active chat sessions with the same
+bare JID (that is, without the "/resource" part) as that of the
+new chat. If there are, they are closed with their conversation
+log and input history preserved, the new chat window is opened
+and then the saved data is inserted into the new window. 
+So effectively this plugin makes Tkabber keep just one chat
+window per bare JID open.
+
+The plugin does not touch MUC private chats because in them
+resource part of the room JID is used to designate participants'
+nicknames.
+
+
+II. Usage
+
+Just install this plugin as usually and restart Tkabber.
+Currently there's no UI to control the plugin's behaviour.
+
+
+III. Bugs and limitations
+
+* Tkabber is currently unable to actually "switch" a chat window
+  from one JID to another, so this plugin works by closing the
+  existing window(s) and opening the new one. While in tabbed
+  mode this looks mostly OK, in windowed mode this may be
+  annoying because the new window will most probably not appear
+  at the same location and layer as the closed window.
+
+* For some unknown reason the first line of the input history is
+  lost when the chat state is transferred to the newly opened
+  window.
+
+* If there are several chat windows to be closed when the new
+  one is about to be opened, the order in which their
+  conversation logs and input history records are collected
+  is undefined.
+
+
+# vim:tw=64:noet


Property changes on: trunk/tkabber-plugins/singularity/README
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/singularity/license.terms
===================================================================
--- trunk/tkabber-plugins/singularity/license.terms	                        (rev 0)
+++ trunk/tkabber-plugins/singularity/license.terms	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,19 @@
+Copyright (c) 2008 Konstantin Khomoutov <flatworm at users.sourceforge.net>
+
+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.


Property changes on: trunk/tkabber-plugins/singularity/license.terms
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/singularity/singularity.tcl
===================================================================
--- trunk/tkabber-plugins/singularity/singularity.tcl	                        (rev 0)
+++ trunk/tkabber-plugins/singularity/singularity.tcl	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,88 @@
+# $Id$
+# When a new chat window is about to be opened this plugin
+# checks whether any chats with other resources of this chat peer
+# are currently opened and closes them all, if any.
+# In other words, it ensures that only one chat window per bare
+# JID is opened at any given time.
+# Written by Konstantin Khomoutov <flatworm at users.sourceforge.net>
+# See license.terms for the terms of distribution.
+# See README for usage details.
+
+namespace eval singularity {
+    variable contexts
+    variable options
+
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
+
+    custom::defgroup Singularity \
+	[::msgcat::mc "Singularity plugin options.\
+	    What this plugin makes is to do cleanup by closing obsolete\
+	    chat windows opened for different resources of the same\
+	    contact ensuring only one chat window for a contact\
+	    is opened at any given time."] \
+	-group Plugins \
+	-group IFace
+
+    custom::defvar options(enabled) 1 \
+	[::msgcat::mc "Allows closing obsolete chat windows\
+	    for a contact when a new chat session window\
+	    with that contact is about to be opened."] \
+	-group Singularity \
+	-type boolean
+
+    hook::add open_chat_pre_hook \
+	[namespace current]::process_new_chat_opening
+    hook::add open_chat_post_hook \
+	[namespace current]::restore_chat_context
+}
+
+proc singularity::process_new_chat_opening {chatid type} {
+    variable options
+    if {!$options(enabled) || ![string equal $type chat]} return
+
+    set from [chat::get_jid $chatid]
+    set barejid [node_and_server_from_jid $from]
+    if {[chat::is_groupchat [chat::chatid \
+	[chat::get_connid $chatid] $barejid]]} return
+
+    variable contexts
+    upvar 0 contexts(input,$chatid) savedinput
+    upvar 0 contexts(history,$chatid) savedhistory
+    variable [namespace parent]::history
+
+    set savedinput ""
+    set savedhistory [list]
+
+    foreach cid [chat::opened] {
+	set jid [chat::get_jid $cid]
+	if {![string equal $from $jid] &&
+		[string equal $barejid [node_and_server_from_jid $jid]]} {
+	    if {$savedinput != ""} { append savedinput \n }
+	    append savedinput [[chat::input_win $cid] get 1.0 end-1c]
+	    set savedhistory [concat $savedhistory $history(stack,$cid)]
+	    chat::close $cid
+	}
+    }
+}
+
+proc singularity::restore_chat_context {chatid type} {
+    variable options
+    if {!$options(enabled) || ![string equal $type chat]} return
+
+    variable contexts
+    upvar 0 contexts(input,$chatid) savedinput
+    upvar 0 contexts(history,$chatid) savedhistory
+    if {![info exists savedinput]} return
+
+    variable [namespace parent]::history
+
+    [chat::input_win $chatid] insert end $contexts(input,$chatid)
+    set history(stack,$chatid) $contexts(history,$chatid)
+    set history(pos,$chatid)   0
+
+    unset contexts(input,$chatid) contexts(history,$chatid)
+}
+
+# vim:ts=8:sw=4:sts=4:noet


Property changes on: trunk/tkabber-plugins/singularity/singularity.tcl
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/stripes/AUTHORS
===================================================================
--- trunk/tkabber-plugins/stripes/AUTHORS	                        (rev 0)
+++ trunk/tkabber-plugins/stripes/AUTHORS	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>


Property changes on: trunk/tkabber-plugins/stripes/AUTHORS
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/stripes/INSTALL
===================================================================
--- trunk/tkabber-plugins/stripes/INSTALL	                        (rev 0)
+++ trunk/tkabber-plugins/stripes/INSTALL	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,13 @@
+As usually, copy this directory under the ~/.tkabber/plugins directory
+so that you get a hierarchy like this:
+  ~/.tkabber/plugins
+  ~/.tkabber/plugins/stripes/
+  ~/.tkabber/plugins/stripes/stripes.tcl
+
+Restart Tkabber, to get the plugin loaded.
+
+Consult the README file for the details about using this plugin.
+Usually you'll want to set the stripes' color which can be done
+either via XRDB (on Unix) or using Tk option database (on any
+system).
+


Property changes on: trunk/tkabber-plugins/stripes/INSTALL
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/stripes/README
===================================================================
--- trunk/tkabber-plugins/stripes/README	                        (rev 0)
+++ trunk/tkabber-plugins/stripes/README	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,64 @@
+$Id$
+
+"Stripes" -- chat plugin for Tkabber.
+
+
+I. The Idea
+
+This plugin allows to colorize backgrounds of the whole
+messages placed in the conversation logs of Tkabber chat
+windows. Backgrounds of even and odd messages can be
+configured separately from each other (or not configured
+at all).
+
+
+II. Usage
+
+The colors of even and odd messages can be manipulated using the
+Tk option database resources which are:
+
+* Chat.oddBackground for odd messages.
+
+* Chat.evenBackground for even messages.
+
+When the particular resource is not defined, it's not used thus
+not affecting the appearance of the corresponding messages.
+
+By default these resources are not defined.
+
+The color may be specified in any form accepted by Tk which mean
+any named color (from the X server's color database on
+systems using X Window or listed in [1] on other systems) or the
+color specification such as #RRGGBB.
+For the strict explanation or color specifications read [2].
+
+
+III. Examples
+
+1) To set up gray colors using the Tkabber configuration file
+   add these lines to your config.tcl file:
+
+# Colors for the stripes plugin:
+option add *Chat.oddBackground  gray77
+option add *Chat.evenBackground gray84
+
+2) To do the same using XRDB (systems based on X Window):
+
+! Colors for the stripes plugin:
+Tkabber*Chat.oddBackground:  AntiqueWhite
+Tkabber*Chat.evenBackground: bisque
+
+
+IV. Bugs and limitations
+
+* Changing any color resource at runtime won't affect already
+  opened chat windows.
+
+
+V. References
+
+1. http://www.tcl.tk/man/tcl8.5/TkCmd/colors.htm
+2. http://www.tcl.tk/man/tcl8.5/TkLib/GetColor.htm
+
+
+# vim:tw=64:noet


Property changes on: trunk/tkabber-plugins/stripes/README
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/stripes/license.terms
===================================================================
--- trunk/tkabber-plugins/stripes/license.terms	                        (rev 0)
+++ trunk/tkabber-plugins/stripes/license.terms	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,19 @@
+Copyright (c) 2007, 2008 Konstantin Khomoutov <flatworm at users.sourceforge.net>
+
+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.


Property changes on: trunk/tkabber-plugins/stripes/license.terms
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/stripes/stripes.tcl
===================================================================
--- trunk/tkabber-plugins/stripes/stripes.tcl	                        (rev 0)
+++ trunk/tkabber-plugins/stripes/stripes.tcl	2008-10-15 17:39:41 UTC (rev 1513)
@@ -0,0 +1,74 @@
+# $Id$
+# "Stripes" chat plugin for Tkabber -- colorizes background of
+# whole messages in chat windows.
+#
+# Written by Konstantin Khomoutov <flatworm at users.sourceforge.net>
+# See license.terms for the terms of distribution.
+# See README for usage details.
+
+# Color for odd and even messages can be tuned separately
+# using the Tk option database (or XRDB) like this:
+# option add *Chat.oddBackground  gray77
+# option add *Chat.evenBackground gray84
+
+namespace eval stripes {
+    variable state
+
+    hook::add open_chat_post_hook \
+	[namespace current]::setup_chat_window
+    hook::add draw_message_post_hook \
+	[namespace current]::on_message_drawn
+}
+
+proc stripes::setup_chat_window {chatid type} {
+    variable state
+
+    set cw [::chat::chat_win $chatid]
+    set mw [::chat::winid $chatid]
+
+    set bgodd [option get $mw oddBackground Chat]
+    if {$bgodd != ""} {
+	$cw tag configure odd -background $bgodd
+    }
+    set bgeven [option get $mw evenBackground Chat]
+    if {$bgeven != ""} {
+	$cw tag configure even -background $bgeven
+    }
+
+    set state($cw,last) 1.0
+    set state($cw,tag) odd
+
+    bind $cw <Destroy> +[list [namespace current]::cleanup $cw %W]
+}
+
+proc stripes::cleanup {w1 w2} {
+    if {![string equal $w1 $w2]} return
+
+    variable state
+    unset state($w1,last)
+    unset state($w1,tag)
+}
+
+proc stripes::on_message_drawn {chatid from type body x} {
+    if {![chat::is_opened $chatid]} return
+
+    set cw [::chat::chat_win $chatid]
+
+    variable state
+    upvar 0 state($cw,last) last
+    upvar 0 state($cw,tag)  tag
+
+    set now [$cw index {end - 1 char}]
+    if {[$cw compare $last < $now]} {
+	$cw tag add $tag $last $now
+	if {[string equal $tag even]} {
+	    set tag odd
+	} else {
+	    set tag even
+	}
+    }
+
+    set last $now
+}
+
+# vim:ts=8:sw=4:sts=4:noet


Property changes on: trunk/tkabber-plugins/stripes/stripes.tcl
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native



More information about the Tkabber-dev mailing list