* docs/tkcon.html: improved docs for tkcon *get* methods.
* tkcon.tcl: reinstituted override of gets by default to use the
tkcon console based gets.
2001-05-28 Jeff Hobbs <jeffh@ActiveState.com>
+ * docs/start.html: added note about ::tkcon::OPT(gets) var.
+ * docs/tkcon.html: improved docs for tkcon *get* methods.
+ * tkcon.tcl: reinstituted override of gets by default to use the
+ tkcon console based gets.
+
* tkcon.tcl (dump): corrected outputting local vars with dump.
Added RCS info to PRIV array and About box.
(tkcon congets) corrected congets to set the limit and insert
<DD> Font to use for tkcon text widgets (also specified with -font).
Defaults to the system default, or a fixed width equivalent.
+<DT> <CODE>::tkcon::OPT(gets)</CODE>
+<DD> Controls whether tkcon will overload the gets command to work with
+tkcon. The valid values are: <code>congets</code> (the default), which
+will redirect <code>stdin</code> requests to the tkcon window;
+<code>gets</code>, which will pop up a dialog to get input; and {} (empty
+string) which tells tkcon not to overload gets. This value must be set at
+startup to alter tkcon's behavior.
+
<DT> <CODE>::tkcon::OPT(history)</CODE>
<DD> The size of the history list to keep. Defaults to 48.
<DL>
<DT> <CODE>tkcon <b>attach</b></CODE> <I>interpreter</I>
-<DD> Attaches TkCon to the named interpreter. The name must be that
+<DD> Attaches tkcon to the named interpreter. The name must be that
returned by <CODE>[tk appname]</CODE> or a valid path to a slave
interpreter. It's best to use this via the <CODE>Console->Attach
Console</CODE> menu.
has been exceeded (read: this is the scroll buffer size).
<DT> <CODE>tkcon <b>bgerror</b></CODE> ?<I>msg errorInfo</I>?
-<DD> Does bgerror stuff in the TkCon master interpreter.
+<DD> Does bgerror stuff in the tkcon master interpreter.
<DT> <CODE>tkcon <b>close</b></CODE> or <CODE>tkcon <b>destroy</b></CODE>
-<DD> Destroys this TkCon widget.
+<DD> Destroys this tkcon widget.
+
+<DT> <CODE>tkcon <b>congets</b></CODE>
+<DD> Behaves like the traditional Tcl <code>gets</code>, but instead of
+using <code>stdin</code>, it uses the tkcon console window. By default,
+tkcon replaces the standard gets with this command. This behavior can be
+controlled by altering the <code>::tkcon::OPT(gets)</code> parameter at
+startup. This should not be called directly - instead rely on the
+overloaded <code>gets</code>, which has support for the optional varName
+parameter.
<DT> <CODE>tkcon <b>console</b></CODE> <I>args</I>
-<DD> Passes the args to the TkCon text widget (the console).
+<DD> Passes the args to the tkcon text widget (the console).
<DT> <CODE>tkcon <b>error</b></CODE>
<DD> Pops up a dialog that gives the user a full trace of the last error
-received in the TkCon console.
+received in the tkcon console.
<DT> <CODE>tkcon <b>find</b></CODE> <I>string ?-case TCL_BOOLEAN
-regexp TCL_BOOLEAN?</I>
<DT> <CODE>tkcon <b>font</b></CODE> ?<I>fontname</I>?
<DD> Sets or returns the font used by tkcon text widgets.
-<DT> <CODE>tkcon <b>gets</b></CODE> ?<I>varname</I>?
-<DD> Behaves like the traditional Tcl <code>gets</code>, but uses the
-TkCon console instead of <code>stdin</code>.
+<DT> <CODE>tkcon <b>gets</b></CODE>
+<DD> Behaves like the traditional Tcl <code>gets</code>, but instead of
+needing <code>stdin</code>, it pops a dialog box up for the user. The
+overloaded <code>gets</code> has support for the optional varName parameter.
+
+<DT> <CODE>tkcon <b>getcommand</b></CODE>
+<DD> A variation of the <CODE><b>congets</b></CODE> method that requires a
+full command to be input before returning.
<DT> <CODE>tkcon <b>hide</b></CODE>
-<DD> Withdraw the TkCon display from the screen (make sure you have
+<DD> Withdraw the tkcon display from the screen (make sure you have
a way to get it back).
<DT> <CODE>tkcon <b>history</b></CODE> ?<i>-newline</i>?
-<DD> Displays the TkCon history in sourceable form. If <i>-newline</i> is
+<DD> Displays the tkcon history in sourceable form. If <i>-newline</i> is
specified, it separates each command by an extra newline.
<DT> <CODE>tkcon <b>iconify</b></CODE>
-<DD> Iconifies the TkCon display.
+<DD> Iconifies the tkcon display.
<DT> <CODE>tkcon <b>load</b></CODE> <I>filename</I>
<DD> Sources named file into the slave interpreter. If no filename is
file select box.
<DT> <CODE>tkcon <b>main</b></CODE> ?<I>arg arg ...</I>?
-<DD> Passes the args to the main TkCon interpreter to be evaluated and
+<DD> Passes the args to the main tkcon interpreter to be evaluated and
returns the result.
<DT> <CODE>tkcon <b>master</b></CODE> <I>args</I>
returns the result.
<DT> <CODE>tkcon <b>new</b></CODE>
-<DD> Creates a new TkCon widget.
+<DD> Creates a new tkcon widget.
<DT> <CODE>tkcon <b>save</b></CODE> ?<I>filename</I> ?<I>type</I>??
<DD> Saves the console buffer to the given filename. If no filename is
<DD> Like set, but uses <CODE>lappend</CODE> on the variable.
<DT> <CODE>tkcon <b>show</b></CODE> or <CODE>tkcon deiconify</CODE>
-<DD> Redisplays TkCon on the screen.
+<DD> Redisplays tkcon on the screen.
<DT> <CODE>tkcon <b>slave</b></CODE> ?<I>slavename ?arg arg ...?</I>?
-<DD> If called with no args, it returns the name of all the TkCon
+<DD> If called with no args, it returns the name of all the tkcon
interpreters. Otherwise given an interp name it passes the args
to the named interpreter to be evaluated and returns the result.
If no args are passed, then it returns the <CODE>[tk appname]</CODE>
of that interpreter.
<DT> <CODE>tkcon <b>title</b></CODE> ?<I>title</I>?
-<DD> Sets or returns the title for TkCon.
+<DD> Sets or returns the title for tkcon.
<DT> <CODE>tkcon <b>version</b></CODE>
-<DD> Returns of version of TkCon.
+<DD> Returns of version of tkcon.
</DL>
</DIV>
slaveexit close
subhistory 1
gc-delay 60000
+ gets {congets}
exec slave
}
slavealias { edit more less tkcon }
slaveprocs {
alias clear dir dump echo idebug lremove
- tkcon_puts observe observe_var unalias which what
+ tkcon_puts tkcon_gets observe observe_var unalias which what
}
version 2.1+
RCS {RCS: @(#) $Id$}
if {![catch {rename ::puts ::tkcon_tcl_puts}]} {
interp alias {} ::puts {} ::tkcon_puts
}
- #if {![catch {rename ::gets ::tkcon_tcl_gets}]} {
- #interp alias {} ::gets {} ::tkcon_gets
- #}
+ if {($OPT(gets) != "") && ![catch {rename ::gets ::tkcon_tcl_gets}]} {
+ interp alias {} ::gets {} ::tkcon_gets
+ }
EvalSlave history keep $OPT(history)
if {[info exists MainInit]} {
}
$slave alias exit exit
interp eval $slave {
- catch {rename ::puts ::tkcon_tcl_puts}
- #catch {rename ::gets ::tkcon_tcl_gets}
+ # Do package require before changing around puts/gets
catch {package require bogus-package-name}
+ catch {rename ::puts ::tkcon_tcl_puts}
}
foreach cmd $PRIV(slaveprocs) { $slave eval [dump proc $cmd] }
foreach cmd $PRIV(slavealias) { $slave alias $cmd $cmd }
interp alias $slave ::ls $slave ::dir -full
interp alias $slave ::puts $slave ::tkcon_puts
- #interp alias $slave ::gets $slave ::tkcon_gets
+ if {$OPT(gets) != ""} {
+ interp eval $slave { catch {rename ::gets ::tkcon_tcl_gets} }
+ interp alias $slave ::gets $slave ::tkcon_gets
+ }
if {[info exists argv0]} {interp eval $slave [list set argv0 $argv0]}
interp eval $slave set tcl_interactive $tcl_interactive \; \
set argc [llength $args] \; \
set oldname $PRIV(namesp)
catch {
Attach $name $type
- EvalAttached {
- catch {rename ::puts ::tkcon_tcl_puts}
- #catch {rename ::gets ::tkcon_tcl_gets}
- }
+ EvalAttached { catch {rename ::puts ::tkcon_tcl_puts} }
foreach cmd $PRIV(slaveprocs) { EvalAttached [dump proc $cmd] }
switch -exact $type {
slave {
if {[catch {interp alias {} ::puts {} ::tkcon_puts}]} {
catch {rename ::tkcon_puts ::puts}
}
- #if {[catch {interp alias {} ::gets {} ::tkcon_gets}]} {
- #catch {rename ::tkcon_gets ::gets}
- #}
+ }
+ if {$OPT(gets) != ""} {
+ EvalAttached {
+ catch {rename ::gets ::tkcon_tcl_gets}
+ if {[catch {interp alias {} ::gets {} ::tkcon_gets}]} {
+ catch {rename ::tkcon_gets ::gets}
+ }
+ }
}
return
} {err}
$::tkcon::OPT(buffer)
}
congets {
- ## 'congets' a replacement for [gets stdin varname]
+ ## 'congets' a replacement for [gets stdin]
+ # Use the 'gets' alias of 'tkcon_gets' command instead of
+ # calling the *get* methods directly for best compatability
+ if {[llength $args]} {
+ return -code error "wrong # args: must be \"tkcon congets\""
+ }
+ set old [bind TkConsole <<TkCon_Eval>>]
+ bind TkConsole <<TkCon_Eval>> { set ::tkcon::PRIV(wait) 0 }
+ set w $::tkcon::PRIV(console)
+ # Make sure to move the limit to get the right data
+ $w mark set insert end
+ $w mark set limit insert
+ $w see end
+ vwait ::tkcon::PRIV(wait)
+ set line [::tkcon::CmdGet $w]
+ $w insert end \n
+ bind TkConsole <<TkCon_Eval>> $old
+ return $line
+ }
+ getc* {
+ ## 'getcommand' a replacement for [gets stdin]
## This forces a complete command to be input though
+ if {[llength $args]} {
+ return -code error "wrong # args: must be \"tkcon getcommand\""
+ }
set old [bind TkConsole <<TkCon_Eval>>]
bind TkConsole <<TkCon_Eval>> { set ::tkcon::PRIV(wait) 0 }
set w $::tkcon::PRIV(console)
$w see end
}
bind TkConsole <<TkCon_Eval>> $old
- if {![llength $args]} {
- return $line
- } else {
- upvar 1 [lindex $args 0] data
- set data $line
- return [string length $line]
- }
+ return $line
}
- get* {
+ get - gets {
## 'gets' - a replacement for [gets stdin]
## This pops up a text widget to be used for stdin (local grabbed)
if {[llength $args]} {
if {[string compare stdin [lindex $args 0]]} {
return [uplevel 1 tkcon_tcl_gets $args]
}
- set data [tkcon gets]
+ set gtype [tkcon set ::tkcon::OPT(gets)]
+ if {$gtype == ""} { set gtype congets }
+ set data [tkcon $gtype]
if {$len == 2} {
upvar 1 [lindex $args 1] var
set var $data
while 1 {
set err {}
if {$tkcon} {
+ # tkcon's overload of gets is advanced enough to not need
+ # this, but we get a little better control this way.
tkcon evalSlave set level $level
tkcon prompt
- set line [tkcon congets]
+ set line [tkcon getcommand]
tkcon console mark set output end
} else {
puts -nonewline stderr "(level \#$level) debug > "