# # tkMOO # ~/.tkMOO-lite/plugins/linelen.tcl # # tkMOO-light is Copyright (c) Andrew Wilson 1994,1995,1996,1997,1998,1999. # # 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 linelen start proc linelen.start {} { # window manager sends the event when the window is resized. bind .output linelen.configure # set up a new directive in the Preferences Editor preferences.register client {Special Forces} { { {directive SendLinelen} {type boolean} {default Off} {display "Send linelength"} } } } proc linelen.configure {} { # how many fixedwidth characters wide is the client window? set geometry [wm geometry .] regexp {^([0-9]*)x} $geometry all width # catch all this, because our API can't easily tell us if we're # connected, and events happen pretty much at the # wim of the Window manager. catch { #if we're using a fixedwidth font for this world, and we've # set the 'Send linelength' value in the Preferences Editor # then send the @linelength command. set fonttype [worlds.get_generic fixedwidth {} {} DefaultFont] set linelen [worlds.get_generic Off {} {} SendLinelen] if { ($fonttype == "fixedwidth") && ([string tolower $linelen] == "on") } { io.outgoing "@linelength $width" } } }