# # tkMOO # ~/.tkMOO-lite/plugins/scoop.tcl # # tkMOO-light is Copyright (c) Andrew Wilson 1994,1995,1996,1997,1998,1999 # 2000,2001 # # All Rights Reserved # # Permission is hereby granted to use this software for private, academic # and non-commercial use. No commercial or profitable use of this # software may be made without the prior permission of the author. # # THIS SOFTWARE IS PROVIDED BY ANDREW WILSON ``AS IS'' AND ANY # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANDREW WILSON BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. client.register scoop start client.register scoop incoming 10 proc scoop.start {} { window.menu_tools_add "Scoop..." scoop.scoop_to_html } proc scoop.incoming event { # generate a unique timestamp tag for this line now anything # written which resulted from this line will carry the timestamp set tag scoop_[clock seconds] window.remove_matching_tags scoop_* window.contribute_tags $tag return [modules.module_deferred] } proc scoop.scoop {} { # which lines are selected set from "" set to "" catch { set from [.output index {sel.first linestart}] set to [.output index {sel.last - 1 char linestart}] } # was there a selection? if { $from == "" } { return } set scoop {} # scan through the text looking for tags on the 1st character for {set num $from} {$num <= $to} {set num [expr $num + 1.0]} { set tags [.output tag names $num] set time 000000000 regexp {scoop_([\-0-9]*)} $tags _ time # one of these will be the timestamp... set text [.output get $num "$num lineend"] regsub "\n$" $text "" text lappend scoop [list $time $text] } return $scoop } proc scoop.wrap_line {string num} { set lines {} set tmp "" foreach word [split $string " "] { if { [string length "$tmp $word"] < $num } { append tmp "$word " } { lappend lines $tmp set tmp "$word " } } lappend lines $tmp return $lines } proc scoop.scoop_to_html {} { set scoop [scoop.scoop] if { $scoop == {} } { return } set html "\n
\n