[WJG] (04/11/07) Here's the gnocl::text equivalent. Those who already use [gnocl] may be aware that the current release has no text bindings for either the widget or tags. I use a development version which has the appropriate bindings. For those who are interested, before the next official release occurs, send me an email and I can forward details. ---- ====== #--------------- # gncolBalanceQuotes.tcl #--------------- # William J Giddings # 04/11/07 #--------------- # Enable context sensitive quotations. # If the input quote mark is preceded by a printable character, # then closequote otherwise openquote! # #--------------- # Notes: # This is not "smart" and so does attempt to ballance quote marks. # The swap is made on the KeyRelease event so the swap will only # effect the final quote if a key repeat event occurs. #--------------- #!/bin/sh \ exec tclsh "$0" "$@" package require Gnocl ;# Tcl-Gtk+ bindings #--------------- # w text widget into which the substition is to be made # c character currently inserted # # Codes: # single openquote ` \u2018 # closequote ' \u2019 # double openquote " \u201C # closequote " \u201D # # ' quoteright # # quotedbl #--------------- proc balanceQuotes {w c} { #get the preceding character set idx [ $w getCursor ] set str [ $w get cursor-1 ] if {$str == "" || [string is space $str] || $str == "\u2018" || $str == "\u201C" } { set str " " } # if the last code entered was ' if {$c == "quoteright" } { $w erase cursor if {$str == " "} { # openquote $w insert cursor "\u2018" } else { # closequote $w insert cursor "\u2019" } } # or, if was " if {$c == "quotedbl" } { $w erase cursor if {$str == " "} { # openquote $w insert cursor "\u201C" } else { # closequote $w insert cursor "\u201D" } } } #--------------- # Demo #--------------- set txt [gnocl::text -baseFont {Sans 25} \ -onKeyRelease {balanceQuotes %w %K}] gnocl::window -title BalanceQuotes \ -child $txt \ -onDestroy exit \ -width 250 ====== ---- [FF] 2008-07-19 - I tried running that demo, bt I encountered some errors: bad option "-baseFont": must be -scrollbar, -pixelsInsideWrap, -pixelsBelowLines, -pixelsAboveLines, -editable, -wrapMode, -justify, -leftMargin, -rightMargin, -indent, -cursorVisible, -hasFocus, -tooltip, -onShowHelp, -name, -visible, or -sensitive and: bad option "-onKeyRelease": must be -scrollbar, -pixelsInsideWrap, -pixelsBelowLines, -pixelsAboveLines, -editable, -wrapMode, -justify, -leftMargin, -rightMargin, -indent, -cursorVisible, -hasFocus, -tooltip, -onShowHelp, -name, -visible, or -sensitive my Gnocl version is 0.9.91, is not latest version? [WJG] (20/07/08) Firstly, thanks for trying the script and I hope that you continue to explore the use of gnocl. The options that you list there are available on the next release of gnocl which I'm currently working on. In fact there a number of feature enhancements to the text widget including the inclusion of two additional tag commands "add" and "remove" and mouse event trapping with a new switch -onEvent. I'm planning to make a release of these changes plus some additional Gtk widgets not available at the moment (toggleButton, linkButton, scaleButton, volumeButton and hnadleBox) but, if you want a copy of the working version I'm currently using I'd be happy to email this to you, email:giddings@freeuk.com. [FF] 2008-07-20 - I'm very happy to hear that Gnocl development is currently active! :-) I'd like to help for what I can. I obviously know Tcl, but also have a little knowledge of the C API. I started looking at Gnocl very recently; I'll report you my suggestions and my findings if you are interested. For now, what I'd like to change is: * make the programming syntax for gnocl as closest as possible to the tk one. * I found cget is missing for widgets ---- !!!!!! %|[Category GUI]|% !!!!!!