home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.tcl
- Path: sparky!uunet!decwrl!parc!welch
- From: welch@parc.xerox.com (Brent Welch)
- Subject: Re: Request: Anybody have a tk-based "Tcl Listener" implemented?
- Message-ID: <welch.715132269@corvina>
- Sender: news@parc.xerox.com
- Organization: Xerox PARC
- References: <VEK.92Aug20161320@rover.allegra.att.com>
- Distribution: comp
- Date: 29 Aug 92 23:51:09 GMT
- Lines: 52
-
- The mxedit editor uses an entry widget as a TCL command interpreter.
- Here is the main procedure that passes the contents of the
- entry widget the Tcl_Eval:
-
-
- # mxDoCmd --
- # Execute the commands issued to the command entry
- # This is ordinarily bound to hitting <Return> in the command entry
-
- proc mxDoCmd { } {
- # focus is a flag that indicates which other widget should get
- # focus after the command is executed
- global focus
- # command is a frame widget holding a label and an entry
- global command
-
- set cmd [$command.entry get]
- if {[llength $cmd] != 0} {
- case [lindex $cmd 0] in {
- {echo feedback mxFeedback} {
- # Echo inputs
- mxFeedback "$cmd"
- } help {
- # Display help information
- mxopen [info library]/mxedit.tutorial
- } default {
- # Pass on the command to Tcl
- if [catch {uplevel #0 $cmd} msg] {
- mxFeedback "Cmd failed: $msg"
- } else {
- # This displays the result in another entry widget
- if {[string compare "$msg" ""] != 0} {
- mxFeedback $msg
- } else {
- mxFeedback "ok"
- }
- }
- }
- }
- }
- # Let a command do its own focus if it wants,
- # otherwise return the focus to the editting window
- if {[string compare $focus "default"] == 0} {
- mxeditFocus
- }
- set focus default
- }
-
-
- --
-
- Brent Welch
-