+2005-07-14 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * tkcon.tcl: add ::tkcon::OPT(maxlinelen) (default 0 == unlimited)
+ and 'tkcon linelength ?value?' to optionally limit long result
+ lines. True result is still captured in $_ (and 'puts $_' works).
+
2005-05-25 Jeff Hobbs <jeffh@ActiveState.com>
* tkcon.tcl (InitMenus): add ActiveTcl Help menu item, if AT Help
blinktime 500
blinkrange 1
buffer 512
+ maxlinelen 0
calcmode 0
cols 80
debugPrompt {(level \#$level) debug [history nextid] > }
}
StateCheckpoint $PRIV(name) slave
+ puts "buffer line limit:\
+ [expr {$OPT(buffer)?$OPT(buffer):{unlimited}}] \
+ max line length:\
+ [expr {$OPT(maxlinelen)?$OPT(maxlinelen):{unlimited}}]"
+
Prompt "$title console display active (Tcl$::tcl_patchLevel / Tk$::tk_patchLevel)\n"
}
}
AddSlaveHistory $cmd
catch {EvalAttached [list set _ $res]}
+ set maxlen $OPT(maxlinelen)
+ set trailer ""
+ if {($maxlen > 0) && ([string length $res] > $maxlen)} {
+ # If we exceed maximum desired output line length, truncate
+ # the result and add "...+${num}b" in error coloring
+ set trailer ...+[expr {[string length $res]-$maxlen}]b
+ set res [string range $res 0 $maxlen]
+ }
if {$code} {
if {$OPT(hoterrors)} {
set tag [UniqueTag $w]
- $w insert output $res [list stderr $tag] \n stderr
+ $w insert output $res [list stderr $tag] \n$trailer stderr
$w tag bind $tag <Enter> \
[list $w tag configure $tag -under 1]
$w tag bind $tag <Leave> \
"if {!\[info exists tkPriv(mouseMoved)\] || !\$tkPriv(mouseMoved)} \
{[list $OPT(edit) -attach [Attach] -type error -- $PRIV(errorInfo)]}"
} else {
- $w insert output $res\n stderr
+ $w insert output $res\n$trailer stderr
}
} elseif {[string compare {} $res]} {
- $w insert output $res\n stdout
+ $w insert output $res stdout $trailer stderr \n stdout
}
}
}
# Outputs: may delete data in console widget
##
proc ::tkcon::ConstrainBuffer {w size} {
- if {[$w index end] > $size} {
+ if {$size && ([$w index end] > $size)} {
$w delete 1.0 [expr {int([$w index end])-$size}].0
}
}
}
return $OPT(buffer)
}
+ linelen* {
+ ## 'linelength' Sets/Query the maximum line length
+ if {[llength $args]} {
+ if {[regexp {^-?[0-9]+$} $args]} {
+ set OPT(maxlinelen) $args
+ } else {
+ return -code error "buffer must be a valid integer"
+ }
+ }
+ return $OPT(maxlinelen)
+ }
bg* {
## 'bgerror' Brings up an error dialog
set errorInfo [lindex $args 1]