home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
tptools.zip
/
MSINST.ZIP
/
MSIKEY.INC
< prev
next >
Wrap
Text File
|
1987-12-21
|
45KB
|
1,187 lines
{ MSIKEY.INC
MSINST 4.0
Copyright (c) 1985, 87 by Borland International, Inc. }
function KeyInstall : Boolean;
{-install keyboard}
const
firstrow = 4;
lastrow = 25;
primecmdcol = 28;
primemincol = 31;
primemaxcol = 52;
secndcmdcol = 54;
secndmincol = 57;
secndmaxcol = 79;
MaxDisplay = 206;
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}
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}
CmdNull, {==============================================}
CmdCpgotoln, {18. Goto line n}
CmdGotoColumn, {19. Goto column n}
CmdGotoPage, {129. Go to specified page}
CmdGotoWindow, {20. Goto window n}
CmdJumpTopOfBlock, {54. Top of block}
CmdJumpBottomBlock, {55. Bottom of block}
CmdJumpMarker0, {Jump marker}
CmdJumpMarker1,
CmdJumpMarker2,
CmdJumpMarker3,
CmdJumpMarker4,
CmdJumpMarker5,
CmdJumpMarker6,
CmdJumpMarker7,
CmdJumpMarker8,
CmdJumpMarker9,
CmdSetMarker0, {62. Set marker}
CmdSetMarker1,
CmdSetMarker2,
CmdSetMarker3,
CmdSetMarker4,
CmdSetMarker5,
CmdSetMarker6,
CmdSetMarker7,
CmdSetMarker8,
CmdSetMarker9,
CmdJumpLastPosition, {21. Previous cursor position}
CmdMoveToBegin, {16. Move to previous BEGIN line}
CmdMoveToEnd, {17. Move to previous END line}
CmdNextSentence, {154. Next sentence}
CmdPrevSentence, {155. Previous sentence}
CmdPromptSetMarker, {143. Prompt for a marker number to set}
CmdPromptJumpMarker, {144. Prompt for a marker to jump to}
CmdNull, {==============================================}
CmdNewLine, {26. New line in text buffer}
CmdInsertLine, {27. Inserting line}
CmdInsertCtrlChar, {25. Inserting control character into text}
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}
CmdDelLineNoRecourse, {33. Delete line, no undo}
CmdNull, {==============================================}
CmdFind, {34. Find pattern}
CmdFindReplace, {35. Find and replace}
CmdFindAndMacro, {36. Search and apply macro at position}
CmdFindNext, {37. Find next}
CmdNull, {==============================================}
CmdNewFile, {40. Edit a new file in current window}
CmdAbandonFile, {41. Abandon file}
CmdReadBlock, {42. Read file into window}
CmdWriteBlock, {44. Write block to file, not appending}
CmdSaveFile, {43. Save file}
CmdDoneFile, {48. Save current file, and get a new one}
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}
CmdCloseTillLast, {142. Close window, on last one, enter menus}
CmdWindowDown, {49. Switch windows}
CmdWindowUp, {153. Move to previous window}
CmdSizeWindow, {47. Resize current window}
CmdZoomWindow, {51. Make the current window fill the screen}
CmdNull, {==============================================}
CmdBlockBegin, {52. Begin block}
CmdBlockEnd, {53. End 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, {==============================================}
CmdToggleMacroRecord, {Toggle macro recording}
CmdInsertScrapPrompted, {Inserting scrap macro n times (prompted)}
CmdInsertScrap1, {Inserting scrap macro 1..9 times}
CmdInsertScrap2,
CmdInsertScrap3,
CmdInsertScrap4,
CmdInsertScrap5,
CmdInsertScrap6,
CmdInsertScrap7,
CmdInsertScrap8,
CmdInsertScrap9,
CmdInsertMacro1, {Inserting Macro 1 once}
CmdInsertMacro2,
CmdInsertMacro3,
CmdInsertMacro4,
CmdInsertMacro5,
CmdInsertMacro6,
CmdInsertMacro7,
CmdInsertMacro8,
CmdInsertMacro9,
CmdPromptInsertMacro, {145. Prompt for a macro to insert}
CmdEditMacro, {150. Edit a macro}
CmdReadMacroFile, {Load a set of macros from disk}
CmdWriteMacroFile, {Write current macros to disk}
CmdNull, {==============================================}
CmdToggleInsert, {106. Toggle insert mode}
CmdToggleAutoindent, {107. Toggle autoindent mode}
CmdToggleWordWrap, {113. Toggle word wrap on or off}
CmdToggleJustify, {117. Toggle right justification}
CmdToggleCompressWrap, {172. Toggle compression prior to wrap}
CmdSetLeftMargin, {114. Set the left margin for word wrap}
CmdSetRightMargin, {111. Set the right margin for word wrap and reformat}
CmdSetTempMargin, {140. Set temporary margin for word wrap}
CmdSetTempAtCursor, {147. Set temporary margin at current column}
CmdMarginRelease, {168. Set margin release}
CmdCenterLine, {120. Center the current line in margins}
CmdToggleCase, {108. Toggle case of character(s)}
CmdLowerCase, {109. Lower case character(s)}
CmdUpperCase, {110. Upper case character or block}
CmdReformParagraph, {112. Reformat the current paragraph}
CmdReformBlock, {141. Reformat marked block}
CmdNull, {==============================================}
CmdToggleTabLine, {115. Toggle tab line display on or off}
CmdToggleTextMarker, {61. Toggle text marker display}
CmdTogglePaginate, {118. Toggle Pagination display}
CmdToggleAttribute, {119. Toggle on-screen attribute display}
CmdToggleKeyHelp, {152. Toggle display of keyboard help in menu system}
CmdNull, {==============================================}
CmdInvokeDOS, {38. Invoke a DOS shell}
CmdLogDrive, {127. Log drive or path}
CmdSysInfo, {104. Show system information}
CmdShowMem, {105. Show available memory}
CmdDirectory, {128. Show directory}
CmdNull, {==============================================}
CmdSetUndoLimit, {133. Set default undo limit}
CmdSetSupportPath, {148. Set the path to all the support files}
CmdGetDefaultExtension, {135. Get a new default file extension}
CmdSetColors, {121. Set editor colors}
CmdToggleRetraceMode, {165. Toggle snow checking}
CmdToggleSolidCursor, {166. Toggle block cursor mode}
CmdToggleEga43Line, {167. Toggle EGA 43 line mode}
CmdToggleTabExpansion, {134. Toggle tab expansion on read-in}
CmdToggleWriteTabs, {171. Toggle tabs written to compress output}
CmdToggleStripMode, {149. Toggle high bit stripping on read-in}
CmdToggleInitZoomState, {173. Toggle default zoom state}
CmdSaveDefaults, {122. Save colors, toggles, etc for new time}
CmdNull, {==============================================}
CmdTab, {24. Tab, either fixed or "smart"}
CmdBackTab, {39. Backwards tab, fixed only}
CmdToggleTabMode, {146. Toggle between fixed and "smart" tabs}
CmdEditTabLine, {139. Interactively edit the tabs}
CmdSetTabLine, {136. Set the tabs}
CmdSaveTabLine, {138. Write current tab line into text}
CmdSetTabSize, {137. Set default tab size}
CmdRestoreDefaultTabs, {156. Restore to default (even) tabs}
CmdNull, {==============================================}
CmdPrintFile, {123. Print a file}
CmdSetTopMargin, {130. Set default top margin}
CmdSetBotMargin, {131. Set default bottom margin}
CmdSetPageLength, {132. Set default page length}
CmdNull, {==============================================}
CmdChooseBold, {158. Insert Bold toggle}
CmdChooseDbl, {159. Insert Doublestrike toggle}
CmdChooseUnd, {160. Insert Underscore toggle}
CmdChooseSup, {161. Insert Superscript toggle}
CmdChooseSub, {162. Insert Subscript toggle}
CmdChooseAlt1, {163. Insert Alt1 font toggle}
CmdChooseAlt2, {164. Insert Alt2 font toggle}
CmdWhatFont, {157. What font is cursor on}
CmdNull, {==============================================}
CmdHelpMenu, {174. Help summary menu}
CmdHelpSummary, {50. Put up a help summary}
CmdHelpHelp, {175.}
CmdCursorHelp, {176.}
CmdQuickHelp, {177.}
CmdDeleteHelp, {178.}
CmdFindHelp, {179.}
CmdFileHelp, {180.}
CmdWindowHelp, {181.}
CmdBlockHelp, {182.}
CmdTextHelp, {183.}
CmdTabHelp, {184.}
CmdUtilityHelp, {185.}
CmdSettingHelp, {186.}
CmdSpellingHelp, {187.}
CmdMacroHelp, {188.}
CmdFormatHelp, {189.}
CmdFunctionKeyHelp, {190.}
CmdNull, {==============================================}
CmdMenu, {191. Activate the menu system}
CmdAbort, {192. Abort current operation}
CmdUndo, {22. Undo last deletion}
CmdRestoreCurrentLine, {23. Restore line as on entry}
CmdInsertUndoBuffer, {116. Insert undo buffer at cursor}
CmdFlushUndo, {124. Flush undo buffer}
CmdSpellCheck {169. Check spelling}
);
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';
CmdMoveToBegin : name := 'Up to equal indent';
CmdMoveToEnd : name := 'Down to equal indent';
CmdCpgotoln : name := 'Go to line';
CmdJumpLastPosition : name := 'Previous cursor position';
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';
CmdFindAndMacro : name := 'Search and apply macro';
CmdFindNext : name := 'Find next';
CmdToggleCase : name := 'Toggle case';
CmdLowerCase : name := 'Lower case';
CmdUpperCase : name := 'Upper case';
CmdInvokeDOS : name := 'Invoke DOS shell';
CmdShowMem : name := 'Show available memory';
CmdToggleInsert : name := 'Toggle insert mode';
CmdToggleAutoindent : name := 'Toggle autoindent mode';
CmdToggleMacroRecord : name := 'Toggle macro record';
CmdAddWindow : name := 'Add window';
CmdSizeWindow : name := 'Resize current window';
CmdDoneFile : name := 'Save/switch files';
CmdWindowDown : name := 'Next window';
CmdHelpSummary : name := 'Show help summary';
CmdBackTab : name := 'Backward tab';
CmdNewFile : name := 'Edit another file';
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';
CmdReadMacroFile : name := 'Load macros from disk';
CmdWriteMacroFile : name := 'Write macros to disk';
CmdJumpTopOfBlock : name := 'Top of block';
CmdJumpBottomBlock : name := 'Bottom of block';
CmdBlockBegin : name := 'Begin block';
CmdBlockCopy : name := 'Copy block';
CmdBlockHide : name := 'Toggle block display';
CmdBlockEnd : name := 'End block';
CmdBlockWord : name := 'Mark current word';
CmdBlockMove : name := 'Move block';
CmdBlockDelete : name := 'Delete block';
CmdToggleTextMarker : name := 'Toggle marker display';
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 marker 0';
CmdJumpMarker1 : name := 'Jump marker 1';
CmdJumpMarker2 : name := 'Jump marker 2';
CmdJumpMarker3 : name := 'Jump marker 3';
CmdJumpMarker4 : name := 'Jump marker 4';
CmdJumpMarker5 : name := 'Jump marker 5';
CmdJumpMarker6 : name := 'Jump marker 6';
CmdJumpMarker7 : name := 'Jump marker 7';
CmdJumpMarker8 : name := 'Jump marker 8';
CmdJumpMarker9 : name := 'Jump marker 9';
CmdInsertMacro1 : name := 'Playback macro 1';
CmdInsertMacro2 : name := 'Playback macro 2';
CmdInsertMacro3 : name := 'Playback macro 3';
CmdInsertMacro4 : name := 'Playback macro 4';
CmdInsertMacro5 : name := 'Playback macro 5';
CmdInsertMacro6 : name := 'Playback macro 6';
CmdInsertMacro7 : name := 'Playback macro 7';
CmdInsertMacro8 : name := 'Playback macro 8';
CmdInsertMacro9 : name := 'Playback macro 9';
CmdInsertScrapPrompted : name := 'Playback scrap';
CmdInsertScrap1 : name := 'Playback scrap 1 time';
CmdInsertScrap2 : name := 'Playback scrap 2 times';
CmdInsertScrap3 : name := 'Playback scrap 3 times';
CmdInsertScrap4 : name := 'Playback scrap 4 times';
CmdInsertScrap5 : name := 'Playback scrap 5 times';
CmdInsertScrap6 : name := 'Playback scrap 6 times';
CmdInsertScrap7 : name := 'Playback scrap 7 times';
CmdInsertScrap8 : name := 'Playback scrap 8 times';
CmdInsertScrap9 : name := 'Playback scrap 9 times';
CmdSetLeftMargin : name := 'Set left margin';
CmdSetRightMargin : name := 'Set right margin';
CmdReformParagraph : name := 'Reformat paragraph';
CmdToggleWordWrap : name := 'Toggle word wrap';
CmdGotoColumn : name := 'Go to column';
CmdGotoWindow : name := 'Go to window';
CmdSysInfo : name := 'Show system info';
CmdDelLineNoRecourse : name := 'Delete Line (no undo)';
CmdZoomWindow : name := 'Zoom current window';
CmdToggleTabLine : name := 'Toggle tab line';
CmdInsertUndoBuffer : name := 'Insert undo buffer';
CmdToggleJustify : name := 'Toggle right justify';
CmdPrintFile : name := 'Print file';
CmdFlushUndo : name := 'Flush undo buffer';
CmdUnused4 : name := 'For expansion';
CmdUnused5 : name := 'For expansion';
CmdLogDrive : name := 'Log drive/path';
CmdDirectory : name := 'File directory';
CmdTogglePaginate : name := 'Toggle pagination';
CmdToggleAttribute : name := 'Toggle attributes';
CmdCenterLine : name := 'Center line';
CmdSetColors : name := 'Set colors';
CmdSaveDefaults : name := 'Save defaults';
CmdGotoPage : name := 'Go to page';
CmdSetTopMargin : name := 'Set top margin';
CmdSetBotMargin : name := 'Set bottom margin';
CmdSetPageLength : name := 'Set page length';
CmdSetUndoLimit : name := 'Set undo limit';
CmdToggleTabExpansion : name := 'Toggle tab expansion';
CmdGetDefaultExtension : name := 'Set default extension';
CmdSaveTabLine : name := 'Save tab line';
CmdEditTabLine : name := 'Edit tab line';
CmdSetTempMargin : name := 'Set temp margin';
CmdSetTabLine : name := 'Set tab line';
CmdSetTabSize : name := 'Set tab size';
CmdPromptSetMarker : name := 'Set a marker via menu';
CmdPromptJumpMarker : name := 'Jump to marker by menu';
CmdPromptInsertMacro : name := 'Playback macro by menu';
CmdToggleTabMode : name := 'Toggle fixed tabs';
CmdSetTempAtCursor : name := 'Temp margin to cursor';
CmdReformBlock : name := 'Reformat block';
CmdCloseTillLast : name := 'Close window';
CmdSetSupportPath : name := 'Set support path';
CmdToggleStripMode : name := 'Toggle hi-bit strip';
CmdEditMacro : name := 'Edit macro';
CmdWriteNamedFile : name := 'Write to named file';
CmdToggleKeyHelp : name := 'Toggle key help';
CmdWindowUp : name := 'Previous window';
CmdNextSentence : name := 'Next sentence';
CmdPrevSentence : name := 'Previous sentence';
CmdRestoreDefaultTabs : name := 'Default tabs';
CmdWhatFont : name := 'Show font';
CmdChooseBold : name := 'Select bold';
CmdChooseDbl : name := 'Select double';
CmdChooseUnd : name := 'Select underscore';
CmdChooseSup : name := 'Select superscript';
CmdChooseSub : name := 'Select subscript';
CmdChooseAlt1 : name := 'Select compressed';
CmdChooseAlt2 : name := 'Select italic';
CmdToggleRetraceMode : name := 'Toggle snow check';
CmdToggleSolidCursor : name := 'Toggle block cursor';
CmdToggleEga43Line : name := 'Toggle 43 line mode';
CmdMarginRelease : name := 'Margin release';
CmdSpellCheck : name := 'Check spelling';
CmdToggleWriteTabs : name := 'Toggle tab writing';
CmdToggleCompressWrap : name := 'Toggle compress at wrap';
CmdToggleInitZoomState : name := 'Toggle initial zoom';
CmdHelpMenu : name := 'Help menu';
CmdCursorHelp : name := 'Cursor help';
CmdQuickHelp : name := 'Quick movement help';
CmdDeleteHelp : name := 'Delete help';
CmdFindHelp : name := 'Find/Replace help';
CmdFileHelp : name := 'File help';
CmdWindowHelp : name := 'Window help';
CmdHelpHelp : name := 'Status help';
CmdBlockHelp : name := 'Block help';
CmdTextHelp : name := 'Text help';
CmdTabHelp : name := 'Tab help';
CmdUtilityHelp : name := 'Utility help';
CmdSettingHelp : name := 'Setting help';
CmdSpellingHelp : name := 'Spelling help';
CmdMacroHelp : name := 'Macro help';
CmdFormatHelp : name := 'Print Format help';
CmdFunctionKeyHelp : name := 'Function keys';
CmdMenu : name := 'Activate menus';
CmdAbort : name := 'Abort command (1 char)';
CmdNull : name := 'No action';
CmdNullMain : name := 'No action (main)';
end;
end;
c := Succ(c);
end;
end; {InitializeCommands}
procedure ParsePackedCommands(PackedCommands : PackedCommandList;
var Commands : commandlist);
{-fill in the structured command array from the packed buffer}
var
p, CmdLen : Integer;
c : CommandType;
begin {ParsePackedCommands}
p := 0;
CmdLen := Ord(PackedCommands[p]);
while CmdLen <> 0 do begin
c := CommandType(Ord(PackedCommands[Succ(p+CmdLen)]));
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 set}
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
curcmd : CommandType;
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(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 update MS.EXE and MS.HLP files, Q to quit without writing: ', '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;
KeyInstall := Wrote;
end; {KeyInstall}