home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR4
/
TEXMAC.ZIP
/
SPPRINT.SPM
< prev
next >
Wrap
Text File
|
1991-08-31
|
17KB
|
536 lines
; Formatter related macros and menus
; -----------------------------------------------------------------
; Deletions
; -----------------------------------------------------------------
; Variables
; -----------------------------------------------------------------
; Forward Declarations
; -----------------------------------------------------------------
; General Macros
PrintGuess : ; try to guess which pass this file should print on
mark { ; RUN BEFORE CHANGING BUFFERS!!!
if (lines > GuessCutOff) (2 return)
r toend
if ('@' csearch) (2 return)
r toend
if ('^O' csearch) (2 return)
r toend
if ('^D' csearch) (2 return)
r toend
if ('^V' csearch) (2 return)
}
1
PrintOptions: ; fwd declare for Infomerge
; These functions use QK to hold various parameters for Spmerge.
; The format of QK is:
; letterfile<ffh>datafile<ffh>sortorder<ffh>selectioncriteria
; init sets the initial contents of QK to:
; <ffh><ffh><ffh>
; The routines below pick out the particular field required, and return
; the results in Q0. Defaults are made if nothing has been set yet
InfoLetterFile :
mark {
to QK
if current = 0ffh { ; if no letter file set yet
set Q0 cdstrip Q0 ; set default
insert Q0 ; save default
}
else {set Q0 "" copy to (current = 0ffh) Q0} ; get name out
}
InfoLetter : ; Return w/Q0 = letter file name
set Q0 fname ; to build default
InfoLetterFile ; can't combine, cause we need fname in Q0
; and InfoData calls InfoLetterFile from within QK,
; and That would give an fname of null.
InfoLetterSet : ; prompt for Letter file name and place in QK
set Q0 cdstrip fname ; get a default
message "\nLetter file to print: " set Q0
set Q0 cdstrip flist Q0 ; it looks weird, but works!
0 QCap ; file name in CAPS
mark {
to QK
erase to current = 0ffh ; prepare for new name
insert Q0
}
InfoData : ; Return w/Q0 = Data file name
set Q0 fname ; in case required to build default
mark {
to QK
to current = 0ffh c ; start of data file name
if current = 0ffh { ; if no data file set yet
set Q0 "DEFAULT.REC"
;; Next 2 lines would make default 'fname.rec'
; InfoLetterFile ; set default
; set Q0 fchange "%.REC" Q0
insert Q0 ; save default
}
else {copy to (current = 0ffh) Q0} ; get name out
}
InfoDataSet : ; prompt for Data file name and place in QK
InfoData ; get a default
message "\nData file to merge: " set Q0
set Q0 cdstrip flist Q0 ; it looks weird, but works!
0 QCap ; file name in CAPS
mark {
to QK
to current = 0ffh c
erase to current = 0ffh ; prepare for new name
insert Q0
}
InfoSortOrder : ; Return w/Q0 = Sort Order
mark {
to QK
to current = 0ffh c ; start of data file name
to current = 0ffh c ; start of Sort order info
if current = 0ffh { ; if no sort order entered
set Q0 ""
}
else {copy to (current = 0ffh) Q0} ; sort order to Q0
}
InfoOrderSet :
InfoSortOrder ; get a default
message "\nSort order: " set Q0
mark {
to QK
to current = 0ffh c
to current = 0ffh c
erase to current = 0ffh ; prepare for new sort order
insert Q0
}
InfoSortSpec : ; Return w/Q0 = Sort Criteria
mark {
to QK
to current = 0ffh c ; start of data file name
to current = 0ffh c ; start of Sort order info
to current = 0ffh c ; start of Sort Criteria info
if isend { ; if no sort criteria entered
set Q0 ""
}
else {copy toend Q0} ; sort criteria to Q0
}
InfoSpecSet :
InfoSortSpec ; get a default
message "\nRecord selection criteria: " set Q0
mark {
to QK
to current = 0ffh c
to current = 0ffh c ; start of Sort order info
to current = 0ffh c ; start of Sort Criteria info
erase toend ; prepare for new name
insert Q0
}
InfoMerge : ; preserve PrintDest, but allow temp change
(PrintDest -> SaveDest $) ; save destination, preserve argument
-> PrintDest
InfoLetter
mark (if (buffind Q0 && modf) FileSave) ; make sure file is current
InfoData
mark (if (buffind Q0 && modf) FileSave) ; make sure file is current
mark { ; build command in Q6
to Q6 clear
insert "SPMERGE "
InfoLetter insert Q0
insert " -r "
InfoData insert Q0
insert " "
if (DataFormat) insert "-remditto "
if (FirstRec != 1) (FirstRec put "-startrec %d ")
if (LastRec) (LastRec put "-endrec %d ")
InfoSortOrder if length Q0 { ; if a sort order spec'd add it
insert "-sort "
insert Q0 insert " "
}
InfoSortSpec if length Q0 { ; if selection criteria exists add it
insert "-select "
insert Q0 insert " "
}
insert "-p "
}
6 PrintOptions ; add printoptions to end
SaveDest ->PrintDest ; restore the destination as it was
; formatter can't add '-z or -p=' switches so add them here ourselves
; otherwise, they are added at the front of the command line.
mark {
to Q6
toend
insert "-z " $
if length printer {
insert "-p=" $
insert printer
}
}
if record KeyRecordEnd ; allow graceful keyrecord endings
set Q0 "spmerge.com" NeedDisk
PArg + 6 call Q6
LimitLength : ; truncates a string in Q0 to length passed to it. adding '...'
->int x ; if it truncated.
if ((length Q0) <= x) return ; no truncation necessary
mark {
to Q0
while (offset != (x-3)) c ; move to position
erase toend ; remove excess
insert "..." ; add ellipses
}
; contextual help
InfoGoHelp:
InfoPreviewHelp:
InfoFirstHelp:
InfoLastHelp:
InfoMergeMenu :
if FloppyDisk error "You can't run InfoMerge within Sprint on floppy systems"
do {
menu "Merge" {
"Go!" InfoGoHelp draw PrintDest InfoMerge,
"Screen Preview" InfoPreviewHelp draw 2 InfoMerge,
"_",
InfoLetter "Letter File\>" Q0 InfoLetterSet,
InfoData "Record File\>" Q0 InfoDataSet,
"_",
DataFormat "Data Format\>%[STANDARD%:BASIC%]"
!DataFormat ->DataFormat SetOvlModf,
FirstRec "Initial Record\>%d"
InfoFirstHelp 0 rangeget 32767 "Start with record" ->FirstRec,
LastRec "Ending Record\>%[LAST%:%d%]"
InfoLastHelp 0 rangeget 32767 "Last record to merge (0 = end)" ->LastRec,
"_",
(InfoSortOrder 17 LimitLength)
"Order\>" Q0 InfoOrderSet,
(InfoSortSpec 14 LimitLength)
"Criteria\>" Q0 InfoSpecSet
}
}
Paginate :
if (IsOnlyRuler) return
if NeedSave FileSave
; if (modf=1 || (!length fname)) FileSave
; 1 -> RestartMode
if record KeyRecordEnd ; allow graceful keyrecord endings
status "\nPaginating..."
set Q0 "spedit.exe" NeedDisk
PArg+8 call "spfmt -l=log.$$$ -p0" cdstrip fname
Restart ; I think this only happens because it's built into Sprint?
PrintingTo : PrintDest message "\nReady to send output to %[printer%;file%;screen%;queue%]"
; ----- a replacement for PrintMenu in SP.SPM -----
ClearQI : mark { to QI {
clear 253 insert ; marker
0 insert ; PrintDest = printer, of file, screen, queue
0 insert ; PrintPass = auto
1 insert ; NumCopies = 1
0 insert ; PagePause = no
0 insert ; LogErrors = no
0 insert ; Plain = no
0 insert ; AutoFill = no
0 insert ; spooling = no ; RDT, not used see PrintDest
254 insert ; 1 font = <default>
insert "PS"
254 insert ; 2 start = <first>
254 insert ; 3 end = <last>
254 insert ; 4 printer name
254 insert ; 5
254 insert ; 6 Tex Compose cline
insert "Tex " ; or Latex or Tex &lplain
254 insert ; 7 Tex DVI print cline
insert "dvieps -x.75in -y0in "
254 insert ; 8 Tex TTY cline
insert "dvi2tty -e-12 -w120 "
} }
CheckQI : mark { to QI if (current != 253) ClearQI }
; get the n'th numeric entry, return in the argument
GetQINum : ->int n CheckQI mark { to QI n repeat c current }
; set the n'th numeric entry to the value of x
SetQINum : ->int n CheckQI mark { to QI n repeat c x->current }
; get the n'th string entry, return in QD
GetQIStr : ->int n CheckQI
mark { to QI n repeat { 254 csearch c }
copy to (current = 254) QD }
; set the n'th string entry to the value of QD
SetQIStr : ->int n CheckQI
mark { to QI n repeat { 254 csearch c }
erase to (current = 254) insert QD }
GetPrinter : 5 GetQIStr $ if !length QD set QD "<default>"
; set QD printer^
SetPrinter : 10 set printer flist "*.spp" (set QD printer 5 SetQIStr)
GetFont : 1 GetQIStr if !length QD set QD "<default>"
SetFont : set QD pickfont 1 SetQIStr
CurrentDest : (PrintDest+1)%4 -> PrintDest
GetStart : 2 GetQIStr if !length QD set QD "<first>"
SetStart : 2 GetQIStr message "Starting Page (or TOC): " set QD 2 SetQIStr
GetEnd : 3 GetQIStr if !length QD set QD "<last>"
SetEnd : 3 GetQIStr message "Ending Page: " set QD 3 SetQIStr
ErasePages : ; Depaginate - remove all temporary page breaks
mark {
r toend
while ('^L' csearch) (toeol if (current != '^J') (del erase tosol))
}
readpage ; make editor know page # is different
; add print options to end of the q-register given as the argument (!= 0)
; note: the 'printer' value is appended by 'call' when bit 1 of PArg is set
; note: all options are in QI, except PrintDest which is set before
PrintOptions :
mark {
->int qreg
int GuessResult
(PrintGuess -> GuessResult $) ; check before switching buffers
; 1 -- PrintDest is global, and set in Menu
2 GetQINum -> int PrintPass
3 GetQINum -> int NumCopies
4 GetQINum -> int PagePause
5 GetQINum -> int LogErrors
6 GetQINum -> int Plain
7 GetQINum -> int AutoFill
if (PrintDest = 1)
{ set Q0 "-v " }
else if (PrintDest >= 2) ; file or queue output
{
set Q0 "%.PRN" mark(to Q0 insert home) ; easier to cleanup if in one dir.
; set Q0 cdstrip fchange "%.PRN" fname ; default file name
set Q0 flist Q0
0 QCap
do {
message "\nOutput file name: " set Q0
set Q0 flist Q0
if PrintDest = 3 (set Q4 Q0) ; preserve for my spool technique
; else set Q4 "" ; use as flag
if (!(32 exist Q0) || ask "Overwrite existing file?")
{
to Q0 insert "-o=" toend insert " " break
}
}
}
else set Q0 "" ; no trailing switches
qreg qswitch toend insert Q0
1 GetQIStr
if (length QD)
{ insert "-f=" insert QD insert " " }
2 GetQIStr
if (mark ( to QD 1 match "toc" ))
{ insert "-page=0 " } ; to print TOC only
else {
if (length QD) (insert "-start=" insert QD insert " ")
3 GetQIStr
if (length QD) (insert "-stop=" insert QD insert " ")
}
if ((NumCopies > 1) && (PrintDest != 2)) (NumCopies put "-%d ")
if (PagePause) (insert "-pause ")
if (Plain) (insert "-p ")
if (AutoFill) (insert "-f ")
if (LogErrors) (insert "-l ")
if (PrintPass)
(PrintPass put "-p%d ")
else
(GuessResult put "-p%d ")
tabsize put "-t=%d "
}
PrintDoc : ; argument is device to print to
-> PrintDest -> int Dest
5 GetQIStr set printer QD ; RDT, get stored printer name
if (IsOnlyRuler) return
; (modf=1 || (!length fname) || (!exist fname))
if NeedSave FileSave
if (!length fname) abort ; if file save didn't complete
set Q6 "spfmt "
6 PrintOptions
if record KeyRecordEnd ; allow graceful keyrecord endings
; set Q0 "spedit.exe" NeedDisk
SetOvlModf ; save damn variables in Ovl file
if (PrintDest = 3) ( ;
PArg call Q6 cdstrip fname
; call "print /p " Q4 ; Q4 now holds output file name, cleanup in autoexec
) ; Only Restart can do anything after BigDos 16 call
else (PArg+8 call Q6 cdstrip fname) ; restart causes ignorance of printdest?
WPPrintMenu : menu "SPFMT (Scribe) Print" {
"Go!" (1 GetQINum) PrintDoc,
"View on screen" 1 PrintDoc,
; "Merge" InfoMergeMenu,
"Break into pages" Paginate,
"Remove page breaks" ErasePages,
"_Print Settings",
"Default settings" if ask "Are you sure (Y,N,ESC)? "
{ ClearQI set printer "" } abort,
GetPrinter "Printer\>" QD SetPrinter abort,
GetFont "Font\>" QD SetFont abort,
(1 GetQINum) "Output to\>%[PRINTER%;SCREEN%;FILE%;QUEUE%]"
((1 GetQINum)+1)%4->x 1 SetQINum abort,
"_",
GetStart "Start Page\>" QD SetStart abort,
GetEnd "End Page\>" QD SetEnd abort,
"_",
(2 GetQINum) "A number of pAsses\>%[AUTO%;1%;2%;3%]"
((2 GetQINum)+1)%4->x 2 SetQINum abort,
(3 GetQINum) "N Number of copies\>%d"
1 rangeget 250 "Number of Copies" ->x
3 SetQINum abort,
(4 GetQINum) "C Cut sheets\>%[ NO%:YES%]"
!(4 GetQINum)->x 4 SetQINum abort,
(5 GetQINum) "L Log errors to file\>%[ NO%:YES%]"
!(5 GetQINum)->x 5 SetQINum abort,
(6 GetQINum) "U Unformatted Print\>%[ NO%:YES%]"
!(6 GetQINum)->x 6 SetQINum abort,
(7 GetQINum) "W Wordwrap Ascii Files\>%[ NO%:YES%]"
!(7 GetQINum)->x 7 SetQINum abort
}
centry : if select (
int WasBefore 0
aftermark ? swapmark : (1-> WasBefore)
insert Q0 "{"
swapmark
insert "}"
WasBefore ? swapmark ; get back in front
0->select
)
else (insert Q0 "{}" r c)
bentry : mark (0 qswitch del)
int WasBefore 0 ; flag to stay at the current end of blck
if select (
aftermark ? swapmark : (1-> WasBefore)
"@begin(" insert Q0
")\n"
swapmark
"@end(" insert Q0
")\n"
if WasBefore swapmark ; get back to front end
0->select
)
else (
"@begin(" insert Q0 ")\n\n@end(" insert Q0 ")\n" Up Up
)
TypefacesMenu : imenu "Typefaces" (
"@B (bold)" set Q0 "@b",
"@Big",
"@I (italics)" set Q0 "@i",
"@P (bold italics)" set Q0 "@p",
"@R (regular)" set Q0 "@r",
"@T (typewriter)" set Q0 "@t",
"@UX (underscore)" set Q0 "@ux",
"@U (U/characters)" set Q0 "@u",
"@UN (U/letters+digits)" set Q0 "@un",
"@+ (superscript)" set Q0 "@+",
"@- (subscript)" set Q0 "@-")
centry
DivisionsMenu : imenu "Divisions" (
"@MajorHeading",
"@Heading",
"@SubHeading",
"@Chapter",
"@Section",
"@SubSection",
"@Paragraph",
"@Appendix",
"@AppendixSection")
centry
LayoutMenu : imenu "Layout Commands" (
"@Center" bentry,
"@Flushright" bentry,
"@Quotation" bentry,
"X-@Example" set Q0 "@Example" bentry,
"@Description" bentry,
"@Enumerate" bentry,
"@Itemize" bentry,
"@Level" bentry,
"@Group" bentry,
"Other layout" message "\nLayout: " set Q0 bentry,
"@= (center line)" tosol insert "@=",
"@> (flush right)" insert "@>",
"@/ (tab stop)" insert "@/",
"@^ (set tab stop)" insert "@^",
"@PageFooting" insert
"@PageFooting(left=\"\", center=\"\", right=\"\")\n"
24 r c,
"H-@PageHeading" insert
"@PageHeading(left=\"\", center=\"\", right=\"\")\n"
24 r c,
"@BlankPage" insert Q0 "\n",
"@NewPage" insert Q0 "\n")
NotesMenu : imenu "Notes/Reference" (
"@Foot" centry,
"@Index" centry,
"@Label" 0->select centry Q3 "Name of tag" insert Q3 c,
"@Note" centry,
"@PageRef" 0->select centry Q3 "Name of tag" insert Q3 c,
"@Ref" 0->select centry Q3 "Name of tag" insert Q3 c,
"@Tag" 0->select centry Q3 "Name of tag" insert Q3 c,
"@Under" centry)
StyleMenu : imenu "Style Options" (
"LeftMargin",
"RightMargin",
"TopMargin",
"BottomMargin",
"Font",
"Fill",
"Indent",
"Justify",
"LineWidth",
"PaperLength",
"PaperWidth",
"Spacing",
"Spread",
"TabSize")
FileStart
if (1 match "@style(" || search "\n@style(")
(found search ")")
else (r toend
if (1 match "@make" || 1 match "@format") (Down)
insert "@style()\n" r c r c)
draw
r c current = '(' ? c : (c ", ")
insert Q0 " = "
; Accents
ScribeFormatMenu : menu "Scribe Menu" (
"@Typefaces" TypefacesMenu,
"@Divisions" DivisionsMenu,
"@Layout" LayoutMenu,
"@Notes/Ref" NotesMenu,
"@Style" StyleMenu
)