home *** CD-ROM | disk | FTP | other *** search
- { MSPRTM.PAS
- MS 4.0
- Copyright (c) 1985, 87 by Borland International, Inc. }
-
- {$I msdirect.inc}
-
- unit MsPrtM;
- {-Print menu to set up a print job}
-
- interface
-
- uses
- Crt, {Basic video operations - standard unit}
- Dos, {DOS interface - standard unit}
- Errors, {Runtime error handler}
- MsVars, {Global types and declarations}
- MsScrn1, {Fast screen writing routines}
- MsString, {String primitives}
- MsPtrOp, {Pointer primitives}
- EscSeq, {Returns text string for extended scan codes}
- MsCmds, {Maps keystrokes to commands}
- Int24, {DOS critical error handler}
- Message, {Message system}
- MsUser, {User keyboard input, line edit, error report, help}
- MsMemOp, {Text buffer allocation and deallocation}
- MsBack, {Background processes}
- MsScrn2, {Editor screen updating}
- MsMenu, {Pulldown and custom menu system}
- MsDir, {Popup directory picker}
- MsEdit, {Basic editing commands}
- MsText, {Text processing commands}
- MsFile, {File I/O routines}
- MsMacro; {Macro editing and processing}
-
- procedure EdInitPrintState;
- {-Set up initial state of print job}
-
- procedure EdPrintSetDefaults(PrtDefFile : Filepath);
- {-Set up defaults for printing system}
-
- function EdPrintSetup : Boolean;
- {-Set up a print job and edit printer definitions, returning true if print is to start}
-
- {==========================================================================}
-
- implementation
-
- const
- PrtDefExt : ExtString = 'PDF';
- PdfSignature : string[6] = 'PRTDEF'; {At the beginning of every printer file}
-
- procedure EdGetOutputDest(var ToFile : Boolean; var Printer : Byte);
- {-Prompt for and return the output destination of a print job}
- var
- Menu : CustomMenuRec;
- Choice : Integer;
-
- function EdBuildMessages(var Menu : CustomMenuRec) : Boolean;
- {-Build the message table for the menu}
- var
- Item : Integer;
- S : VarString;
-
- begin {EdBuildMessages}
- EdBuildMessages := False;
- with Menu do begin
- if EdMemAvail(Succ(MaxChoice) shl 2, FreeListTemp) then
- {Get the pointers}
- GetMem(Messages, Succ(MaxChoice) shl 2)
- else
- Exit;
-
- {Get the string space and fill in the items}
- for Item := MinChoice to MaxChoice do begin
- case Item of
- 1 : S := 'File';
- 2, 3 : S := 'LPT'+Chr(47+Item);
- end;
- if EdMemAvail(Succ(Length(S)), FreeListTemp) then
- GetMem(Messages^[Item], Succ(Length(S)))
- else
- Exit;
- Messages^[Item]^ := S;
- end;
- end;
- EdBuildMessages := True;
- end; {EdBuildMessages}
-
- begin {EdGetOutputDest}
-
- {Initialize the menu}
- with Menu do begin
- Xmin := 37;
- Ymin := 21;
- MessageNum := 304;
- PromptNum := 390;
- MinChoice := 1;
- MaxChoice := 3;
- InitChoice := 1;
- CmdSet := PrtCmdSet;
- UseLetters := False;
- end;
- if not(EdBuildMessages(Menu)) then begin
- EdErrormsg(35);
- Exit;
- end;
-
- {Get the menu choice}
- EdGetCustomMenuChoice(Menu, Choice);
-
- if not(Abortcmd) then
- case Choice of
- 1 :
- ToFile := True;
- 2 :
- begin
- ToFile := False;
- Printer := 0;
- end;
- 3 :
- begin
- ToFile := False;
- Printer := 1;
- end;
- end;
-
- end; {EdGetOutputDest}
-
- procedure EdReadPrinterFile(Fname : Filepath; var Pdef : PrinterDefinition);
- {-Read a printer definition from a file}
- label
- ExitPoint;
- var
- F : file;
- C : PrintCommandtype;
- S : PrintCommand;
- M : Boolean;
- BytesRead : Word;
- TestSig : VarString;
-
- begin {EdReadPrinterFile}
-
- Assign(F, Fname);
- Reset(F, 1);
- if EdFileerror then
- Exit;
-
- with Pdef do begin
-
- {Check signature}
- EdBlockRead(F, TestSig, Succ(Length(PdfSignature)), BytesRead);
- if Goterror then
- goto ExitPoint;
- if TestSig <> PdfSignature then begin
- EdErrormsg(61);
- goto ExitPoint;
- end;
-
- {Read each command string from packed format}
- for C := PrtInit to PrtNone do
- for M := False to True do begin
- EdBlockRead(F, S[0], 1, BytesRead);
- if Goterror or (BytesRead <> 1) then
- goto ExitPoint;
- EdBlockRead(F, S[1], Length(S), BytesRead);
- if Goterror or (BytesRead <> Length(S)) then
- goto ExitPoint;
- Commands[C] [M] := S;
- end;
-
- {Read booleans}
- EdBlockRead(F, FormfeedMode, 1, BytesRead);
- if Goterror or (BytesRead <> 1) then
- goto ExitPoint;
- EdBlockRead(F, PaperPause, 1, BytesRead);
- if Goterror or (BytesRead <> 1) then
- ;
-
- end;
-
- ExitPoint:
- Close(F);
- end; {EdReadPrinterFile}
-
- procedure EdPrintSetDefaults(PrtDefFile : Filepath);
- {-Set up defaults for printing system}
-
- begin {EdPrintSetDefaults}
- Printing := False;
- FillChar(PrintDef, SizeOf(PrintDef), 0);
- with PrintJob do begin
- {Load printer definition if file is found}
- if EdExistFile(PrtDefFile) then begin
- EdReadPrinterFile(PrtDefFile, PrintDef);
- if Goterror then begin
- {Ignore error and continue}
- Goterror := False;
- EdClearString(Devicename);
- end else
- Devicename := PrtDefFile;
- end else
- EdClearString(Devicename);
- EdClearString(PrintFilename);
- StartPage := 1; {First page to print}
- StopPage := MaxPage; {Last page to print}
- Format := SaveFormatState; {True to interpret dot commands}
- ToFile := SaveToFile; {True to print to file}
- OutFilename := SaveOutputName; {Output file name, if any}
- Printer := SavePrinterPort; {Use LPT1 or LPT2}
- end;
- end; {EdPrintSetDefaults}
-
- procedure EdWritePrinterFile(Fname : Filepath; var Pdef : PrinterDefinition);
- {-Write a printer definition to a file}
- label
- ExitPoint;
- var
- F : file;
- C : PrintCommandtype;
- S : PrintCommand;
- M : Boolean;
-
- begin {EdWritePrinterFile}
-
- Assign(F, Fname);
- Rewrite(F, 1);
- if EdFileerror then
- Exit;
-
- with Pdef do begin
-
- {Write signature}
- EdBlockWrite(F, PdfSignature, Succ(Length(PdfSignature)));
- if Goterror then
- goto ExitPoint;
-
- {Write each command string in a packed format}
- for C := PrtInit to PrtNone do
- for M := False to True do begin
- S := Commands[C] [M];
- {Write packed string}
- EdBlockWrite(F, S, Succ(Length(S)));
- if Goterror then
- goto ExitPoint;
- end;
-
- {Write booleans}
- EdBlockWrite(F, FormfeedMode, 1);
- if Goterror then
- goto ExitPoint;
- EdBlockWrite(F, PaperPause, 1);
- if Goterror then
- ;
-
- end;
-
- ExitPoint:
- Close(F);
- end; {EdWritePrinterFile}
-
- function EdBuildPrintMenuMessages(var Menu : CustomMenuRec) : Boolean;
- {-Build the message table for the printer string menu}
- var
- Item : Integer;
- S : VarString;
- C : PrintCommandtype;
- M : Boolean;
-
- begin {EdBuildPrintMenuMessages}
- EdBuildPrintMenuMessages := False;
- with Menu do begin
-
- if EdMemAvail(Succ(MaxChoice) shl 2, FreeListTemp) then
- {Get the pointers}
- GetMem(Messages, Succ(MaxChoice) shl 2)
- else
- Exit;
-
- {Get the string space and fill in the items}
- Item := 0;
-
- {Printer init and reset strings}
- for M := False to True do begin
- S := EdGetMessage(248+Item);
- if EdMemAvail(Succ(Length(S)), FreeListTemp) then
- GetMem(Messages^[Item], Succ(Length(S)))
- else
- Exit;
- Messages^[Item]^ := S;
- Inc(Item);
- end;
-
- {Font control strings}
- for C := PrtBold to PrtAlt2 do
- for M := False to True do begin
- S := EdGetMessage(Ord(C)+414)+OnOff[not(M)];
- if EdMemAvail(Succ(Length(S)), FreeListTemp) then
- GetMem(Messages^[Item], Succ(Length(S)))
- else
- Exit;
- GetMem(Messages^[Item], Succ(Length(S)));
- Messages^[Item]^ := S;
- Inc(Item);
- end;
-
- end;
- EdBuildPrintMenuMessages := True;
- end; {EdBuildPrintMenuMessages}
-
- function EdValidPrintEntries : Boolean;
- {-Return true if the print selections are valid}
- var
- W : Pwindesc;
-
- function EdPrintFileInMemory(var W : Pwindesc) : Boolean;
- {-Return True and window descriptor if print file in memory}
- var
- Fname : Filepath;
- Found : Boolean;
-
- begin {EdPrintFileInMemory}
- Found := False;
- if WindowCount > 0 then begin
- Fname := PrintJob.PrintFilename;
- W := Window1;
- repeat
- Found := (W^.Filename = Fname);
- if not(Found) then
- EdFwdPtr(W);
- until Found or (W = Window1);
- end;
- EdPrintFileInMemory := Found;
- end; {EdPrintFileInMemory}
-
- begin {EdValidPrintEntries}
- EdValidPrintEntries := False;
-
- {If print file is in memory and modified, raise a flag}
- if EdPrintFileInMemory(W) then
- if W^.Modified then begin
- EdErrormsg(65);
- Exit;
- end;
-
- with PrintJob do begin
- {Make sure print file exists}
- if not(EdExistFile(PrintFilename)) then begin
- EdErrormsg(67);
- Exit;
- end;
- {Make sure output file can be overwritten}
- if ToFile then begin
- if EdHasWildCards(OutFilename) or EdStringEmpty(OutFilename) then begin
- EdErrormsg(68);
- Exit;
- end;
- if EdExistFile(OutFilename) then
- if not(EdYesNo(EdGetMessage(319))) then
- Exit;
- end;
- {Make sure page numbers are valid}
- if StopPage < StartPage then begin
- EdErrormsg(66);
- Exit;
- end;
- end;
-
- EdValidPrintEntries := True;
- end; {EdValidPrintEntries}
-
- procedure EdSetFileDefault;
- {-Set initial guess at print file}
-
- begin {EdSetFileDefault}
- with PrintJob do begin
- if EdHasWildCards(PrintFilename) or EdStringEmpty(PrintFilename) then begin
- if EdHasWildCards(LastPrintFile) or EdStringEmpty(LastPrintFile) then begin
- if EdHasWildCards(LastFileEdit) or EdStringEmpty(LastFileEdit) then begin
- if Curwin^.Filename <> NoFile then
- PrintFilename := Curwin^.Filename;
- end else
- PrintFilename := LastFileEdit;
- end else
- PrintFilename := LastPrintFile;
- end;
- if not(EdStringEmpty(PrintFilename)) then
- {Add default extension}
- EdDefaultExtension(DefExtension, PrintFilename);
- end;
- end; {EdSetFileDefault}
-
- procedure EdDrawSeparator(W : WindowRec; WhichItem : Integer);
- {-Draw a bar spanning the whole window at row WhichItem}
- var
- SpanBar : VarString;
-
- begin {EdDrawSeparator}
- with W do begin
- SpanBar[0] := Chr(XSize);
- FillChar(SpanBar[1], Length(SpanBar), Border[Horiz]);
- SpanBar[1] := Border[LeftJoin];
- SpanBar[XSize] := Border[RightJoin];
- EdFastWrite(SpanBar, YPosn+WhichItem, XPosn, ScreenAttr[MfColor]);
- end;
- end; {EdDrawSeparator}
-
- procedure EdInitPrintState;
- {-Set up initial state of print job}
-
- procedure EdCheckMargins;
- {-Assure margins are self-consistent}
-
- begin {EdCheckMargins}
- with PrintJob do begin
- if HTMargin >= Tmargin then
- HTMargin := Pred(Tmargin);
- if FBMargin >= Bmargin then
- FBMargin := Pred(Bmargin);
- end;
- end; {EdCheckMargins}
-
- begin {EdInitPrintState}
- with PrintJob do begin
-
- FillChar(FontState, SizeOf(FontState), False); {Default font state}
- FillChar(PendingFontState, SizeOf(PendingFontState), False); {No font change pending}
- EdClearString(Header); {Empty header}
- EdClearString(Footer); {Empty footer}
- StackIndex := 0; {No print command setup in progress}
- BufferPtr := 1; {Use first character of read buffer}
- BufferChars := 0; {Force buffer read first time}
- ShowPageNum := True; {Print page number if empty footer}
- Loffset := 8; {Default left offset}
- Pagecol := 33; {Default column for page numbers}
- PushStart := True; {First header pending}
- PushEnd := True; {First footer pending}
- NewLine := True; {First line pending}
- LastPage := False; {Not on last page yet}
- Column := 1; {First column}
- Line := 1; { of first line}
- PageNum := 1; { of first page}
-
- {Set up vertical margins}
- if not(Format) then begin
- Tmargin := 0;
- Bmargin := 0;
- HTMargin := 0;
- FBMargin := 0;
- end else begin
- if WindowCount = 0 then begin
- PageLen := SavePageLen;
- Tmargin := SaveTopMargin;
- Bmargin := SaveBottomMargin;
- end else begin
- PageLen := Curwin^.PageLen;
- Tmargin := Curwin^.Tmargin;
- Bmargin := Curwin^.Bmargin;
- end;
- HTMargin := 1;
- FBMargin := 3;
- EdCheckMargins;
- end;
-
- {Open the print file}
- Assign(PrintFile, PrintFilename);
- Reset(PrintFile, 1);
- if EdFileerror then
- Exit;
-
- {Open the output file}
- PrintChars := CharsPerPrintBlock;
- if ToFile then
- if EdStringEmpty(OutFilename) then
- ToFile := False
- else begin
- PrintChars := CharsPerFileBlock;
- Assign(OutFile, OutFilename);
- Rewrite(OutFile);
- if EdFileerror then
- Exit;
- end;
-
- {Push printer initialization commands}
- if Format then
- EdPushPrintString(PrintDef.Commands[PrtInit] [False]);
- PrinterInit := (StackIndex > 0);
-
- end;
- end; {EdInitPrintState}
-
- procedure EdEditPrinterString;
- {-Edit the printer command string in the current printer definition}
- var
- C : PrintCommandtype;
- M : Boolean;
- Menu : CustomMenuRec;
- Choice : Integer;
- msg : VarString;
-
- begin {EdEditPrinterString}
-
- {Choose string to edit}
- {Initialize the menu}
- with Menu do begin
- Xmin := 32;
- Ymin := 7;
- MessageNum := 304;
- PromptNum := 373;
- MinChoice := 0;
- MaxChoice := 15;
- InitChoice := 0;
- CmdSet := PrtCmdSet;
- UseLetters := False;
- end;
-
- repeat
-
- {Store the strings for the menu}
- if not(EdBuildPrintMenuMessages(Menu)) then begin
- EdErrormsg(35);
- Exit;
- end;
-
- {Get the menu choice}
- EdGetCustomMenuChoice(Menu, Choice);
-
- if Abortcmd then
- Exit;
-
- {Determine which string to edit}
- M := Odd(Choice);
- C := PrintCommandtype(Choice shr 1);
- if C = PrtInit then
- if M then
- msg := EdGetMessage(249)
- else
- msg := EdGetMessage(248)
- else
- msg := EdGetMessage(Ord(C)+414)+OnOff[not(M)]+Blank;
-
- {Edit the keys, ignoring extended keystrokes}
- UseExtendedSequence := False;
- EdEditKeyWindow(msg, 5, 19, 75, 24, PrintCommandSize, PrintDef.Commands[C] [M]);
- UseExtendedSequence := True;
-
- until Abortcmd;
- Abortcmd := False;
-
- end; {EdEditPrinterString}
-
- function EdPrintSetup : Boolean;
- {-Set up a print job and edit printer definitions, returning true if print is to start}
- const
- Xmin = 10;
- Ymin = 8;
- Xmax = 78;
- MaxItems = 13;
- Left = 20;
- var
- OldItem, WhichItem : Integer;
- Wmenu : WindowRec;
- Quitting : Boolean;
- CmdSet : Charset;
- Ch : Char;
-
- procedure EdWriteEntry(W : WindowRec; WhichItem : Integer; Selected : Boolean);
- {-Write one menu entry}
- var
- S, Ss : VarString;
- X, Y : Integer;
-
- begin {EdWriteEntry}
- with W, PrintJob, PrintDef do begin
-
- {Get the fixed string and pad to a left margin value}
- S := EdPadEntry(EdGetMessage(425+WhichItem), Left);
-
- {Add varying status information}
- case WhichItem of
-
- 3 : {Name of file}
- if not(EdHasWildCards(PrintFilename)) then
- S := S+PrintFilename;
-
- 4 : {Formatting}
- S := S+OnOff[Format];
-
- 5 : {First page}
- begin
- Str(StartPage, Ss);
- S := S+Ss;
- end;
-
- 6 : {Last page}
- begin
- Str(StopPage, Ss);
- S := S+Ss;
- end;
-
- 8 : {Which printer}
- S := S+Devicename;
-
- 9 : {Output destination}
- if ToFile then begin
- if not(EdHasWildCards(OutFilename)) then
- S := S+OutFilename;
- end else
- S := S+'LPT'+Chr(Printer+49);
-
- 10 : {Paper pause}
- S := S+OnOff[PaperPause];
-
- 11 : {Form feed mode}
- S := S+OnOff[FormfeedMode];
-
- end;
-
- {Pad to fill the menu box}
- S := EdPadEntry(S, XSize-2);
-
- X := Succ(XPosn);
- Y := YPosn+WhichItem;
-
- {Write the string with appropriate attributes}
- if Selected then
- EdFastWrite(S, Y, X, ScreenAttr[MsColor])
- else begin
- {Highlight the first character}
- EdFastWrite(S[1], Y, X, ScreenAttr[MnColor]);
- EdFastWrite(S[2], Y, Succ(X), ScreenAttr[MhColor]);
- EdFastWrite(Copy(S, 3, DefNoCols), Y, X+2, ScreenAttr[MnColor]);
- end;
- end;
- end; {EdWriteEntry}
-
- procedure EdDrawAllChoices(W : WindowRec; SelectNum : Integer);
- {-Draw all of the setup choices}
- var
- I : Integer;
-
- begin {EdDrawAllChoices}
- for I := 1 to MaxItems do
- if (I <> 2) and (I <> 7) then
- EdWriteEntry(W, I, (I = SelectNum));
- end; {EdDrawAllChoices}
-
- procedure EdScrollPrintEntry(var WhichItem : Integer; Increment : Integer);
- {-Increment or decrement item in menu, skipping separators}
-
- begin {EdScrollPrintEntry}
- repeat
- Inc(WhichItem, Increment);
- if WhichItem < 1 then
- WhichItem := MaxItems
- else if WhichItem > MaxItems then
- WhichItem := 1;
- until (WhichItem <> 2) and (WhichItem <> 7);
- end; {EdScrollPrintEntry}
-
- procedure EdSetItemByLetter(Ch : Char; var WhichItem : Integer);
- {-See if character matches a menu entry, and set appropriate item if so}
- var
- I : Integer;
-
- begin {EdSetItemByLetter}
- I := 1;
- repeat
- if Upcase(EdFirstLetter(EdGetMessage(425+I))) = Ch then begin
- WhichItem := I;
- Exit;
- end;
- EdScrollPrintEntry(I, 1);
- until I = 1;
- end; {EdSetItemByLetter}
-
- procedure EdModifyPrintSetup(W : WindowRec; WhichItem : Integer);
- {-Modify the print setup parameter}
- var
- Old, Junk : Filepath;
-
- function EdGetPageLimit(Msgno, Default : Integer) : Integer;
- {-Return a validated page number}
- var
- Pnum : Integer;
-
- begin {EdGetPageLimit}
- EdGetPageLimit := Default;
- Pnum := EdGetnumber(EdGetMessage(Msgno), Default);
- if Abortcmd or (Pnum = 0) then
- Abortcmd := False
- else if (Pnum < 1) or (Pnum > MaxPage) then begin
- EdErrormsg(47);
- Goterror := False;
- end else
- EdGetPageLimit := Pnum;
- end; {EdGetPageLimit}
-
- begin {EdModifyPrintSetup}
- with PrintJob, PrintDef do
- case WhichItem of
-
- 3 : {Name of file}
- begin
- Old := PrintFilename;
- PrintFilename := EdGetFileName(EdGetMessage(346), DefExtension, 21, 0, LastPrintFile, True);
- Abortcmd := False;
- if EdStringEmpty(PrintFilename) then
- PrintFilename := Old;
- end;
-
- 4 : {Formatting}
- begin
- Format := not(Format);
- SaveFormatState := Format;
- end;
-
- 5 : {First page}
- StartPage := EdGetPageLimit(392, StartPage);
-
- 6 : {Last page}
- StopPage := EdGetPageLimit(393, StopPage);
-
- 8 : {Printer type}
- begin
- Old := Devicename;
- Junk := SupportPath+'*.'+PrtDefExt;
- Devicename := EdGetFileName(EdGetMessage(334), PrtDefExt, 21, 0, Junk, True);
- Abortcmd := False;
- if EdStringEmpty(Devicename) then begin
- {Return to previous}
- Devicename := Old;
- Exit;
- end;
- if not(EdExistFile(Devicename)) then begin
- EdErrormsg(2);
- Devicename := Old;
- Exit;
- end;
- if Devicename <> Old then begin
- EdReadPrinterFile(Devicename, PrintDef);
- if Goterror then
- Devicename := Old
- else
- {Update toggles controlled by printer}
- EdDrawAllChoices(W, 8);
- end;
- end;
-
- 9 : {Output destination - cycle through the choices}
- begin
- EdGetOutputDest(ToFile, Printer);
- if ToFile then begin
- {Get an output file name}
- OutFilename := EdGetFileName(EdGetMessage(391), '', 21, 0, LastPrintOutput, False);
- Abortcmd := False;
- end;
- end;
-
- 10 : {Manual paper feed}
- PaperPause := not(PaperPause);
-
- 11 : {Form feeds}
- FormfeedMode := not(FormfeedMode);
-
- 12 : {Edit printer codes}
- begin
- EdEditPrinterString;
- Abortcmd := False;
- end;
-
- 13 : {Save printer setup}
- begin
- {Get filename}
- Old := Devicename;
- Devicename := EdGetFileName(EdGetMessage(334), PrtDefExt, 21, 0, Old, False);
- Abortcmd := False;
- if EdStringEmpty(Devicename) then begin
- {Return to previous}
- Devicename := Old;
- Exit;
- end;
- {Check for overwrite}
- if EdExistFile(Devicename) then
- if not(EdYesNo(EdGetMessage(319))) then begin
- {Return to previous}
- Devicename := Old;
- Exit;
- end;
- {Write it out}
- EdWritePrinterFile(Devicename, PrintDef);
- if not(Goterror) then
- {Update toggles controlled by printer}
- EdDrawAllChoices(W, 13);
- Goterror := False;
- end;
-
- end;
- end; {EdModifyPrintSetup}
-
- procedure EdHandleSelection(WhichItem : Integer);
- {-Take action on the selected item}
-
- begin {EdHandleSelection}
- if WhichItem = 1 then begin
- {Validate selections prior to starting print job}
- if EdValidPrintEntries then begin
- {Return true to start printing}
- EdPrintSetup := True;
- Quitting := True;
- end;
- end else
- EdModifyPrintSetup(Wmenu, WhichItem);
-
- Goterror := False;
- EdEraseMenuHelp;
- EdWritePromptLine(EdGetMessage(375));
- end; {EdHandleSelection}
-
- begin {EdPrintSetup}
-
- {Set initial guess at print file name}
- EdSetFileDefault;
-
- {Put up a menu of selections}
- EdSaveTextWindow(Border, EdGetMessage(378), Xmin, Ymin, Xmax, Succ(Ymin+MaxItems), Wmenu);
- {Draw fixed separator bars}
- EdDrawSeparator(Wmenu, 2);
- EdDrawSeparator(Wmenu, 7);
- EdEraseMenuHelp;
- EdWritePromptLine(EdGetMessage(375));
- {Get full screen cursor addressing back}
- WindMin := 0;
- WindMax := swap(pred(PhyScrRows)) or pred(PhyScrCols);
- WhichItem := 1;
- EdDrawAllChoices(Wmenu, WhichItem);
- CmdSet := PrtCmdSet+['A'..'Z'];
-
- {Select until done}
- Quitting := False;
-
- repeat
-
- EdSetCursor(CursorOff);
- EdWriteEntry(Wmenu, WhichItem, True);
- Abortcmd := False;
- Goterror := False;
-
- Ch := EdGetCursorCommand(CmdSet);
-
- if not(Abortcmd) then
- case Ch of
-
- ^J : {Help}
- begin
- EdHelpWindow(CmdPrintFile);
- EdWritePromptLine(EdGetMessage(375));
- end;
-
- ^M : {Select}
- EdHandleSelection(WhichItem);
-
- ^[ : {Escape}
- begin
- EdPrintSetup := False;
- Quitting := True;
- end;
-
- ^E : {Scroll up}
- begin
- EdWriteEntry(Wmenu, WhichItem, False);
- EdScrollPrintEntry(WhichItem, -1);
- end;
-
- ^X : {Scroll down}
- begin
- EdWriteEntry(Wmenu, WhichItem, False);
- EdScrollPrintEntry(WhichItem, 1);
- end;
-
- 'A'..'Z' : {Select by letter}
- begin
- OldItem := WhichItem;
- EdSetItemByLetter(Ch, WhichItem);
- if OldItem <> WhichItem then begin
- EdWriteEntry(Wmenu, OldItem, False);
- EdWriteEntry(Wmenu, WhichItem, True);
- end;
- EdHandleSelection(WhichItem);
- end;
-
- end;
- until Abortcmd or Quitting;
-
- {Restore the screen}
- EdRestoreTextWindow(Wmenu);
- EdShowMenuHelp;
-
- end; {EdPrintSetup}
-
- end.