home *** CD-ROM | disk | FTP | other *** search
-
- # The menu.
- menu -n $tclMenu -p tclMenuProc {
- "/Z<O<UtraceTclProc╔"
- "/D<O<UdumpTraces"
- "(-"
- "rebuildTclIndices"
- "(-"
- "<U/PprocDefinition"
- "getVarValue╔"
- }
- proc tclMenu {} {}
-
- newModeVar Tcl prefixString {# } 0
- newModeVar Tcl wordWrap {0} 1
- newModeVar Tcl funcExpr {^proc *([+-a-zA-Z0-9]+)} 0
- newModeVar Tcl wordBreak {(\$)?[a-zA-Z0-9_]+} 0
- newModeVar Tcl wordBreakPreface {([^a-zA-Z0-9_\$]|.\$)} 0
- newModeVar Tcl elecLBrace 1 1
- newModeVar Tcl elecRBrace 1 1
- newModeVar Tcl elecReturn 1 1
- newModeVar Tcl autoMark 0 1
- newModeVar Tcl electricTab 1 1
-
- set tclKeyWords {
- then append array break case catch cd close concat continue elseif else eof
- error eval exec exit expr file flush foreach format for gets global glob
- history if incr info join lappend library lindex linsert list llength
- lrange lreplace lsearch lsort open pid proc puts pwd read regexp regsub
- rename return scancontext scan seek set source split string switch tell
- time trace unknown unset uplevel upvar while
-
- menu
- }
- if {[info exists Tclwords]} {set tclKeyWords [concat $tclKeyWords $Tclwords]}
- regModeKeywords -e {#} -c red -k blue Tcl $tclKeyWords
- unset tclKeyWords
-
- #================================================================================
-
- proc electricTclLeft {} {
- global TclmodeVars
-
- if {[getPos] != [selEnd]} {
- set beg [getPos]
- set end [selEnd]
- select $end $end
- deleteText $beg $end
- }
- if {!$TclmodeVars(elecLBrace) || (([lookAt [getPos]] != "\r") && ([getPos] != [maxPos])) || [catch {search -s -f 0 -r 1 "\}" [getPos]} res] ||
- ![regexp {\}[ \t\r]*(else(if)?)[ \t\r]*} [getText [lindex $res 0] [getPos]] dum word]} {
- insertText "\{"
- return
- }
- replaceText [lindex $res 0] [getPos] "\} $word \{\r"
- indentLine
- if {$word == "elseif"} {
- previousLine
- endOfLine
- }
- }
- bind '\{' <s> electricTclLeft Tcl
-
-
- proc electricTclRight {} {
- global TclmodeVars {}
-
- if {!$TclmodeVars(elecRBrace) || [regexp {[^ \t]} [getText [lineStart [getPos]] [getPos]]]} {
- insertText "\}"
- blink [matchIt "\}" [expr [getPos] - 2]]
- return
- }
- set start [lineStart [getPos]]
- insertText "\}"
- backwardChar
- indentLine
- endOfLine
- tclCarriageReturn
- blink [matchIt "\}" $start]
- }
- bind '\}' <s> electricTclRight Tcl
-
-
- proc tclCarriageReturn {} {
- global TclmodeVars
-
- insertText "\r"
- if {$TclmodeVars(elecReturn)} {
- indentLine
- }
- }
- bind '\r' tclCarriageReturn Tcl
-
-
-
- proc rebuildTclIndices {} {
- set dir [pwd]
- cd
- message "Building SystemCode index╔"
- auto_mkindex :Tcl:SystemCode *.tcl
- message "Building UserCode index╔"
- auto_mkindex :Tcl:UserCode *.tcl
- message ""
- cd $dir
- }
-
-
- proc tclMenuProc {menu item} {
- global tclColoring
-
- eval $item
- }
-
-
- #===========================================================================
- # Debug a Tcl procedure.
- #===========================================================================
-
- # Alpha TCL programming mode
-
- proc traceTclProc {} {
- global tclMenu
- if {[llength [traceFunc status]]>2} {
- markMenuItem $tclMenu {traceTclProc╔} off
- enableMenuItem $tclMenu dumpTraces off
- if {[string length [set data [traceDump]]]} {
- if {[askyesno "Dump traces?"] == "yes"} {
- dumpTraces [string trimright [lindex [traceFunc status] 3] {,}] $data
- setWinInfo dirty 0
- }
- }
- traceFunc off
- message "Tracing off."
- return
- }
- if {[llength [winNames]] && [string length [set sel [getSelect]]]} {
- set func [listpick -L $sel -p {Func Name:} [lsort -ignore [info procs]]]
- } else {
- set func [listpick -p {Func Name:} [lsort -ignore [info procs]]]
- }
- if {![string length $func]} return
- traceFunc on $func ""
- catch {markMenuItem $tclMenu {traceTclProc╔} on}
- enableMenuItem $tclMenu dumpTraces on
- message "Tracing '$func'╔"
- }
-
-
- proc dumpTraces {{name ""} {data ""}} {
- if {![string length $name]} {
- set name [string trimright [lindex [traceFunc status] 3] {,}]
- }
- if {![string length $data]} {
- set data [traceDump]
- }
-
- if {![string length $data]} {
- message "Trace buffer empty"
- } else {
- new -n "* Trace '$name' *"
- insertText $data
- setWinInfo dirty 0
- goto 0
- }
- }
-
- proc setTclMode {} {
- changeMode "Tcl"
- }
-
- #================================================================================
- proc TclMarkFile {} {
- set end [maxPos]
- set pos 0
- set l {}
- while {![catch {search -s -f 1 -r 1 -m 0 -i 0 {^proc} $pos} res]} {
- set start [lindex $res 0]
- set end [nextLineStart $start]
- set text [lindex [getText $start $end] 1]
- set pos $end
- set inds($text) [lineStart [expr $start - 1]]
- }
-
- if {[info exists inds]} {
- foreach f [lsort -ignore [array names inds]] {
- set next [nextLineStart $inds($f)]
- setNamedMark $f $inds($f) $next $next
- }
- }
- }
-
- proc dummyTcl {} {}
-
- #===============================================================================
- proc TclDblClick {from to} {
- global HOME auto_index
-
- select $from $to
- set text [getSelect]
-
- # Is it a loaded proc?
- if {[info exists "auto_index($text)"]} {
- editMark "$auto_index($text)" $text
- return
- }
- # Is it a built-in Alpha command?
- set lines [grep "^Ñ $text " "$HOME:Help:Alpha Commands"]
- if {[string length $lines]} {
- editMark "$HOME:Help:Alpha Commands" $text
- setWinInfo read-only 1
- return
- }
- # Is it a core Tcl command?
- set lines [grep "^ $text -" "$HOME:Help:Tcl Commands"]
- if {[string length $lines]} {
- editMark "$HOME:Help:Tcl Commands" $text
- setWinInfo read-only 1
- return
- }
- # Is it a global variable?
- if {[llength [info globals [string trimleft $text {$}]]]==1} {
- showVarValue [string trimleft $text {$}]
- return
- }
- message "No docs"
- }
-
- proc procDefinition {} {
- global auto_index auto_help
-
- if {[llength [winNames]] && [string length [set sel [getSelect]]]} {
- set func [listpick -L $sel -p {Proc?} [lsort -ignore [array names auto_index]]]
- } else {
- set func [listpick -p {Proc?} [lsort -ignore [array names auto_index]]]
- }
-
- editMark "$auto_index($func)" $func
- }
-
- #===============================================================================
-