home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
sprint
/
spturbo.arc
/
TURBO.SPM
< prev
Wrap
Text File
|
1989-08-01
|
32KB
|
1,031 lines
; Copyright (c) 1988, 1989 Ralf Brown. All Rights Reserved.
; Portions derived from code Copyright 1988 Borland International
; Other portions from COMPILE.SPM by Chris Barker, CIS ID 72261,2312
;
; May be freely redistributed provided no fee is charged and the above
; copyright notice remains intact.
;---------------------------------------------------------------------
; Turbo Languages compilation support package: Turbo Pascal, Turbo C,
; Turbo Assembler, Turbo Debugger. Allows setting compiler options which
; will be passed to the command-line versions of the compilers.
;
; To install, just load this file with the Alt-U-M-R or Alt-U-M-L command.
; Uncomment the last line if you want the new user interface saved as the
; default user interface.
;
; Created: Nov 12, 1988
; LastEdit: Aug 1, 1989
; Release: v2.3
;---------------------------------------------------------------------
; 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 (pops up menu if not .C, .H, .PAS, .ASM, or .SPM)
; Alt-F9 run MAKE
; Alt-F10 remove error list
; ), ], } briefly move cursor to matching opening delimiter
; Shf-Alt-C pop up compiler menu, allows setting compiler options
; Shf-Alt-D show declaration corresponding to English description
; Shf-Alt-E explain declaration on the current line, or marked declaration
; Shf-Alt-F add for(;;){} at cursor position
; Shf-Alt-P add printf() call at cursor position
; Shf-Alt-W add while(){} at cursor position
;---------------------------------------------------------------------
; Q registers used:
; Q1 name of file containing error or warning, misc
; Q4 path to file(s) being compiled
; Q7 miscellaneous
; QD original path; file before switching to error; line number
; QP compiler command-line switches, other scratch storage
;---------------------------------------------------------------------
; Program History:
; v1.0 12/12/88 first release
; v1.1 1/8/89 fixed delimiter-matching when inside a string
; v1.2 3/8/89 sped up delimiter-matching
; v2.0 7/9/89 merged with COMPILE.SPM by Chris Barker
; now parses TP and TASM error messages
; v2.1 7/10/89 minor bug fixes
; v2.2 7/14/89 added more TurboC and TurboPascal options
; v2.3 8/1/89 additional TP5.5 flags
; second release
;---------------------------------------------------------------------
; start with default Borland user interface
#include "sp"
;---------------------------------------------------------------------
; Initialize debug code generation to false(0). These settings will be
; sticky - they will stay set to however you last set them.
int Pdebug 0
int Cdebug 0
int Adebug 0
; Initialize memory model
int Cmodel 1 ; 0 = -mt, 1 = -ms, 2 = -mc, 3 = -mm, 4 = -ml, 5 = -mh
; Initialize command-line options to none
; These are also "sticky"
int Copts 0
int PASopts 0
int ASMopts 0
int Lopts 0
;---------------------------------------------------------------------
SaveUI : $ ovlwrite "turbo.ui" ovlwrite "sp"
;---------------------------------------------------------------------
InsideQuotes:
0 -> int single
0 -> int double
stopped mark {
tosol
do {
2 search "[\"\'\n]"
if (before themark)
{
if (current == '\'' && double == 0)
1 - single -> single
if (current == '"' && single == 0)
1 - double -> double
c
}
}
while (before themark)
}
single || double
;---------------------------------------------------------------------
int MatchChar 0
ShowMatchingChar : ; derived from MATCH.SPM, (c) Copyright Borland International
->int ThisChar
1 -> int NestingLevel
dline -> int numlines
scrollborder -> int old_border
0 -> scrollborder
set themark ; remember where we were
r c ; skip back from the just-inserted delimiter
if (!InsideQuotes)
{
r stopped while (NestingLevel && !(r isend))
{
2 search "[(){}\\[\\]'\"\n]"
if (current == ThisChar)
++NestingLevel
else if (current == MatchChar)
--NestingLevel
else if (current == '\'')
{
to (current == '\'' || isnl)
c ; skip quote or NL
}
else if (current == '"')
{
to (current == '"' || isnl)
c ; skip quote or NL
}
else if isnl
{
if (--numlines < 0)
break
}
else
c ; keep moving backwards
}
if (NestingLevel == 0) ; found?
mark
{
set themark ; highlight the matched character for
1->select ; 1/10 second
c
draw
100 wait
0->select
r c
draw
}
else if !isnl
{
MatchChar message "no matching '%c'"
}
}
swap themark
old_border -> scrollborder
;---------------------------------------------------------------------
ParseCerror :
tosol
mark {
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 ; now show the parsed error message
}
;---------------------------------------------------------------------
ParseASMerror :
tosol
mark {
c ; skip the "**" at the start of the line
if (current == 'W') ; is it a warning or an error?
set Q7 "W"
else
{
c
if (current == 'F') ; was it a Fatal error?
set Q7 "F"
else
set Q7 "E"
}
to iswhite
c
copy to (current == '(') Q1 ; and get it
to (current == '(')
c
copy to (current == ')') QD ; get line number
1 -> append
copy to (current == ')') Q7 ; and also add it to output message
to iswhite ; skip to error message
1 -> append
copy toeol Q7 ; and add it to the output message
mode Q7 ; now show the parsed error message
}
;---------------------------------------------------------------------
ParsePASerror :
tosol
mark {
copy to (current == '(') Q1 ; get filename in which error occurred
to (current == '(') ; now skip it
c
copy to (current == ')') QD ; get line number
to isgray
c ; skip blank before "Error" or "Warning"
if (current == 'W') ; was this a warning or an error?
set Q7 "W"
else
set Q7 "E"
to (current == ':') ; skip message type
c
mark { to Q7 toend insert QD } ; add line number to output message
1 -> append
copy toeol Q7 ; add error message to output
mode Q7 ; and now show the parsed err message
}
;---------------------------------------------------------------------
; Check if the current line in the current buffer is an error or
; warning message. Return 0 if not, 1 if TCC-style error, 2 if TASM-style
; error, or 3 if TPas-style error
IsErrorMsg :
int type
if (((0 match "Warning") && !(0 match "Warning messages")) ||
((0 match "Error") && !(0 match "Error messages")))
1 -> type
else if ((0 match "**Error**") || (0 match "*Warning*") || (0 match "**Fatal**"))
2 -> type
else
mark {
to isgray
if ((0 match " Error ") || (0 match " Warning"))
3 -> type
else
0 -> type
}
type
;---------------------------------------------------------------------
ShowErrorMsg :
-> int type
int WasFound
2 -> statline
set Q1 ""
buffind "MAKE.$$$"
type case {
1 ParseCerror, ; display parsed errror message
2 ParseASMerror,
3 ParsePASerror,
$ error "internal: unknown error message type"
}
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 Q4 ; 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 :
int type
0 -> int Done
tosol
while (!(IsErrorMsg -> type) && (1->Done) && line != ++line)
0 -> Done
if Done
{
if (statline > 1)
1 -> statline
message "\nCompilation successful. Press a key..."
key
message "\n"
}
else
{ type ShowErrorMsg }
;---------------------------------------------------------------------
FlagsHack :
; hook to allow UI which includes this file to use flag[3456] in
; the flags line
;---------------------------------------------------------------------
Restart : ; patterned after Borland's Restart
NormalMode
FlagsHack ; hook to reset flag3, flag4, flag5, flag6
mark
{
if (exist "log.$$$") ; for compatibility with standard UI
{
draw pageread "log.$$$"
fdelete "log.$$$"
}
}
if (exist "MAKE.$$$")
{
open "MAKE.$$$"
fdelete "MAKE.$$$" ; 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
;---------------------------------------------------------------------
FindErrorFile :
if (!buffind "MAKE.$$$") ; switch to buffer containing messages
error "No error file"
;---------------------------------------------------------------------
NoMoreErrors :
if (statline > 1)
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
;---------------------------------------------------------------------
ToPrevError:
int type
0 -> int Done
set QD fname ; remember where we were
FindErrorFile ; switch to file containing errors
--line ; back up a line
while (!(IsErrorMsg -> type) && (1->Done) && line != --line)
0 -> Done ; continue backing up until msg found
if Done
NoMoreErrors
else
{ type ShowErrorMsg }
;---------------------------------------------------------------------
ToNextError :
int type
0 -> int Done
set QD fname ; remember where we were
FindErrorFile
++line ; down a line
while (!(IsErrorMsg -> type) && (1->Done) && line != ++line)
0 -> Done ; continue down until message found
if Done
NoMoreErrors
else
{ type ShowErrorMsg }
;---------------------------------------------------------------------
ToFirstError:
FindErrorFile
r toend
ToNextError
;---------------------------------------------------------------------
ToLastError:
FindErrorFile
toend
ToPrevError
;---------------------------------------------------------------------
CloseErrorFile :
mark
{
if (buffind "MAKE.$$$") ; get rid of buffer for error messages
close
}
;---------------------------------------------------------------------
SaveAllFiles :
mark
{
bufnum -> int old_buf ; remember where we were
do { ; for each buffer: if modified, save
if (modf == 1 && !IsUnnamed)
write fname
} while (bufswitch && bufnum != old_buf)
}
message "\nAll files saved"
;---------------------------------------------------------------------
GetCompileDir :
set QD cd ; remember where we were
set Q4 fname ; get name of file in current buffer
mark
{
to Q4 toend r c ; strip off last component of name
while (length Q4 && current != '/' && current != '\\' && current != ':')
{
del
r c
}
if (current == '\\' || current == '/')
del
}
CloseErrorFile
set cd Q4 ; go to directory containing the file
;---------------------------------------------------------------------
MakeOptionsPermanent :
if ovlmodf
ovlwrite "sp.ovl"
;---------------------------------------------------------------------
RunDebugger:
if length fname
set QP fchange "%.EXE" fname
else
set QP ""
message "\nProgram to debug: "
set QP
MakeOptionsPermanent ; Sprint doesn't save overlay when swapping!
24 call "td" QP ; load TD, swapping out Sprint
;---------------------------------------------------------------------
RunProgram:
if length fname
set QP fchange "%.EXE" fname
else
set QP ""
message "\nProgram to run: "
set QP
MakeOptionsPermanent ; Sprint doesn't save overlay when swapping!
25 call QP ; run program, swapping out Sprint
;---------------------------------------------------------------------
SelectModel:
menu "Memory Model" {
"Tiny" 0 -> Cmodel,
"Small" 1 -> Cmodel,
"Compact" 2 -> Cmodel,
"Medium" 3 -> Cmodel,
"Large" 4 -> Cmodel,
"Huge" 5 -> Cmodel
}
;---------------------------------------------------------------------
PASSettingsMenu:
stopped do {
menu "Pascal Settings" {
Pdebug "Debug Info\>%[NO%:YES%]" !Pdebug->Pdebug,
;--comment out next two lines for TP4
(PASopts & 3) "Map File\>%[None%;Segments%;Publics%:Detail%]"
(PASopts & ~3)|(((PASopts&3)+1) & 3)->PASopts,
;--and use the next line instead
; (PASopts & 3) "Map File\>%[NO%:YES%]" PASops^1->PASopts,
((PASopts &12)>>2) "Compile Type\>%[Compile%;Build%:Make%]"
if (PASopts&12 == 8)
(PASopts & ~12)->PASopts
else
(PASopts & ~12)|(((PASopts&12)+4)&12)->PASopts,
(PASopts &16) "Force FAR Calls\>%[NO%:YES%]" PASopts^16->PASopts,
(PASopts &32) "Boolean Eval\>%[SHORT%:FULL%]" PASopts^32->PASopts,
(PASopts &64) "Numerics\>%[SOFT%:HARD%]WARE" PASopts^64->PASopts,
(PASopts&128) "Link Buffer\>%[DISK%:MEMORY%]" PASopts^128->PASopts,
"_Runtime",
(PASopts&256) "Stack Checks\>%[NO%:YES%]" PASopts^256->PASopts,
(PASopts&1024)"VarString Checks\>%[ NO%:YES%]" PASopts^1024->PASopts,
(PASopts&2048)"Range Checks\>%[NO%:YES%]" PASopts^2048->PASopts,
(PASopts&4096)"I/O Checks\>%[NO%:YES%]" PASopts^4096->PASopts
}
}
;---------------------------------------------------------------------
DecodePASsettings:
set QP "/q"
mark {
to QP
f toend
if Pdebug
"/v/$L+/$D+" ; remove the /v/$L+ for TP4
;--use the following for TP4
; "/$T"
; if (PASopts & 3) "+" else "-"
;--comment out the following if using TP4
(PASopts & 3) case
{
1 "/GS"
2 "/GP"
3 "/GD"
}
;--end of block to comment out for TP4
(PASopts & 12) case
{
4 "/B"
8 "/M"
}
"/$F"
if (PASopts & 16) "+" else "-"
"/$B"
if (PASopts & 32) "+" else "-"
"/$N"
if (PASopts & 64) "+" else "-"
"/$L"
if (PASopts & 128) "+" else "-"
"/$S"
if (PASopts & 256) "+" else "-"
"/$V"
if (PASopts & 1024) "+" else "-"
"/$R"
if (PASopts & 2048) "+" else "-"
"/$I"
if (PASopts & 4096) "+" else "-"
}
;---------------------------------------------------------------------
CSettingsMenu:
stopped do {
menu "C Settings" {
Cmodel "Memory Model\>%[T%;S%;C%;M%;L%:H]" SelectModel,
(Copts & 2) "Alignment\>%[BYTE%:WORD%]" Copts^2->Copts,
(Copts & 4) "Generate for\>80%[%:1%]86" Copts^4->Copts,
(Copts & 8) "Calling Conv\>%[C%:Pascal%]" Copts^8->Copts,
(Copts & 1) "Strict ANSI\>%[NO%:YES%]" Copts^1->Copts,
(Copts&2048)"Default Chars\>%[ %:UN%]SIGNED" Copts^2048->Copts,
(Copts &16) "Produce .ASM\>%[NO%:YES%]" Copts^16->Copts,
"_Debugging",
Cdebug "Debug Info\>%[NO%:YES%]" !Cdebug->Cdebug,
(Copts&512) "Std Stack Frame\>%[YES%:NO%]" Copts^512->Copts,
(Copts&1024)"Stack Overflow\>%[NO%:YES%]" Copts^1024->Copts,
"_Optimization",
(Copts&4096)"Optimize for\>%[SPEED%:SIZE%]" Copts^4096->Copts,
(Copts&256) "Merge Dup Strings\>%[ NO%:YES%]" Copts^256->Copts,
"_Warnings",
(Copts &32) "No Prototype\>%[WARN%:OK%]" Copts^32->Copts,
(Copts &64) "No Declaration\>%[WARN%:OK%]" Copts^64->Copts,
(Copts&128) "Poss Inc Assign\>%[WARN%:OK%]" Copts^128->Copts
}
}
;---------------------------------------------------------------------
DecodeCsettings:
if Cdebug
set QP "-v "
else
set QP ""
mark {
to QP
toend
Cmodel case {
0 "-mt",
1 "-ms",
2 "-mc",
3 "-mm",
4 "-ml",
$ "-mh"
}
" -A"
if ((Copts & 1) == 0)
"-"
" -a"
if ((Copts & 2) == 0)
"-"
"-1"
if ((Copts & 4) == 0)
"-"
if (Copts & 8)
" -P"
if (Copts & 16)
" -S" ; compile to .ASM
else
" -c" ; compile to .OBJ
if (Copts & 32)
" -w-pro"
if (Copts & 64)
" -w-nod"
if (Copts & 128)
" -w-pia"
if (Copts & 256)
" -d"
" -k"
if (Copts & 512)
"-"
" -N"
if ((Copts & 1024) == 0)
"-"
" -K"
if ((Copts & 2048) == 0)
"-"
" -G"
if (Copts & 4096)
"-"
}
;---------------------------------------------------------------------
TASMSettingsMenu:
stopped do {
menu "Assembler Settings" {
Adebug "Debug Info\>%[NO%:YES%]" !Adebug->Adebug,
(ASMopts & 8) "Case Sensitive\>%[NO%:YES%]" ASMopts^8->ASMopts,
(ASMopts & 1) "Segment Order \>%[ Seq%:Alpha%]" ASMopts^1->ASMopts,
"_Listing",
(ASMopts & 4) "Generate Listing\>%[NO%:YES%]" ASMopts^4->ASMopts,
(ASMopts & 2) "XReference\>%[NO%:YES%]" ASMopts^2->ASMopts,
(ASMopts &64) "Symbol table\>%[YES%:NO%]" ASMopts^64->ASMopts,
"_Compatibility",
(ASMopts &16) "MASM version\>5.%[0%:1%]" ASMopts^16->ASMopts,
(ASMopts &32) "QUIRKS mode\>%[OFF%:ON%]" ASMopts^32->ASMopts
}
}
;---------------------------------------------------------------------
DecodeASMsettings:
set QP "/w" ; enable warnings
mark {
to QP
toend
if Adebug
" /zi"
if (ASMopts & 1)
" /a"
else
" /s"
if (ASMopts & 2)
" /c"
if (ASMopts & 4)
" /l"
if (ASMopts & 8)
" /ml"
if (ASMopts & 16)
" /jmasm51"
if (ASMopts & 32)
" /jquirks"
if (ASMopts & 64)
" /n"
}
;---------------------------------------------------------------------
LinkSettingsMenu:
stopped do {
menu "Linker Settings" {
(Lopts & 64) "Debug Info\>%[NO%:YES%]" (Lopts^64)->Lopts,
(Lopts & 3) "Map file\>%[None%;Publics%;Lines%:Detail%]"
(((Lopts&3)+1)&3) | (Lopts & ~3) -> Lopts,
(Lopts & 4) "Case Sensitive\>%[NO%:YES%]" (Lopts^4)->Lopts,
(Lopts & 8) "Initialize Segments\>%[ NO%:YES%]" (Lopts^8)->Lopts,
(Lopts & 16) "Duplicate Symbols\>%[OK%:WARN%]" (Lopts^16)->Lopts,
(Lopts & 32) "Generate .COM file\>%[NO%:YES%]" (Lopts^32)->Lopts,
(Lopts &128) "Use extended dict\>%[YES%:NO%]" (Lopts^128)->Lopts,
(Lopts &256) "L use default Libs\>%[YES%:NO%]" (Lopts^256)->Lopts,
(Lopts &512) "32-bit processing\>%[NO%:YES%]" (Lopts^512)->Lopts
}
}
;---------------------------------------------------------------------
DecodeLINKsettings:
if (Lopts & 64)
set QP "/v"
else
set QP ""
mark {
to QP
toend
(Lopts & 3) case {
0 " /x",
1 " /m",
2 " /m/l",
$ " /m/s"
}
if (Lopts & 4)
" /c"
if (Lopts & 8)
" /i"
if (Lopts & 16)
" /d"
if (Lopts & 32)
" /t"
if (Lopts & 128)
" /e"
if (Lopts & 256)
" /n"
if (Lopts & 512)
" /3"
}
;---------------------------------------------------------------------
RunPascal:
SaveAllFiles
GetCompileDir
status "\nCompiling..."
DecodePASsettings ; QP := the selected cmd-line switches
MakeOptionsPermanent ; SP 1.00a doesn't update overlay on "call" that swaps!
56 call "command /ctpc >MAKE.$$$" QP cdstrip fname ; swap out SP to run compiler
; if you don't need Sprint to swap out, change the 56 above to 0, comment out
; the MakeOptionsPermanent, and uncomment the next line
; Restart
;---------------------------------------------------------------------
RunCCompiler:
SaveAllFiles
GetCompileDir
status "\nCompiling..." ; clear the status line
DecodeCsettings ; QP := the selected cmd-line switches
set Q1 cdstrip fname
if (mark (to Q1 1 search ".h")) ; if header, compile corresponding
set Q1 fchange "%.C" Q1 ; .C source file
MakeOptionsPermanent ; SP 1.00a doesn't update overlay on "call" that swaps!
56 call "command /ctcc >MAKE.$$$" QP Q1 ; swap out SP to run compiler
;---------------------------------------------------------------------
RunAssembler:
SaveAllFiles
GetCompileDir
status "\nAssembling...."
DecodeASMsettings ; set QP to the selected command-line switches
MakeOptionsPermanent ; SP 1.00a doesn't update overlay on "call" that swaps!
56 call "command /ctasm >MAKE.$$$" QP cdstrip fname
; if you don't need Sprint to swap out to run the assembler, change the 56
; above to 0, comment out the MakeOptionsPermanent, and uncomment the next line
; Restart
;---------------------------------------------------------------------
RunLinker:
set Q1 fchange "%.obj" cdstrip fname
DecodeLINKsettings
1 call "tlink" QP Q1
;---------------------------------------------------------------------
CompileMenu:
menu "Compiler Menu" {
"Pascal" RunPascal,
"C" RunCCompiler,
"Assembler" RunAssembler,
"Linker" RunLinker,
"_Settings",
"1 Pascal" PASSettingsMenu,
"2 C" CSettingsMenu,
"3 Assembler" TASMSettingsMenu,
"4 Linker" LinkSettingsMenu
}
;---------------------------------------------------------------------
CompileFile:
set Q1 cdstrip fname
if (mark (to Q1 1 search ".pas"))
RunPascal
else if (mark (to Q1 1 search ".asm"))
RunAssembler
else if (mark (to Q1 2 search ".[cChH]"))
RunCCompiler
else if (mark (to Q1 1 search ".spm"))
{
SaveAllFiles
GetCompileDir
MacroRunFile
set cd QD
}
else
CompileMenu ; unknown extension, so ask what to do
;---------------------------------------------------------------------
RunMake:
SaveAllFiles
status "\nRunning MAKE..."
GetCompileDir
MakeOptionsPermanent
56 call "command /c >MAKE.$$$ make" ; run the make, swapping out Sprint
;---------------------------------------------------------------------
DeleteErrors:
if (statline > 1)
1 -> statline ; shut off mode line for messages
CloseErrorFile
if (exist "MAKE.$$$") ; in the unlikely event that the error
fdelete "MAKE.$$$" ; file still exists, delete it
;---------------------------------------------------------------------
CdeclDeclare:
int old_statline
message "\nDeclare: "
set QP "" ; no default declaration
set QP ; 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 QP ; and what we want converted
; 10 insert ; terminate line
; 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" QP
; comment out prev line and uncomment prior block if cdecl requires input from
; stdin
if (exist "CDECL.$$$") ; did CDECL actually get run?
mark {
open "CDECL.$$$" ; load declaration into a buffer
fdelete "CDECL.$$$" ; don't need temp file anymore
set QP ""
r toend ; make sure we're at the beginning
copy to isnl QP ; grab the first line
close ; don't need temp buffer anymore
}
else
error "CDECL not available"
statline -> old_statline
if (statline == 0)
1 -> statline ; make sure status line is on
status QP " /* press a key */" ; show the declaration
if (key == 13) ; wait for keystroke
insert QP ; 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 QP ; grab that
else
{
tosol ; if nothing highlighted,
copy to isnl QP ; grab current line
}
set QP ; let user make any desired modifications
}
;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
; "explain " ; put in the CDECL command
; insert QP ; and what we want converted
; 10 insert ; terminate line
; 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 explain" QP
; comment out prev line and uncomment prior block if cdecl requires input from
; stdin
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 QP ""
r toend ; make sure we're at the beginning
copy to isnl QP ; 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 QP " [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
;---------------------------------------------------------------------
InsertWhile:
line -> int old_line
column -> int old_col
"while ()\n"
while (column < old_col + 3)
" "
"{\n\n"
while (column < old_col + 3)
" "
"}"
old_line -> line ; back to the line with the "while"
toeol ; and position between parens
r c
;---------------------------------------------------------------------
InsertFor:
line -> int old_line
column -> int old_col
"for (;;)\n"
while (column < old_col + 3)
" "
"{\n\n"
while (column < old_col + 3)
" "
"}"
old_line -> line ; back to the line with the "for"
toeol ; and position between open paren and
r (c c c) ; first semicolon
;---------------------------------------------------------------------
ViewFile:
OpenFile ; ask for file and load it
2 -> modf ; then make it read-only
;---------------------------------------------------------------------
F50 : SaveAllFiles ; Alt-F2 save all modified files
F51 : RunDebugger ; Alt-F3 invoke Turbo Debugger
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
~c : CompileMenu ; Shf-Alt-C pop up compiler menu
~d : CdeclDeclare ; Shf-Alt-D run CDECL to get a declaration
~e : CdeclExplain ; Shf-Alt-E run CDECL to explain a declaration
~f : InsertFor ; Shf-Alt-F add for(;;){} at cursor position
~p : InsertPrintf ; Shf-Alt-P add printf() at cursor position
~w : InsertWhile ; Shf-Alt-W add while(){} at cursor position
~V : ViewFile ; Alt-V view file, but don't allow any changes
')' :
')' insert
'(' -> MatchChar
')' ShowMatchingChar
']' :
']' insert
'[' -> MatchChar
']' ShowMatchingChar
'}' :
'}' insert
'{' -> MatchChar
'}' ShowMatchingChar
; uncomment the next line to save new user interface as default
;:SaveUI