Index: library/lib/nx-shell.tcl =================================================================== diff -u -rf69105999ff5876732032cd779f3f7521ab010e5 -r0fd6850413df596f7355ed788d09ad733b35a8ef --- library/lib/nx-shell.tcl (.../nx-shell.tcl) (revision f69105999ff5876732032cd779f3f7521ab010e5) +++ library/lib/nx-shell.tcl (.../nx-shell.tcl) (revision 0fd6850413df596f7355ed788d09ad733b35a8ef) @@ -1,8 +1,48 @@ +# -*- Tcl -*- +############################################################ +# nx-shell.tcl -- +# +# Scripted shell (REPL) infrastructure for NX and XOTcl2. +# +# Copyright (C) 2010-2012 Gustaf Neumann +# Copyright (C) 2016 Stefan Sobernig +# +# Vienna University of Economics and Business +# Institute of Information Systems and New Media +# A-1020, Welthandelsplatz 1 +# Vienna, Austria +# +# This work is licensed under the MIT License http://www.opensource.org/licenses/MIT +# +# Copyright: +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + + package require nx package provide nx::shell 1.1 -nx::Object create ::nx::shell2 { +nx::Object create ::nx::shell { :public object method onRead {{chan stdin}} { append :line [read $chan] @@ -179,49 +219,13 @@ interp expose {} try; } } - } - -} - -nx::Object create ::nx::shell { - :public object method run {argc argv} { - if {$argc == 0} { - set prefix "" - set line "" - while {1} { - update - if {$line eq ""} { - puts -nonewline "% " - flush stdout - } - append line [gets stdin] - if {[info complete $line]} { - set script [list catch $line [current]::result [current]::opts] - set r [uplevel #0 $script] - if {$r} { - puts [dict get ${:opts} -errorinfo] - unset :opts; - } else { - puts ${:result} - unset :result - } - set line "" - continue - } - append line \n - } - } else { - set ::argv [lassign $argv argv0] - incr ::argc -1 - uplevel #0 [list source $argv0] - } } } package provide nx::shell 1.1 # Local variables: -# mode: tcl +# mode: Tcl # tcl-indent-level: 2 # indent-tabs-mode: nil # End: