home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
sprint
/
sprinttc.arc
/
TURBOC.SPM
< prev
Wrap
Text File
|
1988-12-17
|
14KB
|
454 lines
; Copyright (c) 1988 Ralf Brown. All Rights Reserved.
; Portions derived from code Copyright 1988 Borland International
;
; May be freely redistributed provided no fee is charged and the above
; copyright notice remains intact.
;---------------------------------------------------------------------
; Turbo C compilation support package
; Created: Nov 12, 1988
; LastEdit: Dec 12, 1988
; Release: v1.0 Dec 17, 1988
;
; New and changed keys:
; Alt-V view file in read-only mode
; Alt-F2 save all files
; Alt-F3 run debugger
; Alt-F4 run program, swapping out Sprint
; Alt-F5 go to first message in error file
; Alt-F6 go to last message in error file
; Alt-F7 find previous error or warning
; Alt-F8 find next error or warning
; Shf-F9 compile file
; Alt-F9 run MAKE
; Alt-F10 remove error list
; ), ], } briefly move cursor to matching opening delimiter
; Shf-Alt-D show declaration corresponding to English description
; Shf-Alt-E explain declaration on the current line, or marked declaration
; Shf-Alt-P add printf() call at cursor position
;---------------------------------------------------------------------
; Q registers used:
; Q1 miscellaneous
; Q7 miscellaneous
; QD original path
; QP path to file(s) being compiled
;---------------------------------------------------------------------
; start with default Borland user interface
#include "sp"
;---------------------------------------------------------------------
SaveUI : $ ovlwrite "turboc.ui" ovlwrite "sp"
;---------------------------------------------------------------------
int MatchChar 0
ShowMatchingChar : ; derived from MATCH.SPM, (c) Copyright Borland International
->int ThisChar
1->int NestingLevel
set themark ; remember where we were
r c ; skip back from the just-inserted delimiter
stopped while (NestingLevel && !(r isend))
{
r c ; keep moving backwards
if (current == ThisChar)
++NestingLevel
if (current == MatchChar)
--NestingLevel
}
if (!(r isend)) ; until found or we run out of file
mark
{
set themark ; highlight the matched character for
1->select ; 1/10 second
c
draw
100 wait
0->select
r c
draw
}
else
{
MatchChar message "no matching '%c'"
}
swap themark
;---------------------------------------------------------------------
ShowErrorMsg :
int WasFound
2 -> statline
set Q1 ""
buffind "MAKE.ERR"
tosol ; back up to start of line
if (current == 'W') ; is it a warning or an error?
set Q7 "W"
else
set Q7 "E"
past istoken ; skip to filename
to istoken
copy to iswhite Q1 ; and get it
to iswhite ; skip to line number
c
copy to (current == ':') QD ; get line number
1 -> append copy to (current == ':') Q7 ; add line to output message
to (current == ':') ; skip to error message
c
1 -> append copy toeol Q7 ; & append it to output message
mode Q7
1 AllCaps ; uppercase filename in Q1
if (!buffind Q1) ; switch to file with error if loaded,
{ ; otherwise find and load the file
set Q7 cd ; store current directory
set cd QP ; switch to dir containing files
open Q1 -> WasFound ; try to open the file
set cd Q7 ; and restore directory
if !WasFound
{
close ; don't want the buffer just created
error "File not found"
}
}
atoi QD -> line ; jump to line with error
draw ; force screen update
;---------------------------------------------------------------------
FirstError :
0 -> int Done
tosol
while (!(0 match "Warning") && !(0 match "Error") && (1->Done) &&
line != ++line)
0 -> Done
if Done
{
1 -> statline
message "\nCompilation successful. Press a key..."
key
message "\n"
}
else
ShowErrorMsg
;---------------------------------------------------------------------
Restart : ; patterned after Borland's Restart
NormalMode
mark
{
if (exist "log.$$$") ; for compatibility with standard UI
{
draw pageread "log.$$$"
fdelete "log.$$$"
}
}
if (exist "MAKE.ERR")
{
open "MAKE.ERR"
fdelete "MAKE.ERR" ; don't need error file anymore
set cd QD ; restore our old directory
FirstError ; and show the first message
}
while keypressed ; get rid of any typeahead
key
;---------------------------------------------------------------------
SaveAllFiles :
mark
{
bufnum -> int old_buf ; remember where we were
do { ; for each buffer: if modified, save
if (modf && !IsUnnamed)
write fname
} while (bufswitch && bufnum != old_buf)
}
message "\nAll files saved"
;---------------------------------------------------------------------
ToPrevError:
0 -> int Done
set QD fname ; remember where we were
if (!buffind "MAKE.ERR") ; switch to buffer containing messages
error "No error file"
--line ; back up a line
while (!(0 match "Warning") && !(0 match "Error") && (1->Done) &&
line != --line)
0 -> Done ; continue backing up until msg found
if Done
{
1 -> statline ; shut off separate message line
message "\nNo prior errors or warnings. Press a key..."
key
message "\n"
buffind QD ; return to original file
}
else
ShowErrorMsg
;---------------------------------------------------------------------
ToNextError :
0 -> int Done
set QD fname ; remember where we were
if (!buffind "MAKE.ERR") ; switch to buffer containing messages
error "No error file"
line++ ; down a line
while (!(0 match "Warning") && !(0 match "Error") && (1->Done) &&
line != ++line)
0 -> Done ; continue down until message found
if Done
{
1 -> statline ; shut off separate line for messages
message "\nNo more errors or warnings. Press a key..."
key
message "\n"
buffind QD ; return to original file
}
else
ShowErrorMsg
;---------------------------------------------------------------------
ToFirstError:
if (!buffind "MAKE.ERR")
error "No error file"
r toend
ToNextError
;---------------------------------------------------------------------
ToLastError:
if (!buffind "MAKE.ERR")
error "No error file"
toend
ToPrevError
;---------------------------------------------------------------------
GetCompileName :
set QD cd ; remember where we were
set QP fname ; get name of file in current buffer
mark
{
to QP toend r c ; strip off last component of name
while (length QP && current != '/' && current != '\\' && current != ':')
{
del
r c
}
if (current == '\\' || current == '/')
del
if (buffind "MAKE.ERR") ; discard any compile messages
close
}
set cd QP ; go to directory containing the file
;---------------------------------------------------------------------
RunDebugger:
if length fname
set Q1 fchange "%.EXE" fname
else
set Q1 ""
message "\nProgram to debug: "
set Q1
24 call "td " Q1 ; load TD, swapping out Sprint
;---------------------------------------------------------------------
RunProgram:
if length fname
set Q1 fchange "%.EXE" fname
else
set Q1 ""
message "\nProgram to run: "
set Q1
25 call Q1 ; run program, swapping out Sprint
;---------------------------------------------------------------------
CompileFile:
if modf
write fname ; make sure file is up-to-date on disk
GetCompileName
status "\nCompiling..." ; clear the status line
56 call "command /c >MAKE.ERR tcc -c -v " fname ; call compiler, swapping out Sprint
;---------------------------------------------------------------------
RunMake:
SaveAllFiles
GetCompileName
status "\nRunning MAKE..."
56 call "command /c >MAKE.ERR make" ; run the make, swapping out Sprint
;---------------------------------------------------------------------
DeleteErrors:
1 -> statline ; shut off mode line for messages
mark
{
if (buffind "MAKE.ERR") ; get rid of buffer for error messages
close
}
if (exist "MAKE.ERR") ; in the unlikely event that the error
fdelete "MAKE.ERR" ; file still exists, delete it
;---------------------------------------------------------------------
CdeclDeclare:
int old_statline
message "\nDeclare: "
set Q1 "" ; no default declaration
set Q1 ; get it from user
;the following section of code is for versions of cdecl which require that all
;commands are given via standard input
; mark
; {
; open "" ; make an unnamed buffer
; "declare " ; insert the CDECL command
; insert Q1 ; and what we want converted
; 13 insert ; terminate line
; 10 insert
; write "CDECL$IN.$$$" ; save to disk
; status "\nWorking...."
; close ; and discard buffer
; 32 call "command /c cdecl <CDECL$IN.$$$ >CDECL.$$$"
; fdelete "CDECL$IN.$$$" ; don't need input file anymore
; }
; since the cdecl I have can take input from the command line, use short version
32 call "command /c >CDECL.$$$ cdecl declare " Q1
mark
{
if (exist "CDECL.$$$") ; did CDECL actually get run?
{
open "CDECL.$$$" ; load declaration into a buffer
fdelete "CDECL.$$$" ; don't need temp file anymore
}
else
error "CDECL not available"
set Q1 ""
r toend ; make sure we're at the beginning
copy to isnl Q1 ; grab the first line
close ; don't need temp buffer anymore
}
statline -> old_statline
if (statline == 0)
1 -> statline ; make sure status line is on
status Q1 " /* press a key */" ; show the declaration
if (key == 13) ; wait for keystroke
insert Q1 ; insert declaration if Return pressed
while keypressed ; get rid of typeahead, function keys
key
old_statline -> statline ; restore previous state of status line
draw ; force screen update
;---------------------------------------------------------------------
CdeclExplain:
int old_statline
message "Explain: "
mark
{
if select ; if anything is highlighted,
copy togmark Q1 ; grab that
else
{
tosol ; if nothing highlighted,
copy to isnl Q1 ; grab current line
}
set Q1 ; let user make any desired modifications
open "" ; make an unnamed buffer
"explain " ; put in the CDECL command
insert Q1 ; and what we want converted
13 insert ; terminate line
10 insert
write "CDECL$IN.$$$" ; save to disk
status "\nWorking..."
close ; and discard buffer
}
32 call "command /c cdecl <CDECL$IN.$$$ >CDECL.$$$"
fdelete "CDECL$IN.$$$"
mark
{
if (exist "CDECL.$$$") ; did CDECL actually get run?
{
open "CDECL.$$$" ; load declaration into a buffer
fdelete "CDECL.$$$" ; don't need temp file anymore
}
else
error "CDECL not available"
set Q1 ""
r toend ; make sure we're at the beginning
copy to isnl Q1 ; grab the first line
close ; don't need temp buffer anymore
}
statline -> old_statline
if (statline == 0)
1 -> statline ; make sure status line is on
status Q1 " [press a key]" ; show the explanation
key ; wait for keystroke
while keypressed ; get rid of typeahead, function keys
key
old_statline -> statline ; restore previous state of status line
draw ; force screen update
;---------------------------------------------------------------------
InsertPrintf:
"printf() ;\n"
r (c c c c) ; position cursor between parens
;---------------------------------------------------------------------
F50 : SaveAllFiles ; Alt-F2
F51 : RunDebugger ; Alt-F3
F52 : RunProgram ; Alt-F4 run program, swapping out Sprint
F53 : ToFirstError ; Alt-F5 goto first message in error file
F54 : ToLastError ; Alt-F6 goto last message in error file
F55 : ToPrevError ; Alt-F7 goto previous error
F56 : ToNextError ; Alt-F8 goto next error
F25 : CompileFile ; Shf-F9 compile (replaces "Close all windows")
F57 : RunMake ; Alt-F9 make
F58 : DeleteErrors ; Alt-F10 delete error messages
~d : CdeclDeclare ; Shf-Alt-D run CDECL to get a declaration
~e : CdeclExplain ; Shf-Alt-E run CDECL to explain a declaration
~p : InsertPrintf ; Shf-Alt-P add printf() at cursor position
~V : ; Alt-V view file, but don't allow any changes
OpenFile ; ask for file and load it
2 -> modf ; then make it read-only
')' :
')' insert
'(' -> MatchChar
')' ShowMatchingChar
']' :
']' insert
'[' -> MatchChar
']' ShowMatchingChar
'}' :
'}' insert
'{' -> MatchChar
'}' ShowMatchingChar
:SaveUI