home *** CD-ROM | disk | FTP | other *** search
- { MSMACRO.PAS
- MS 4.0
- Copyright (c) 1985, 87 by Borland International, Inc. }
-
- {$I msdirect.inc}
-
- unit MsMacro;
- {-Perform macro operations}
-
- 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}
-
- procedure EdInsertMacro(MacNum, Ntimes : Integer);
- {-Put macro characters into typeahead buffer}
-
- procedure EdGetMacroNumber(Msgno : Integer; var Macronum : Integer);
- {-Use a menu to choose a macro by name or number}
-
- procedure EdReadMacroFile(Fname : Filepath);
- {-Read an existing macro file}
-
- procedure EdWriteMacroFile(Fname : Filepath);
- {-Write a new macro file}
-
- procedure EdToggleMacroRecord;
- {-Toggle whether keystrokes are being recorded for use in macros}
-
- procedure EdPromptMacroInsert;
- {-Prompt for and insert a macro once}
-
- procedure EdEditKeyWindow(msg : VarString; Xmin, Ymin, Xmax, Ymax, Maxlen : Integer; var Keys : MacroString);
- {-Set up a window, and edit the keystring}
-
- procedure EdEditMacro;
- {-Edit a macro}
-
- {==========================================================================}
-
- implementation
-
-
- procedure EdInsertMacro(MacNum, Ntimes : Integer);
- {-Put macro characters into typeahead buffer}
- var
- Bufsize, MaxTimes : Integer;
- I : Integer;
- St, StNum : VarString;
- Mac : MacroString;
-
- begin {EdInsertMacro}
-
- Mac := Macrokeys[MacNum];
- if Length(Mac) = 0 then
- Exit;
-
- {Cannot playback scrap macro while recording}
- if Recording and (MacNum = 0) then begin
- EdErrormsg(42);
- {Clear scrap macro}
- EdClearString(Macrokeys[0]);
- Exit;
- end;
-
- {Get maximum number of insertions that will fit into typeahead buffer}
- Bufsize := DefTypeahead;
- MaxTimes := Bufsize div Length(Mac);
-
- if Ntimes <= 0 then begin
- {Prompt for number of times if undefined}
- Str(MaxTimes, St);
- EdClearString(StNum);
- EdAskfor(EdGetMessage(314)+St+') ', 10, EdYcenterWindow(3), 47, StNum);
- if Abortcmd then
- Exit;
- EdString2integer(StNum, Ntimes);
- if (Ntimes = 0) then
- Exit;
- end;
-
- {Apply ceiling to number of insertions}
- if Ntimes > MaxTimes then
- Ntimes := MaxTimes;
-
- {Put keystrokes into typeahead buffer}
- for I := 1 to Ntimes do
- EdUserPush(Mac);
-
- end; {EdInsertmacro}
-
- procedure EdGetMacroNumber(Msgno : Integer; var Macronum : Integer);
- {-Use a menu to choose a macro by name or number}
- var
- Menu : CustomMenuRec;
-
- 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
- Str(Item, S);
- if EdPtrIsNil(Macronames[Item]) then
- S := S+EdGetMessage(384)
- else begin
- S := S+Blank+Macronames[Item]^;
- if Length(S) > 50 then
- S := Copy(S, 1, 50);
- 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 {EdGetMacroNumber}
-
- {Initialize the menu}
- with Menu do begin
- Xmin := 26;
- Ymin := 13;
- MessageNum := Msgno;
- PromptNum := 383;
- MinChoice := 0;
- MaxChoice := MaxMacro;
- InitChoice := 0;
- CmdSet := NumCmdSet;
- UseLetters := False;
- end;
- if not(EdBuildMessages(Menu)) then begin
- EdErrormsg(35);
- Exit;
- end;
-
- {Get the menu choice}
- EdGetCustomMenuChoice(Menu, Macronum);
-
- if Abortcmd then
- Macronum := MaxInt;
-
- end; {EdGetMacroNumber}
-
- procedure EdGetMacroName(N : Integer);
- {-Prompt for and store a macro name for macro n}
- var
- St : VarString;
-
- function EdGetNameSpace(Len : Byte) : Boolean;
- {-Determine whether space available for a macro name}
- var
- Space : Boolean;
-
- begin {EdGetNameSpace}
- Space := EdMemAvail(Succ(Len), FreeListPerm);
- if not(Space) then
- EdErrormsg(35);
- EdGetNameSpace := Space;
- end; {EdGetNameSpace}
-
- begin {EdGetMacroName}
- if EdPtrIsNil(Macronames[N]) then
- EdClearString(St)
- else
- St := Macronames[N]^;
- EdAskfor(EdGetMessage(385), 10, 20, 53, St);
- if Abortcmd then
- Exit;
-
- {Store it on the heap}
- if not(EdStringEmpty(St)) then
- if EdPtrIsNil(Macronames[N]) then begin
- {No space allocated yet}
- if EdGetNameSpace(Length(St)) then
- GetMem(Macronames[N], Succ(Length(St)));
- Move(St, Macronames[N]^, Succ(Length(St)));
- end else if Ord(Macronames[N]^[0]) < Length(St) then begin
- {Space too small, get a larger block}
- FreeMem(Macronames[N], Succ(Ord(Macronames[N]^[0])));
- if EdGetNameSpace(Length(St)) then
- GetMem(Macronames[N], Succ(Length(St)));
- Move(St, Macronames[N]^, Succ(Length(St)));
- end else
- {Adequate space, overwrite it}
- Move(St, Macronames[N]^, Succ(Length(St)));
- end; {EdGetMacroName}
-
- procedure EdReadMacroFile(Fname : Filepath);
- {-Read an existing macro file}
- label
- ExitPoint;
- var
- Mnum, BytesRead : Integer;
- Mname : VarString;
- F : file;
-
- function EdGetNameSpace(Len : Byte) : Boolean;
- {-Check that there is space for a macro name}
- var
- Space : Boolean;
-
- begin {EdGetNameSpace}
- Space := EdMemAvail(Succ(Len), FreeListPerm);
- if not(Space) then
- EdErrormsg(35);
- EdGetNameSpace := Space;
- end; {EdGetNameSpace}
-
- begin {EdReadMacroFile}
-
- if Abortcmd or EdStringEmpty(Fname) then
- Exit;
- Assign(F, Fname);
- Reset(F, 1);
- if EdFileerror then
- Exit;
-
- {Check file signature}
- EdBlockRead(F, Mname, Succ(Length(MacroSignature)), BytesRead);
- if EdFileerror or (BytesRead <> Succ(Length(MacroSignature))) then
- goto ExitPoint;
- if Mname <> MacroSignature then begin
- EdErrormsg(50);
- goto ExitPoint;
- end;
-
- for Mnum := 0 to MaxMacro do begin
-
- {Get the macro name}
- EdBlockRead(F, Mname[0], 1, BytesRead);
- if Goterror or (BytesRead <> 1) then
- goto ExitPoint;
-
- if not(EdStringEmpty(Mname)) then begin
- EdBlockRead(F, Mname[1], Length(Mname), BytesRead);
- if Goterror or (BytesRead <> Length(Mname)) then
- goto ExitPoint;
- {Store it on the heap}
- if EdPtrIsNil(Macronames[Mnum]) then begin
- {No space allocated yet}
- if not(EdGetNameSpace(Length(Mname))) then
- goto ExitPoint;
- GetMem(Macronames[Mnum], Succ(Length(Mname)));
- end else if Length(Macronames[Mnum]^) < Length(Mname) then begin
- {Space too small, get a larger block}
- FreeMem(Macronames[Mnum], Succ(Length(Macronames[Mnum]^)));
- if not(EdGetNameSpace(Length(Mname))) then
- goto ExitPoint;
- GetMem(Macronames[Mnum], Succ(Length(Mname)));
- end;
- Move(Mname, Macronames[Mnum]^, Succ(Length(Mname)));
- end else if EdPtrNotNil(Macronames[Mnum]) then
- {Clear the name}
- Macronames[Mnum]^[0] := Null;
-
- {Read the macro characters}
- EdBlockRead(F, Macrokeys[Mnum] [0], 1, BytesRead);
- if Goterror or (BytesRead <> 1) then
- goto ExitPoint;
-
- if not(EdStringEmpty(Macrokeys[Mnum])) then begin
- EdBlockRead(F, Macrokeys[Mnum] [1], Length(Macrokeys[Mnum]), BytesRead);
- if Goterror or (BytesRead <> Length(Macrokeys[Mnum])) then
- goto ExitPoint;
- end;
-
- end;
-
- ExitPoint:
- Close(F);
- if EdFileerror then
- ;
- end; {EdReadMacroFile}
-
- procedure EdWriteMacroFile(Fname : Filepath);
- {-Write a new macro file}
- label
- ExitPoint;
- var
- Mnum : Integer;
- F : file;
- Nothing : string[1];
-
- begin {EdWriteMacroFile}
-
- if Abortcmd or EdStringEmpty(Fname) then
- Exit;
-
- if EdExistFile(Fname) then begin
- {Prompt to overwrite}
- if not(EdYesNo(EdGetMessage(319))) then
- Exit;
- if Abortcmd then
- Exit;
- end;
-
- Assign(F, Fname);
- Rewrite(F, 1);
- if EdFileerror then
- Exit;
-
- {Write file signature}
- EdBlockWrite(F, MacroSignature, Succ(Length(MacroSignature)));
- if Goterror then
- goto ExitPoint;
-
- EdClearString(Nothing);
-
- for Mnum := 0 to MaxMacro do begin
- {Write the name}
- if EdPtrNotNil(Macronames[Mnum]) then begin
- {Write the macro name}
- EdBlockWrite(F, Macronames[Mnum]^, Succ(Length(Macronames[Mnum]^)));
- if Goterror then
- goto ExitPoint;
- end else begin
- {Write an empty string}
- EdBlockWrite(F, Nothing, 1);
- if Goterror then
- goto ExitPoint;
- end;
-
- {Write the macro keys}
- EdBlockWrite(F, Macrokeys[Mnum], Succ(Length(Macrokeys[Mnum])));
- if Goterror then
- goto ExitPoint;
- end;
-
- ExitPoint:
- Close(F);
- if EdFileerror then
- ;
- end; {EdWriteMacroFile}
-
- procedure EdToggleMacroRecord;
- {-Toggle whether keystrokes are being recorded for use in macros}
- var
- N : Integer;
-
- procedure EdRemoveToggleCommand(var M : MacroString);
- {-Remove the keys which stopped the recording}
-
- function EdRemoved(Toggle : CommandString; var M : MacroString) : Boolean;
- {-Return true if command Toggle is found and removed}
- var
- Cpos : Byte;
-
- function EdCmdFound(Lcmd : MacroString; Scmd : CommandString; P : Integer) : Boolean;
- {-Return true if scmd is found at position p in lcmd}
- var
- Tcmd : CommandString;
- Found : Boolean;
- I : Integer;
-
- begin {EdCmdFound}
- if (Length(Scmd) = 0) or (P = 0) then
- Found := False
- else begin
- {Get the substring which must match}
- Tcmd := Copy(Lcmd, P, Length(Scmd));
- Found := True;
- {Scan the command keys checking for match}
- I := 1;
- while Found and (I <= Length(Scmd)) do begin
- if (I > Length(Tcmd)) then
- Found := False
- else if I = 1 then
- {Force exact match on first character}
- Found := (Scmd[I] = Tcmd[I])
- else
- {Use control char equivalents on later characters}
- Found := (EdControlFilter(Scmd[I]) = EdControlFilter(Tcmd[I]));
- Inc(I);
- end;
- end;
- EdCmdFound := Found;
- end; {EdCmdFound}
-
- begin {EdRemoved}
- EdRemoved := False;
- if Length(Toggle) > 0 then begin
- Cpos := Succ(Length(M)-Length(Toggle));
- while (Cpos > 0) and not(EdCmdFound(M, Toggle, Cpos)) do
- Dec(Cpos);
- if Cpos > 0 then begin
- M := Copy(M, 1, Pred(Cpos));
- EdRemoved := True;
- end;
- end;
- end; {EdRemoved}
-
- begin {EdRemoveToggleCommand}
- {Check the four ways macro recording could be turned off}
- if EdRemoved(TogglePrime, M) then
- Exit;
- if EdRemoved(ToggleSecon, M) then
- Exit;
- if EdRemoved(MenuPrime, M) then
- Exit;
- if EdRemoved(MenuSecon, M) then
- Exit;
- EdClearString(M);
- end; {EdRemoveToggleCommand}
-
- begin {EdToggleMacroRecord}
- Recording := not(Recording);
- if Recording then
-
- {Starting a recorded macro - reset scrap string}
- EdClearString(Macrokeys[0])
-
- else begin
-
- {Remove the toggle command from the end of the macro string}
- EdRemoveToggleCommand(Macrokeys[0]);
-
- {Get a macro number}
- EdGetMacroNumber(316, N);
- if Abortcmd or not(N in [0..MaxMacro]) then
- Exit;
-
- {Get the macro name}
- EdGetMacroName(N);
- if Abortcmd then
- Exit;
-
- {Store the macro}
- if N <> 0 then
- Macrokeys[N] := Macrokeys[0];
-
- end;
- end; {EdToggleMacroRecord}
-
- procedure EdPromptMacroInsert;
- {-Prompt for and insert a macro once}
- var
- MacNum : Integer;
-
- begin {EdPromptMacroInsert}
- EdGetMacroNumber(304, MacNum);
- if Abortcmd then
- Exit;
- EdInsertMacro(MacNum, 1);
- ExitMenu := True;
- end; {EdPromptMacroInsert}
-
- procedure EdEditKeyWindow(msg : VarString;
- Xmin, Ymin, Xmax, Ymax, Maxlen : Integer;
- var Keys : MacroString);
- {-Set up a window, and edit the keystring}
- var
- W : WindowRec;
- AsciiLength, ExtendedLength : LengthArray;
- SaveCursorState : Boolean;
-
- procedure EdEditKeys(Xmin, Ymin, Xmax, Ymax, Maxlen : Integer; var Keys : MacroString);
- {-edit a key sequence, default keys as input, keys also return result}
- const
- ScrollMask = $10; {Mask for keyboard status flag, to separate scroll lock bit}
- var
- Ch : Char;
- KbFlag : Byte absolute $0040 : $0017;
- Mptr, ScrollLock, LastScroll : Byte;
- Quitting, Inserting : Boolean;
- CurRow, CurCol : Integer;
- BlankLine : VarString;
- RowPos, Colpos : array[1..255] of Integer;
- KeyBuf : MacroString;
-
- procedure EdClrEol(Col, Row, Attr : Integer);
- {-Clear to end of line}
-
- begin {EdClrEol}
- BlankLine[0] := Chr(Xmax-Col);
- EdFastWrite(BlankLine, Row, Col, Attr);
- end; {EdClrEol}
-
- procedure EdClrEos(Col, Row, Attr : Integer);
- {-Clear to end of window}
- var
- R : Integer;
-
- begin {EdClrEos}
- EdClrEol(Col, Row, Attr);
- for R := Succ(Row) to Ymax do
- EdClrEol(Xmin, R, Attr);
- end; {EdClrEos}
-
- procedure EdUpdateHelpLine;
- {-Show the literal/command state}
- const
- StCom : string[9] = ' Command ';
- StLit : string[9] = ' Literal ';
- var
- S : VarString;
-
- begin {EdUpdateHelpLine}
- if ScrollLock <> 0 then
- S := StLit
- else
- S := StCom;
- EdFastWrite(S, Succ(Ymax), Xmax-12, ScreenAttr[MfColor]);
- end; {EdUpdateHelpLine}
-
- procedure EdDisplayKeys(Row, Col, Mptr : Integer; Keys : MacroString);
- {-Write the macro to the screen}
- var
- Attr : Byte;
- CharStr : VarString;
- Special : Boolean;
-
- begin {EdDisplayKeys}
- if Row > Ymax then
- Exit;
- while Mptr <= Length(Keys) do begin
- {Get the text representation of the next character group}
- CharStr := EdTextRepresentation(Keys, Mptr, Special);
- {Check for wrap}
- if (Col+Length(CharStr) >= Xmax) then begin
- {String starts next row}
- EdClrEol(Col, Row, ScreenAttr[MnColor]);
- Inc(Row);
- if Row > Ymax then
- Exit
- else
- Col := Xmin;
- end;
- if Special then
- Attr := ScreenAttr[MhColor]
- else
- Attr := ScreenAttr[MnColor];
- EdFastWrite(CharStr, Row, Col, Attr);
-
- Col := Col+Length(CharStr);
- end;
-
- EdClrEos(Col, Row, ScreenAttr[MnColor]);
- end; {EdDisplayKeys}
-
- procedure EdComputeScreenPos(Mptr : Byte; Keys : MacroString);
- {-Compute the rowpos and colpos arrays, from mptr to length(keys)}
- var
- CharLen : Byte;
- Row, Col : Integer;
-
- function EdMacLength(Keys : MacroString; var Kptr : Byte) : Byte;
- {-Return display length of next character group}
- var
- Ch : Char;
-
- begin {EdMacLength}
- if Kptr <= Length(Keys) then begin
- Ch := Keys[Kptr];
- if UseExtendedSequence and (Ch = Null) and (Kptr < Length(Keys)) then begin
- Inc(Kptr);
- EdMacLength := ExtendedLength[Ord(Keys[Kptr])];
- end else
- EdMacLength := AsciiLength[Ord(Ch)];
- Inc(Kptr);
- end else
- EdMacLength := 0;
- end; {EdMacLength}
-
- begin {EdComputeScreenPos}
- Row := RowPos[Mptr];
- Col := Colpos[Mptr];
- while Mptr <= Length(Keys) do begin
- {Get the length of the next character group}
- CharLen := EdMacLength(Keys, Mptr);
- {Check for wrap}
- if (Col+CharLen >= Xmax) then begin
- {String starts next row}
- if Row < Ymax then begin
- Inc(Row);
- Col := Xmin+CharLen;
- end;
- end else
- Col := Col+CharLen;
- {Store the positions}
- RowPos[Mptr] := Row;
- Colpos[Mptr] := Col;
- end;
- end; {EdComputeScreenPos}
-
- procedure EdIncKeyPos(var Mptr : Byte);
- {-Move the current position one composite key to the right}
-
- begin {EdIncKeyPos}
- if Mptr <= Length(Keys) then begin
- if UseExtendedSequence and (Keys[Mptr] = Null) then
- Inc(Mptr);
- Inc(Mptr);
- end;
- end; {EdIncKeyPos}
-
- procedure EdDecKeyPos(var Mptr : Byte);
- {-move the current position one composite key to left}
-
- begin {EdDecKeyPos}
- if Mptr > 1 then begin
- Dec(Mptr);
- if UseExtendedSequence and (Keys[Pred(Mptr)] = Null) then
- Dec(Mptr);
- end;
- end; {EdDecKeyPos}
-
- procedure EdInsertKey(CharStr : MacroString; var Mptr : Byte);
- {-Insert a byte sequence into the current macro}
-
- begin {EdInsertKey}
-
- {Special case to handle nulls}
- if not(UseExtendedSequence) and (CharStr[1] = Null) then
- if (Length(CharStr) > 1) and (CharStr[2] = #3) then
- {<Ctrl@> combination pressed, convert to true null}
- CharStr := Null
- else
- {Some other combination pressed, ignore it}
- Exit;
-
- if Length(Keys)+Length(CharStr) < Maxlen then begin
- if not(Inserting) then begin
- if UseExtendedSequence and (Keys[Mptr] = Null) then
- {Delete the leader of an extended character}
- Delete(Keys, Mptr, 1);
- Delete(Keys, Mptr, 1);
- end;
- Insert(CharStr, Keys, Mptr);
- EdDisplayKeys(RowPos[Mptr], Colpos[Mptr], Mptr, Keys);
- EdComputeScreenPos(Mptr, Keys);
- Mptr := Mptr+Length(CharStr);
- end;
- end; {EdInsertKey}
-
- procedure EdDeleteKey(Mptr : Byte);
- {-Delete the keystroke at mptr}
-
- begin {EdDeleteKey}
- if UseExtendedSequence and (Keys[Mptr] = Null) then
- {Delete the leader of an extended character}
- Delete(Keys, Mptr, 1);
- Delete(Keys, Mptr, 1);
- EdComputeScreenPos(Mptr, Keys);
- EdDisplayKeys(RowPos[Mptr], Colpos[Mptr], Mptr, Keys);
- end; {EdDeleteKey}
-
- begin {EdEditKeys}
-
- {Buffer the keys in case change is not to be stored}
- KeyBuf := Keys;
-
- Quitting := False;
- Inserting := True;
- RowPos[1] := Ymin;
- Colpos[1] := Xmin;
- LastScroll := $FF;
- EdEraseMenuHelp;
- EdWritePromptLine(EdGetMessage(405));
- Mptr := 1;
- EdComputeScreenPos(Mptr, Keys);
- FillChar(BlankLine[1], PhyScrCols, Blank);
- EdDisplayKeys(RowPos[Mptr], Colpos[Mptr], Mptr, Keys);
- EdSetInsertMode(Inserting);
-
- repeat
-
- GoToXY(Colpos[Mptr], RowPos[Mptr]);
-
- repeat
- {Watch the scroll state while waiting for a keystroke}
- ScrollLock := KbFlag and ScrollMask;
- if ScrollLock <> LastScroll then begin
- EdUpdateHelpLine;
- LastScroll := ScrollLock;
- end;
- if Printing then
- EdPrintNext(PrintChars);
- until EdKeyPressed;
-
- Ch := EdGetInput;
-
- if (Ch = Null) then begin
-
- {Get extended scan code}
- Ch := EdGetAnyChar;
-
- if ScrollLock <> 0 then
-
- {Literal mode, insert the key}
- EdInsertKey(Null+Ch, Mptr)
-
- else
- case Ch of
-
- #75 : {Left arrow}
- EdDecKeyPos(Mptr);
-
- #77 : {Right arrow}
- EdIncKeyPos(Mptr);
-
- #72 : {Up arrow}
- begin
- CurRow := RowPos[Mptr];
- CurCol := Colpos[Mptr];
- repeat
- EdDecKeyPos(Mptr);
- until (Mptr = 1) or ((RowPos[Mptr] < CurRow) and (Colpos[Mptr] <= CurCol));
- end;
-
- #80 : {Down arrow}
- begin
- CurRow := RowPos[Mptr];
- CurCol := Colpos[Mptr];
- repeat
- EdIncKeyPos(Mptr);
- until (Mptr > Length(Keys)) or ((RowPos[Mptr] > CurRow) and (Colpos[Mptr] >= CurCol));
- end;
-
- #82 : {Ins}
- begin
- Inserting := not(Inserting);
- EdSetInsertMode(Inserting);
- end;
-
- #83 : {Del}
- if Mptr <= Length(Keys) then
- EdDeleteKey(Mptr);
-
- else
- {The key is to be part of the macro}
- EdInsertKey(Null+Ch, Mptr);
- end;
- end else begin
- {Not an extended scan code}
-
- if ScrollLock <> 0 then
- EdInsertKey(Ch, Mptr)
- else
- case Ch of
-
- ^H : {Backspace}
- if Mptr > 1 then begin
- EdDecKeyPos(Mptr);
- EdDeleteKey(Mptr);
- end;
-
- #27 : {Escape}
- begin
- {Restore keys to original}
- Keys := KeyBuf;
- Quitting := True;
- end;
-
- ^M : {Enter}
- Quitting := True;
-
- #127 : {CtrlBkSp}
- begin
- EdClearString(Keys);
- Mptr := 1;
- EdDisplayKeys(RowPos[Mptr], Colpos[Mptr], Mptr, Keys);
- end;
-
- else
- EdInsertKey(Ch, Mptr);
- end;
- end;
-
- until Quitting;
-
- end; {EdEditKeys}
-
- begin {EdEditKeyWindow}
- {Turn off abort checking}
- AbortEnable := False;
-
- {Set up an editing window}
- EdSaveTextWindow(Border, msg, Xmin, Ymin, Xmax, Ymax, W);
-
- {Compute length of character display strings}
- EdSetupKeyLength(AsciiLength, ExtendedLength);
-
- {Turn on hardware cursor and enable full screen addressing}
- WindMin := 0;
- WindMax := swap(pred(PhyScrRows)) or pred(PhyScrCols);
- SaveCursorState := SolidCursor;
- SolidCursor := False;
-
- {Edit the string}
- with W do
- EdEditKeys(XPosn+2, Succ(YPosn), Pred(XPosn+XSize), YPosn+YSize-2, Maxlen, Keys);
-
- {Restore screen}
- EdRestoreTextWindow(W);
- EdZapPromptLine;
- SolidCursor := SaveCursorState;
- EdSetCursorOff;
-
- end; {EdEditKeyWindow}
-
- procedure EdEditMacro;
- {-Edit a macro}
- var
- N : Integer;
- Mname : String255;
-
- begin {EdEditMacro}
-
- {Prompt for which macro to edit}
- EdGetMacroNumber(404, N);
- if Abortcmd or not(N in [0..MaxMacro]) then
- Exit;
-
- {Edit the macro name}
- EdGetMacroName(N);
- if Abortcmd then
- Exit;
- if EdPtrIsNil(Macronames[N]) then
- Mname := EdGetMessage(384)
- else
- Mname := Blank+Macronames[N]^+Blank;
-
- {Edit the keystrokes}
- EdEditKeyWindow(Mname, 5, 15, 75, 25, MaxMacroLength, Macrokeys[N]);
-
- end; {EdEditMacro}
-
- begin
- {Initialize macros to nil}
- FillChar(Macrokeys, SizeOf(Macrokeys), 0);
- FillChar(Macronames, SizeOf(Macronames), 0);
- Macronum := 0;
- end.