home *** CD-ROM | disk | FTP | other *** search
- #================================================================================
- #
- # CodeWarrior Interaction
- #
- # Metrowerks currently has an incomplete appleevent interface.
- # Apple events can be used to direct CodeWarrior to compile
- # or add individual files, make the project, etc. However,
- # there is currently no provision to report specific errors
- # back to the controller.
- #
- #================================================================================
-
- proc cwarriorMenu {} {}
-
-
- menu -n "$cwarriorMenu" -p codeWarriorProc {
- "help"
- "/-<UswitchTo"
- {menu -n werksFlags -p werksProc {
- "debugger"
- "switchWhenCompiling"
- }}
- "createFileset"
- "(-"
- "addFile"
- "/K<Ucompile"
- "compileFiles"
- "checkSyntax"
- "precompile╔"
- "(-"
- "/U<Uupdate"
- "/M<Umake"
- "(-"
- "/D<UgotoDebugger"
- "/B<UsetBreakpoint"
- "clearBreakpoint"
- "/J<UshowSource"
- "(-"
- "/N<UnextError"
- "/R<Urun"
- }
-
- if {![info exists cwdebugger]} {set cwdebugger 0}
- if {![info exists cwswitchWhenCompiling]} {set cwswitchWhenCompiling 1}
- markMenuItem werksFlags cwdebugger $cwdebugger
- markMenuItem werksFlags cwswitchWhenCompiling $cwswitchWhenCompiling
-
- proc cwhelp {} {
- global HOME
- edit -r "$HOME:Help:CodeWarrior"
- }
-
- proc werksProc {menu item} {
- global cw$item modifiedVars
-
- set cw$item [expr -1 * ([set cw$item] - 1)]
- markMenuItem werksFlags $item [set cw$item]
- lappend modifiedVars cw$item
- }
-
-
-
- set CWCLASS MMPR
- set CDCLASS MWDB
-
-
- proc cwnextError {} {
- nextMatch "*Compiler Errors*"
- }
-
- proc dispErr {{win "* Compiler Errors *"}} {
- if {[string length $win]} {
- set text [getText -w $win [getPos -w $win] [selEnd -w $win]]
- if {[regexp {(Line.*)░} $text dummy sub]} {
- message "$sub"
- }
- }
- }
-
-
- proc codeWarriorProc {menu item} {
- cw$item
- }
-
- proc cwswitchTo {} {
- global CODEWarrior
- checkCw
- switchTo $CODEWarrior
- }
-
- proc cwmake {} {cwDo Make}
- proc cwupdate {} {cwDo UpdP}
-
- proc cwDo {param} {
- global CODEWarrior CWCLASS ALPHA
- checkCw
- switchTo $CODEWarrior
- if {[string length [set res [AEBuild -r -t 500000 $CODEWarrior $CWCLASS $param "Errs" "bool(╟01╚)"]]]} {
- warriorErrors $res
- }
- }
-
- proc cwrun {} {
- global CODEWarrior CWCLASS ALPHA cwdebugger
- checkCw
- set bug $cwdebugger
- switchTo $CODEWarrior
- if {[string length [set res [AEBuild -r -t 500000 $CODEWarrior $CWCLASS RunP "Errs" "bool(╟01╚)" DeBg $bug]]]} {
- warriorErrors $res
- }
- }
-
-
- proc cwprecompile {} {
- global CODEWarrior CWCLASS res
- checkCw
- set fname [lindex [winNames -f] 0]
- set targ [putfile "Precompile target:"]
- switchTo $CODEWarrior
- if {[string length [set res [AEBuild $CODEWarrior $CWCLASS PreC "----" [makeAlis $fname] "Errs" "bool(╟01╚)" Targ [makeAlis $targ]]]] > 40} {
- warriorErrors $res
- } else {
- if {[regexp {errn:([-0-9]+)} $res dummy errno]} {
- message "Error number: $errno"
- }
- }
- }
-
-
- proc cwaddFile {} {
- global CODEWarrior CWCLASS
- checkCw
- switchTo $CODEWarrior
- set fname [lindex [winNames -f] 0]
- set res [AEBuild -t 500000 -q $CODEWarrior $CWCLASS AddF "----" [makeAlis $fname]]
- }
-
- proc cwcheckSyntax {} {
- global CODEWarrior CWCLASS res
- checkCw
- # switchTo $CODEWarrior
- set fname [lindex [winNames -f] 0]
- if {[string length [set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS Chek "----" [concat {[alis(╟} [coerce TEXT $fname -x alis] {╚)]}] "Errs" "bool(╟01╚)"]]] > 40} {
- warriorErrors $res
- }
- }
-
- proc cwcompile {} {
- global CODEWarrior CWCLASS res ALPHA cwswitchWhenCompiling
- save
- checkCw
- set fname [lindex [winNames -f] 0]
- if {$cwswitchWhenCompiling} {
- switchTo $CODEWarrior
- }
- if {[string length [set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS Comp "----" [makeAlis $fname] "Errs" "bool(╟01╚)"]]] > 40} {
- warriorErrors $res
- } else {
- set wins [winNames]
- if {[set res [lsearch $wins "*Compiler Errors*"]] >= 0} {
- set name [lindex $wins $res]
- bringToFront $name
- killWindow
- }
- }
- switchTo $ALPHA
- }
-
-
- proc cwcompileFiles {} {
- global CODEWarrior CWCLASS res ALPHA winModes
- saveAll
- checkCw
- set files {}
- set wins [winNames -f]
- set md $winModes([lindex $wins 0])
- foreach w $wins {
- if {$md == $winModes($w)} {
- lappend files $w
- }
- }
- switchTo $CODEWarrior
- if {[string length [set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS Comp "----" [eval makeAlises $files] "Errs" "bool(╟01╚)"]]] > 40} {
- warriorErrors $res
- } else {
- set wins [winNames]
- if {[set res [lsearch $wins "*Compiler Errors*"]] >= 0} {
- set name [lindex $wins $res]
- bringToFront $name
- killWindow
- }
- }
- switchTo $ALPHA
- }
-
-
- proc cwGetFiles {} {
- global CODEWarrior CWCLASS
- checkCw
- set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS GSeg]
- regexp {\[(.*)\]} $res dummy segs
- regsub -all {, Seg} $segs {Ñ} segs
- set ind 1
- foreach seg [split $segs {Ñ}] {
- regexp {NumF:([0-9]+)} $seg dummy num
-
- while {$num > 0} {
- set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS GFil "----" "long($num)" Segm "long($ind)"]
- if {[regexp {FTxt} $res]} {
- regexp {╟(.*)╚} $res dummy spec
- set f [specToPathName $spec]
- message $f
- lappend files $f
- }
- incr num -1
- }
- incr ind
- }
- return $files
- }
-
- proc createWarriorFileset {} {
- cwcreateFileset
- }
-
-
- proc cwcreateFileset {} {
- global fileSets
- global currFileSet
-
- set name [prompt "Fileset name? " "CodeWarrior"]
- set fileSets($name) [lsort -command sortByTail [cwGetFiles]]
- addMenuItem -m choose $name
- set currFileSet $name
-
- if {[askyesno "Save project fileset?"] == "yes"} {
- addArrDef fileSets $name $fileSets($name)
- }
- rebuildFilesetMenu
- }
-
-
- proc warriorErrors {res} {
- global winModes tileLeft tileTop tileWidth errorHeight
- if {[regexp {\[.*\]} $res res]} {
- set res [string trim $res {[]}]
- regsub {ErrM} $res "" res
- regsub -all {, ErrM} $res "\r" res
- set text ""
- set errs 0
- set link 0
- foreach err [lrange [split $res "\r"] 0 100] {
- if {[regexp {╥(.*)╙.*╟(.*)╚.*ErrL:([0-9]+)} $err dummy msg spec line]} {
- set f [specToPathName $spec]
- append text "\r\"[file tail $f]\"\t; Line $line: $msg\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t░$f"
- } elseif {[regexp {╥([^:]*): (.*)╙} $err dummy file msg]} {
- set link 1
- append text "\r\"$file\" ; $msg"
- }
- incr errs
- }
-
- set wins [winNames]
- if {!$errs} {
- global killCompilerErrors
- set killCompilerErrors 1
- return
- }
-
- if {[set res [lsearch $wins "*Compiler Errors*"]] >= 0} {
- set name [lindex $wins $res]
- bringToFront $name
- setWinInfo read-only 0
- deleteText 0 [maxPos]
- } else {
- new -n {* Compiler Errors *} -g $tileLeft $tileTop $tileWidth $errorHeight
- changeMode [set winModes([lindex [winNames] 0]) Brws]
- }
- if {$link} {
- insertText "($errs Link errors)\r-----$text\r"
- } else {
- insertText "($errs errs: <cr> to go to match)\r-----$text\r"
- }
-
- display 0
- goto 0
- downBrowse
- setWinInfo dirty 0
- setWinInfo read-only 1
- }
- }
-
-
- proc cwTouch {} {
- global CODEWarrior CWCLASS
- checkCw
- switchTo $CODEWarrior
- set fname [lindex [winNames -f] 0]
- set res [AEBuild -t 500000 -q $CODEWarrior $CWCLASS "Toch" "----" [makeAlis $fname]]
- }
-
- proc checkCw {} {
- global CODEWarrior modifiedVars cwSig cwPath
- set CODEWarrior [checkRunning "MW C/C++" $cwSig cwPath]
- set sig [getFileSig $cwPath]
- if {$sig != $cwSig} {
- lappend modifiedVars cwSig
- set cwSig $sig
- }
- }
-
-
-
- proc checkCwDebug {} {
- global CODEDEBUGGER cwdSig cdPath modifiedVars
- set CODEDEBUGGER [checkRunning "MW Debugger" $cwdSig cdPath]
- set sig [getFileSig $cdPath]
- if {$sig != $cwdSig} {
- lappend modifiedVars cwdSig
- set cwdSig $sig
- }
- }
-
-
- proc cwgotoDebugger {} {
- global CODEDEBUGGER
- checkCwDebug
- switchTo $CODEDEBUGGER
- }
-
- proc cwsetBreakpoint {} {
- global CODEDEBUGGER CDCLASS res
- checkCwDebug
- switchTo $CODEDEBUGGER
- set fname [lindex [winNames -f] 0]
- set ln [lindex [posToRowCol [getPos]] 0]
- set res [AEBuild -t 500000 -r $CODEDEBUGGER $CDCLASS "Sbrk" "----" [makeAlis $fname] "Line" "long($ln)"]
- }
-
- proc cwclearBreakpoint {} {
- global CODEDEBUGGER CDCLASS res
- checkCwDebug
- switchTo $CODEDEBUGGER
- set fname [lindex [winNames -f] 0]
- set ln [lindex [posToRowCol [getPos]] 0]
- set res [AEBuild -t 500000 -r $CODEDEBUGGER $CDCLASS "Cbrk" "----" [makeAlis $fname] "Line" "long($ln)"]
- }
-
-
- proc cwshowSource {} {
- global CODEDEBUGGER CDCLASS res
- checkCwDebug
- switchTo $CODEDEBUGGER
- set fname [lindex [winNames -f] 0]
- set ln [lindex [posToRowCol [getPos]] 0]
- set res [AEBuild -t 500000 -r $CODEDEBUGGER $CDCLASS "Show" "----" [makeAlis $fname] "Line" "long($ln)"]
- }
- # "Soff" "long([getPos]" "Eoff" "long([selEnd])"