From 69ab72ed08506ad33b3157ac8f51645653cceeb0 Mon Sep 17 00:00:00 2001 From: cascade Date: Fri, 17 Oct 2003 22:22:22 +0000 Subject: [PATCH] Initial revision --- src/WOKsite/cmd-input.tcl | 58 +++++++++++++++++++++++++++++++++++++++ src/WOKsite/wokinit.bat | 9 ++++++ 2 files changed, 67 insertions(+) create mode 100755 src/WOKsite/cmd-input.tcl create mode 100755 src/WOKsite/wokinit.bat diff --git a/src/WOKsite/cmd-input.tcl b/src/WOKsite/cmd-input.tcl new file mode 100755 index 0000000..7702f67 --- /dev/null +++ b/src/WOKsite/cmd-input.tcl @@ -0,0 +1,58 @@ + namespace eval CmdInput { + + # We want to allow shell commands to execute automatically + # as in normal interactive use. The "unknown" proc checks + # that "info script" returns "", before it enables that + # behaviour, so we subclass "info". In Tcl 8.4 we could simply + # call 'info script ""' I believe, but 8.3 and earlier don't do + # that. + variable this_script [info script] + proc info {args} { + set result [uplevel [concat __org_info $args]] + set cmd [lindex $args 0] + + variable this_script + if {"script" == $cmd && "$result" == $this_script} { + return "" + } else { + return $result + } + } + rename ::info ::__org_info ;# using a namespace proc here cores + proc ::info {args} "uplevel \[concat [namespace which info] \$args\]" + + proc loop {} { + # preparations + fconfigure stdin -buffering line + fconfigure stdout -buffering line + fconfigure stderr -buffering line + set ::tcl_interactive 1 + + if {[file exists ~/tclshrc_WOK8.0]} { + namespace eval :: {uplevel \#0 source ~/tclshrc_WOK8.3} + } + + # input loop + while {1} { + catch {uplevel \#0 $::tcl_prompt1} + flush stdout + set cmd {} + while {1} { + append cmd [gets stdin] "\n" + if {[info complete $cmd]} { + break + } + catch {uplevel \#0 $::tcl_prompt2} + flush stdout + } + history add $cmd + catch {uplevel \#0 $cmd} result + puts $result + } + return "" + } + } + + catch {CmdInput::loop} result + puts $result + exit 0 diff --git a/src/WOKsite/wokinit.bat b/src/WOKsite/wokinit.bat new file mode 100755 index 0000000..9399b29 --- /dev/null +++ b/src/WOKsite/wokinit.bat @@ -0,0 +1,9 @@ +set TCLHOME=%CASROOT%/../3rdparty/win32/tcltk +set TCLBIN=%TCLHOME%/bin +set WOKHOME=%CASROOT%/../wok +set PATH=%TCLBIN%;%WOKHOME%/lib/wnt;%PATH% +set TCL_RCFILE=%WOKHOME%/site/tclshrc.tcl +set WOK_ROOTADMDIR=%WOKHOME%/wok_entities +set HOME=%WOKHOME%/site +cd %WOK_ROOTADMDIR% +%TCLBIN%/tclsh.exe < %HOME%/CreateFactory.tcl -- 2.39.5