[Tkabber-dev] r144 - in trunk/plugins: . quotelastmsg

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Oct 12 19:01:08 MSD 2008


Author: kostix
Date: 2008-10-12 19:01:08 +0400 (Sun, 12 Oct 2008)
New Revision: 144

Added:
   trunk/plugins/quotelastmsg/
   trunk/plugins/quotelastmsg/AUTHORS
   trunk/plugins/quotelastmsg/INSTALL
   trunk/plugins/quotelastmsg/README
   trunk/plugins/quotelastmsg/license.terms
   trunk/plugins/quotelastmsg/msgs/
   trunk/plugins/quotelastmsg/quotelastmsg.tcl
Log:
quotelastmsg: Initial import of the "quotelastmsg" chat plugin
 which provides a way to quote the last message in the
 conversation log of a chat window.


Copied: trunk/plugins/quotelastmsg/AUTHORS (from rev 141, trunk/plugins/stripes/AUTHORS)
===================================================================
--- trunk/plugins/quotelastmsg/AUTHORS	                        (rev 0)
+++ trunk/plugins/quotelastmsg/AUTHORS	2008-10-12 15:01:08 UTC (rev 144)
@@ -0,0 +1 @@
+Konstantin Khomoutov <flatworm at users.sourceforge.com>

Copied: trunk/plugins/quotelastmsg/INSTALL (from rev 141, trunk/plugins/stripes/INSTALL)
===================================================================
--- trunk/plugins/quotelastmsg/INSTALL	                        (rev 0)
+++ trunk/plugins/quotelastmsg/INSTALL	2008-10-12 15:01:08 UTC (rev 144)
@@ -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.
+

Added: trunk/plugins/quotelastmsg/README
===================================================================
--- trunk/plugins/quotelastmsg/README	                        (rev 0)
+++ trunk/plugins/quotelastmsg/README	2008-10-12 15:01:08 UTC (rev 144)
@@ -0,0 +1,28 @@
+$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
+
+
+III. References
+
+1. http://www.tcl.tk/man/tcl8.5/TkCmd/event.htm
+
+
+vim:et:ts=4:sw=4:tw=64


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

Copied: trunk/plugins/quotelastmsg/license.terms (from rev 141, trunk/plugins/singularity/license.terms)
===================================================================
--- trunk/plugins/quotelastmsg/license.terms	                        (rev 0)
+++ trunk/plugins/quotelastmsg/license.terms	2008-10-12 15:01:08 UTC (rev 144)
@@ -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.

Added: trunk/plugins/quotelastmsg/quotelastmsg.tcl
===================================================================
--- trunk/plugins/quotelastmsg/quotelastmsg.tcl	                        (rev 0)
+++ trunk/plugins/quotelastmsg/quotelastmsg.tcl	2008-10-12 15:01:08 UTC (rev 144)
@@ -0,0 +1,91 @@
+# $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 the message located\
+	    at the bottom of the conversation log of a chat window\
+	    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} {
+    variable state
+
+    set cw [::chat::chat_win $chatid]
+    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/plugins/quotelastmsg/quotelastmsg.tcl
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native



More information about the Tkabber-dev mailing list