home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
tptools.zip
/
EDINST.ZIP
/
EDIKEY.INC
< prev
next >
Wrap
Text File
|
1987-12-21
|
32KB
|
957 lines
{ EDIKEY.INC
EDINST 4.0
Copyright (c) 1985, 87 by Borland International, Inc. }
procedure KeyInstall;
{-install keyboard}
const
FirstRow = 4;
LastRow = 25;
PrimeCmdCol = 28;
PrimeMinCol = 31;
PrimeMaxCol = 52;
SecndCmdCol = 54;
SecndMinCol = 57;
SecndMaxCol = 79;
const
MaxDisplay = 89; {Number of editor commands displayed}
EditPrompt : string[70] =
'-backspace C-clear R-restore ┘-accept edit <Scroll Lock> literal';
BrowsePrompt : string[67] =
'--scroll PgUp-PgDn-page ┘-modify R-restore defaults ESC-exit';
OrderMap : array[1..MaxDisplay] of CommandType =
(
CmdLeftChar, {0. Left character}
CmdRightChar, {1. Right character}
CmdLeftWord, {2. Left lexeme}
CmdRightWord, {3. Right lexeme}
CmdUpLine, {4. Up line}
CmdDownLine, {5. Down line}
CmdScrollUp, {6. Scroll up}
CmdScrollDown, {7. Scroll down}
CmdDownPage, {8. Down page}
CmdUpPage, {9. Up page}
CmdNull,
CmdWindowTopFile, {10. Top of window}
CmdWindowBottomFile, {11. Bottom of window}
CmdLeftLine, {12. Cursor to left side}
CmdRightLine, {13. Cursor to right side}
CmdTopScreen, {14. Top of screen}
CmdBottomScreen, {15. Bottom of screen}
CmdCpgotoln, {18. Goto line n}
CmdGotoColumn, {19. Goto column n}
CmdJumpLastPosition, {21. Previous cursor position}
CmdNull,
CmdAbort, {192. Abort current operation}
CmdUndo, {22. Undo last deletion}
CmdRestoreCurrentLine, {23. Restore line as on entry}
CmdTab, {24. Tab, either fixed or "smart"}
CmdInsertCtrlChar, {25. Inserting control character into text}
CmdNewLine, {26. New line in text buffer}
CmdInsertLine, {27. Inserting line}
CmdDeleteRightChar, {28. Delete current character}
CmdDeleteLeftChar, {29. Delete left character}
CmdDeleteRightWord, {30. Delete right lexeme}
CmdDeleteLineRight, {31. Delete line right of cursor}
CmdDeleteLine, {32. Delete line}
CmdNull,
CmdFind, {34. Find pattern}
CmdFindReplace, {35. Find and replace}
CmdFindNext, {37. Find next}
CmdNull,
CmdAbandonFile, {41. Abandon file}
CmdReadBlock, {42. Read file into window}
CmdSaveFile, {43. Save file}
CmdWriteBlock, {44. Write block to file, not appending}
CmdSaveQuit, {45. Save file and exit}
CmdWriteNamedFile, {151. Save current window to another file}
CmdNull,
CmdAddWindow, {46. Add second window with same or different file}
CmdSizeWindow, {47. Resize current window}
CmdWindowDown, {49. Switch windows}
CmdWindowUp, {153. Move to previous window}
CmdNull,
CmdBlockBegin, {52. Begin block}
CmdBlockEnd, {53. End block}
CmdJumpTopOfBlock, {54. Top of block}
CmdJumpBottomBlock, {55. Bottom of block}
CmdBlockCopy, {56. Copy block}
CmdBlockMove, {57. Move block}
CmdBlockDelete, {58. Delete block}
CmdBlockHide, {59. Hide/display toggle block}
CmdBlockWord, {60. Mark current word as block}
CmdNull,
CmdSetMarker0, {62. Set marker}
CmdSetMarker1,
CmdSetMarker2,
CmdSetMarker3,
CmdSetMarker4,
CmdSetMarker5,
CmdSetMarker6,
CmdSetMarker7,
CmdSetMarker8,
CmdSetMarker9,
CmdJumpMarker0, {Jump marker}
CmdJumpMarker1,
CmdJumpMarker2,
CmdJumpMarker3,
CmdJumpMarker4,
CmdJumpMarker5,
CmdJumpMarker6,
CmdJumpMarker7,
CmdJumpMarker8,
CmdJumpMarker9,
CmdToggleTextMarker, {61. Toggle text marker display}
CmdNull, {193. No operation indicated}
CmdLogDrive, {127. Log drive or path}
CmdSysInfo, {104. Show system information}
CmdShowMem, {105. Show available memory}
CmdToggleInsert, {106. Toggle insert mode}
CmdToggleAutoindent, {107. Toggle autoindent mode}
CmdSetUndoLimit, {133. Set default undo limit}
CmdGetDefaultExtension {135. Get a new default file extension}
);
var
Title : VarString;
Quitting : Boolean;
Wrote : Boolean;
CmdLen : Integer;
PackedCommands : PackedCommandList;
MinCmd : CommandType;
Ch : Char;
KeyOfs : LongInt;
CmdsRead : Integer;
procedure InitializeScreen;
{-Set up for full screen key editor}
begin
ClrScr;
GoToXY(1, 1);
Title := CenterPad(' Installing: '+ProgName+' ', '═', 80);
Center(1, TiColor, Title);
end;
function FindKeys(var PackedCommands : PackedCommandList;
var KeyLen : Integer) : LongInt;
{-Read the command definitions into memory}
type
TempRec = record
Len : Integer;
PCList : PackedCommandList;
end;
var
FO : LongInt;
TR : ^TempRec;
begin {FindKeys}
{allocate temporary workspace}
New(TR);
FillChar(TR^.PCList, SizeOf(PackedCommandList), 0);
{search the work area}
FO := FindString(KIDstring, TR^, CmdListBytes+2);
if FO = 0 then
HaltError('Unable to locate keyboard installation area');
{check the number of bytes in the command list}
if TR^.Len > CmdListBytes then
HaltError('Command list is too large. '+ProgName+' may be corrupted.');
{get the command list}
KeyLen := TR^.Len;
PackedCommands := TR^.PCList;
{release memory}
Dispose(TR);
{return the offset of the command list}
FindKeys := FO+2;
end; {FindKeys}
procedure InitializeCommands(var Commands : CommandList);
{-Initialize the titles of each command}
var
C : CommandType;
begin {InitializeCommands}
C := MinCmd;
while C <= CmdNull do begin
with Commands[C] do begin
with Main do begin
Keys := '';
Modified := False;
Conflict := False;
MinCol := PrimeMinCol;
MaxCol := PrimeMaxCol;
end;
with Alt do begin
Keys := '';
Modified := False;
Conflict := False;
MinCol := SecndMinCol;
MaxCol := SecndMaxCol;
end;
case C of
CmdLeftChar : Name := 'Character left';
CmdRightChar : Name := 'Character right';
CmdLeftWord : Name := 'Word left';
CmdRightWord : Name := 'Word right';
CmdUpLine : Name := 'Line up';
CmdDownLine : Name := 'Line down';
CmdScrollUp : Name := 'Scroll up';
CmdScrollDown : Name := 'Scroll down';
CmdDownPage : Name := 'Page down';
CmdUpPage : Name := 'Page up';
CmdWindowTopFile : Name := 'Top of window';
CmdWindowBottomFile : Name := 'Bottom of window';
CmdLeftLine : Name := 'Cursor to left side';
CmdRightLine : Name := 'Cursor to right side';
CmdTopScreen : Name := 'Top of screen';
CmdBottomScreen : Name := 'Bottom of screen';
CmdCpgotoln : Name := 'Go to line';
CmdGotoColumn : Name := 'Go to column';
CmdJumpLastPosition : Name := 'Previous cursor position';
CmdAbort : Name := 'Abort command (1 char)';
CmdUndo : Name := 'Undo last deletion';
CmdRestoreCurrentLine : Name := 'Restore line';
CmdTab : Name := 'Tab';
CmdInsertCtrlChar : Name := 'Insert control char';
CmdNewLine : Name := 'New line';
CmdInsertLine : Name := 'Insert line';
CmdDeleteRightChar : Name := 'Delete current character';
CmdDeleteLeftChar : Name := 'Delete left character';
CmdDeleteRightWord : Name := 'Delete right word';
CmdDeleteLineRight : Name := 'Delete line right';
CmdDeleteLine : Name := 'Delete line';
CmdFind : Name := 'Find pattern';
CmdFindReplace : Name := 'Find and replace';
CmdFindNext : Name := 'Find next';
CmdAbandonFile : Name := 'Abandon file';
CmdReadBlock : Name := 'Read file into window';
CmdSaveFile : Name := 'Save and continue edit';
CmdWriteBlock : Name := 'Write block to file';
CmdSaveQuit : Name := 'Save and exit to DOS';
CmdWriteNamedFile : Name := 'Save to file';
CmdAddWindow : Name := 'Add window';
CmdSizeWindow : Name := 'Resize current window';
CmdWindowDown : Name := 'Next window';
CmdWindowUp : Name := 'Previous window';
CmdBlockBegin : Name := 'Begin block';
CmdBlockEnd : Name := 'End block';
CmdJumpTopOfBlock : Name := 'Top of block';
CmdJumpBottomBlock : Name := 'Bottom of block';
CmdBlockCopy : Name := 'Copy block';
CmdBlockMove : Name := 'Move block';
CmdBlockDelete : Name := 'Delete block';
CmdBlockHide : Name := 'Toggle block display';
CmdBlockWord : Name := 'Mark current word';
CmdSetMarker0 : Name := 'Set marker 0';
CmdSetMarker1 : Name := 'Set marker 1';
CmdSetMarker2 : Name := 'Set marker 2';
CmdSetMarker3 : Name := 'Set marker 3';
CmdSetMarker4 : Name := 'Set marker 4';
CmdSetMarker5 : Name := 'Set marker 5';
CmdSetMarker6 : Name := 'Set marker 6';
CmdSetMarker7 : Name := 'Set marker 7';
CmdSetMarker8 : Name := 'Set marker 8';
CmdSetMarker9 : Name := 'Set marker 9';
CmdJumpMarker0 : Name := 'Jump to marker 0';
CmdJumpMarker1 : Name := 'Jump to marker 1';
CmdJumpMarker2 : Name := 'Jump to marker 2';
CmdJumpMarker3 : Name := 'Jump to marker 3';
CmdJumpMarker4 : Name := 'Jump to marker 4';
CmdJumpMarker5 : Name := 'Jump to marker 5';
CmdJumpMarker6 : Name := 'Jump to marker 6';
CmdJumpMarker7 : Name := 'Jump to marker 7';
CmdJumpMarker8 : Name := 'Jump to marker 8';
CmdJumpMarker9 : Name := 'Jump to marker 9';
CmdToggleTextMarker : Name := 'Toggle marker display';
CmdLogDrive : Name := 'Log drive/path';
CmdSysInfo : Name := 'Show editor version';
CmdShowMem : Name := 'Show available memory';
CmdToggleInsert : Name := 'Toggle insert mode';
CmdToggleAutoindent : Name := 'Toggle autoindent mode';
CmdSetUndoLimit : Name := 'Set undo limit';
CmdGetDefaultExtension : Name := 'Set default extension';
end;
end;
C := Succ(C);
end;
end; {InitializeCommands}
procedure ParsePackedCommands(var PackedCommands : PackedCommandList;
var Commands : CommandList);
{-fill in the structured command array from the packed buffer}
var
P, CmdLen : Integer;
C : CommandType;
function InOrderMap(C : CommandType) : Boolean;
{-Return true if c is found in the displayed commands}
var
I : Integer;
begin {InOrderMap}
InOrderMap := False;
for I := 1 to MaxDisplay do
if C = OrderMap[I] then begin
InOrderMap := True;
Exit;
end;
end; {InOrderMap}
begin {ParsePackedCommands}
P := 0;
CmdLen := Ord(PackedCommands[P]);
while CmdLen <> 0 do begin
C := CommandType(Ord(PackedCommands[Succ(P+CmdLen)]));
if InOrderMap(C) then
with Commands[C] do begin
if Main.Keys = '' then
{load the main command selection}
Move(PackedCommands[P], Main.Keys[0], Succ(CmdLen))
else if Alt.Keys = '' then
{load the alternate command selection}
Move(PackedCommands[P], Alt.Keys[0], Succ(CmdLen))
else begin
{both are full}
ClrEol(1, 1, LoColor);
EdFastWrite('Warning: more than 2 definitions for command '+Name, 1, 1, LoColor);
end;
end;
{move to next command group}
P := P+CmdLen+2;
CmdLen := Ord(PackedCommands[P]);
end;
end; {ParsePackedCommands}
procedure DisplayKeys(TheColor, R : Byte; K : KeyRec);
{-display the stored keystrokes}
var
Txt, Dis : VarString;
Len : Byte;
TxtLen : Byte absolute Txt;
begin {DisplayKeys}
with K do begin
Len := Succ(MaxCol-MinCol);
Txt := TextRepresentation(K);
Dis := Pad(Copy(Txt, 1, Len), Len);
EdFastWrite(Dis, R, MinCol, TheColor);
if TxtLen > Len then
GoToXY(MinCol+Len, R)
else
GoToXY(MinCol+Ord(Txt[0]), R);
end;
end; {DisplayKeys}
procedure DisplayCommand(C : CommandType; R : Byte);
{-display a command and its keys}
begin {DisplayCommand}
if C = CmdNull then
{Draw a separator bar}
Center(R, TiColor, '────────────────────────────────────────────────────────────────────────────────')
else
with Commands[C] do begin
ClrEol(1, R, TiColor);
EdFastWrite(Name, R, 1, TiColor);
EdFastWrite('P:', R, PrimeCmdCol, TiColor);
if Main.Conflict then
DisplayKeys(CfColor, R, Main)
else if Main.Modified then
DisplayKeys(ChColor, R, Main)
else
DisplayKeys(LoColor, R, Main);
EdFastWrite('S:', R, SecndCmdCol, TiColor);
if Alt.Conflict then
DisplayKeys(CfColor, R, Alt)
else if Alt.Modified then
DisplayKeys(ChColor, R, Alt)
else
DisplayKeys(LoColor, R, Alt);
end;
end; {DisplayCommand}
function GetKeys(R : Byte; var K : KeyRec; var StopNow : Boolean) : Boolean;
{-edit a key sequence, default keys as input, keys also return result}
{-return true if keys were modified in the process}
const
ScrollMask = $10;
var
Quitting : Boolean;
Ch : Char;
Buf : KeyString;
ScrollLock, LastScroll : Byte;
KbFlag : Byte absolute $0040 : $0017;
begin {GetKeys}
StopNow := False;
LastScroll := $FF;
with K do begin
Buf := Keys;
Quitting := False;
repeat
DisplayKeys(EdColor, R, K);
repeat
{Watch the scroll state while waiting for a keystroke}
ScrollLock := KbFlag and ScrollMask;
if ScrollLock <> LastScroll then begin
if ScrollLock <> 0 then
EdFastWrite('Literal', 1, 70, LoColor)
else
EdFastWrite('Command', 1, 70, LoColor);
LastScroll := ScrollLock;
end;
until KeyPressed;
Ch := ReadKey;
if ScrollLock <> 0 then begin
{literal mode}
if Ch = #0 then begin
Ch := ReadKey;
if Length(Keys) < Pred(KeyLength) then
Keys := Keys+#0+Ch;
end else if Length(Keys) < KeyLength then
Keys := Keys+Ch;
end else
{command mode}
case Upcase(Ch) of
#0 :
begin
Ch := ReadKey;
if Length(Keys) < Pred(KeyLength) then
Keys := Keys+#0+Ch;
end;
^M :
Quitting := True;
^H : {backspace}
if Length(Keys) > 0 then begin
Delete(Keys, Length(Keys), 1);
if (Length(Keys) > 0) and (Keys[Length(Keys)] = #0) then
Delete(Keys, Length(Keys), 1);
end;
'C' :
Keys := ''; {erase}
'R' :
Keys := Buf; {restore original}
#32..#47,
#58..#126,
#128..#255 : {ignore regular characters} ;
Escape :
begin
StopNow := True;
Quitting := True;
end;
else
if Length(Keys) < KeyLength then
Keys := Keys+Ch;
end;
until Quitting;
GetKeys := (Keys <> Buf);
EdFastWrite('═══════', 1, 70, TiColor);
end;
end; {getkeys}
procedure EditKeys(R : Byte; var K : KeyRec);
{-edit one key record}
var
StopNow : Boolean;
begin {EditKeys}
Center(2, EdColor, EditPrompt);
with K do begin
Modified := GetKeys(R, K, StopNow);
if Modified then begin
DisplayKeys(ChColor, R, K);
Conflict := False;
end else if Conflict then
DisplayKeys(CfColor, R, K)
else
DisplayKeys(LoColor, R, K);
end;
Center(2, TiColor, BrowsePrompt);
end; {Editkeys}
procedure DrawFullPage(CmdStart : Integer);
{-write a full page of commands, starting at cmdstart}
var
R : Byte;
C : Integer;
begin {DrawFullPage}
R := FirstRow;
C := CmdStart;
while (R <= LastRow) and (C <= MaxDisplay) do begin
DisplayCommand(OrderMap[C], R);
R := Succ(R);
C := Succ(C);
end;
end; {DrawFullPage}
procedure EditCommands;
{-Allow browsing and changing of command keys in range minc to maxc}
var
Quitting : Boolean;
OldTopC, TopC, CurC : Integer;
R, Curr : Byte;
CurCmd : CommandType;
K : KeyRec;
OnMain : Boolean;
begin {EditCommands}
Center(2, TiColor, BrowsePrompt);
Center(3, TiColor, '════════════════════════════════════════════════════════════════════════════════');
TopC := 1;
CurC := 1;
Curr := FirstRow;
DrawFullPage(TopC);
OnMain := True;
Quitting := False;
repeat
{Handle display mapping}
CurCmd := OrderMap[CurC];
if OnMain then
K := Commands[CurCmd].Main
else
K := Commands[CurCmd].Alt;
GoToXY(K.MinCol, Curr);
case GetCursorCommand of
^M : {edit key}
if (CurCmd <> CmdNull) then begin
EditKeys(Curr, K);
if OnMain then
Commands[CurCmd].Main := K
else
Commands[CurCmd].Alt := K;
end;
^E, ^W : {scroll up}
if CurC > 1 then begin
CurC := Pred(CurC);
if Curr = FirstRow then begin
TopC := CurC;
InsLine;
DisplayCommand(OrderMap[CurC], FirstRow);
end else
Curr := Pred(Curr);
end;
^X, ^Z : {scroll down}
if CurC < MaxDisplay then begin
CurC := Succ(CurC);
if Curr >= LastRow then begin
GoToXY(1, FirstRow);
DelLine;
DisplayCommand(OrderMap[CurC], LastRow);
TopC := Succ(TopC);
end else
Curr := Succ(Curr);
end;
^S : {move to secondary}
OnMain := True;
^D : {move to primary}
OnMain := False;
^R : {page up}
if CurC > 1 then begin
OldTopC := TopC;
R := FirstRow;
while (CurC > 1) and (R < LastRow) do begin
CurC := Pred(CurC);
Curr := Pred(Curr);
if Curr < FirstRow then begin
TopC := CurC;
Curr := FirstRow;
end;
R := Succ(R);
end;
if TopC <> OldTopC then
DrawFullPage(TopC);
end;
^C : {page down}
if CurC < MaxDisplay then begin
R := FirstRow;
OldTopC := TopC;
while (CurC < MaxDisplay) and (R < LastRow) do begin
Curr := Succ(Curr);
CurC := Succ(CurC);
if Curr > LastRow then begin
TopC := Succ(TopC);
Curr := LastRow;
end;
R := Succ(R);
end;
if TopC <> OldTopC then
DrawFullPage(TopC);
end;
^T : {home}
if CurC > 1 then begin
CurC := 1;
TopC := 1;
Curr := FirstRow;
OnMain := True;
DrawFullPage(TopC);
end;
^B : {end}
if CurC < MaxDisplay then begin
Curr := FirstRow;
CurC := MaxDisplay;
while Curr < LastRow do begin
Curr := Succ(Curr);
CurC := Pred(CurC);
end;
TopC := CurC;
DrawFullPage(TopC);
CurC := MaxDisplay;
OnMain := False;
end;
'R' : {restore all defaults}
begin
Commands := OrigCommands;
DrawFullPage(TopC);
end;
Escape : {done}
Quitting := True;
end;
until Quitting;
end; {EditCommands}
procedure FastInstallCommands;
{-Prompt for commands one by one}
var
C : Integer;
StopNow : Boolean;
Ch : Char;
procedure PromptFor(var keyset : KeyRec);
{-get the new keyrec for main or alt}
var
K : KeyRec;
begin {PromptFor}
K.Keys := '';
K.MinCol := WhereX;
K.MaxCol := WhereX+20;
if GetKeys(WhereY, K, StopNow) then
{new keystring returned}
with keyset do begin
Modified := True;
Conflict := False;
Keys := K.Keys;
DisplayKeys(ChColor, WhereY, K);
end else
{accepted default}
DisplayKeys(LoColor, WhereY, K);
WriteLn;
end; {PromptFor}
begin {FastInstallCommands}
WriteLn;
WriteLn('Press <Enter> to accept default');
WriteLn('Press keys followed by <Enter> for new key sequence');
WriteLn('Press <Bksp> to back up one keystroke, C to Clear, R to Restore');
WriteLn('Press <ScrollLock> to toggle literal mode');
WriteLn('Press <Escape> to quit entering commands');
WriteLn('Random access editing is available when you are finished');
WriteLn;
C := 1;
StopNow := False;
while not(StopNow) and (C <= MaxDisplay) do begin
with Commands[OrderMap[C]] do begin
Write(Pad(Name, 26), '( Primary ): ', Pad(TextRepresentation(Main), 18), ' ');
PromptFor(Main);
if not(StopNow) then begin
Write(Pad(Name, 26), '(Secondary): ', Pad(TextRepresentation(Alt), 18), ' ');
PromptFor(Alt);
end;
end;
repeat
C := Succ(C);
until (C > MaxDisplay) or (OrderMap[C] <> CmdNull);
end;
WriteLn;
Write('Press a key to invoke full screen key editor ');
Ch := ReadKey;
end; {FastInstallCommands}
function CheckCommands(var Commands : CommandList) : Boolean;
{-Return true if no duplicate commands are found, else complain}
var
FCmd, TCmd : CommandType;
Ok : Boolean;
Cnt : Integer;
CntStr : VarString;
function Conflicting(FCmd, TCmd : CommandType) : Boolean;
{-return true, and set appropriate flags if any conflict}
var
FMain, Falt, TMain, TAlt : KeyString;
Ok : Boolean;
begin {Conflicting}
Ok := True;
with Commands[FCmd] do begin
FMain := Main.Keys;
Falt := Alt.Keys;
end;
with Commands[TCmd] do begin
TMain := Main.Keys;
TAlt := Alt.Keys;
end;
if FMain <> '' then begin
if Pos(FMain, TMain) = 1 then begin
Ok := False;
Commands[FCmd].Main.Conflict := True;
Commands[TCmd].Main.Conflict := True;
end;
if Pos(FMain, TAlt) = 1 then begin
Ok := False;
Commands[FCmd].Main.Conflict := True;
Commands[TCmd].Alt.Conflict := True;
end;
end;
if TMain <> '' then begin
if Pos(TMain, FMain) = 1 then begin
Ok := False;
Commands[TCmd].Main.Conflict := True;
Commands[FCmd].Main.Conflict := True;
end;
if Pos(TMain, Falt) = 1 then begin
Ok := False;
Commands[TCmd].Main.Conflict := True;
Commands[FCmd].Alt.Conflict := True;
end;
end;
if TAlt <> '' then begin
if Pos(TAlt, FMain) = 1 then begin
Ok := False;
Commands[TCmd].Alt.Conflict := True;
Commands[FCmd].Main.Conflict := True;
end;
if Pos(TAlt, Falt) = 1 then begin
Ok := False;
Commands[TCmd].Alt.Conflict := True;
Commands[FCmd].Alt.Conflict := True;
end;
end;
if Falt <> '' then begin
if Pos(Falt, TMain) = 1 then begin
Ok := False;
Commands[FCmd].Alt.Conflict := True;
Commands[TCmd].Main.Conflict := True;
end;
if Pos(Falt, TAlt) = 1 then begin
Ok := False;
Commands[FCmd].Alt.Conflict := True;
Commands[TCmd].Alt.Conflict := True;
end;
end;
Conflicting := not(Ok);
end; {Conflicting}
begin {CheckCommands}
{Provide some reassurance}
ClrEol(1, 1, LoColor);
EdFastWrite('Checking for conflicts....', 1, 1, LoColor);
{Reset previous conflicts}
FCmd := MinCmd;
while FCmd <= CmdAbort do begin
with Commands[FCmd] do begin
Main.Conflict := False;
Alt.Conflict := False;
end;
FCmd := Succ(FCmd);
end;
FCmd := MinCmd;
Ok := True;
Cnt := 0;
while FCmd <= CmdAbort do begin
{Keep status going}
Cnt := Succ(Cnt);
Str(Cnt:4, CntStr);
EdFastWrite(CntStr, 1, 28, LoColor);
{Don't waste space on duplicate commands}
with Commands[FCmd] do
if Main.Keys = Alt.Keys then begin
Alt.Keys := '';
Alt.Conflict := False;
Alt.Modified := False;
end;
if Commands[FCmd].Main.Modified or Commands[FCmd].Alt.Modified then begin
{Now compare for conflicts}
TCmd := MinCmd;
while TCmd <= CmdAbort do begin
if (TCmd <> FCmd) then
if Conflicting(FCmd, TCmd) then
Ok := False;
TCmd := Succ(TCmd);
end;
end;
FCmd := Succ(FCmd);
end;
ClrEol(1, 1, LoColor);
CheckCommands := Ok;
end; {CheckCommands}
procedure PackCommands(var Commands : CommandList;
var PackedCommands : PackedCommandList;
var CmdLen : Integer);
{-Rebuild the packed command structure}
var
C : CommandType;
Len : Byte;
begin {PackCommands}
CmdLen := 0;
FillChar(PackedCommands, SizeOf(PackedCommands), 0);
C := MinCmd;
while C <= CmdAbort do begin
with Commands[C] do begin
if Main.Keys <> '' then begin
Len := Ord(Main.Keys[0]);
Move(Main.Keys, PackedCommands[CmdLen], Succ(Len));
PackedCommands[Succ(CmdLen+Len)] := Chr(Ord(C));
CmdLen := CmdLen+Len+2;
end;
if Alt.Keys <> '' then begin
Len := Ord(Alt.Keys[0]);
Move(Alt.Keys, PackedCommands[CmdLen], Succ(Len));
PackedCommands[Succ(CmdLen+Len)] := Chr(Ord(C));
CmdLen := CmdLen+Len+2;
end;
end;
C := Succ(C);
end;
{Pad with zeros}
CmdLen := CmdLen+4;
end; {PackCommands}
begin
ClrScr;
{command with the lowest ordinal}
MinCmd := CmdLeftChar;
InitializeScreen;
GoToXY(1, 3);
KeyOfs := FindKeys(PackedCommands, CmdsRead);
InitializeCommands(Commands);
ParsePackedCommands(PackedCommands, Commands);
OrigCommands := Commands;
if YesNo('Perform fast entry of fully reconfigured keyboard?', 'N') then
{Sequential installation}
FastInstallCommands;
InitializeScreen;
Quitting := False;
repeat
{Random access editing}
EditCommands;
SetColor(LoColor);
ClrEol(1, 1, LoColor);
ClrEol(1, 2, LoColor);
GoToXY(1, 1);
Ch := Getkey('W to install keyboard, Q to quit: ', 'WQ');
Write(Ch);
GoToXY(1, 1);
case Ch of
'W' :
begin
Wrote := True;
if CheckCommands(Commands) then
Quitting := True
else begin
ClrEol(1, 1, EdColor);
EdFastWrite('Command conflicts found and marked. Press a key to correct...', 1, 1, EdColor);
Ch := ReadKey;
Center(1, TiColor, Title);
end;
end;
'Q' :
begin
Wrote := False;
Quitting := True;
end;
end;
until Quitting;
if Wrote then begin
ClrEol(1, 1, LoColor);
EdFastWrite('Updating '+ProgName+'...', 1, 1, LoColor);
PackCommands(Commands, PackedCommands, CmdLen);
if not ModifyDefaults(KeyOfs, PackedCommands, CmdsRead) then
HaltError('Error writing to keyboard installation area');
end;
end; {KeyInstall}