home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / tptools.zip / MSINST.ZIP / MSIKEY.INC < prev    next >
Text File  |  1987-12-21  |  45KB  |  1,187 lines

  1. {                          MSIKEY.INC
  2.                            MSINST 4.0
  3.              Copyright (c) 1985, 87 by Borland International, Inc.            }
  4.  
  5.   function KeyInstall : Boolean;
  6.     {-install keyboard}
  7.   const
  8.     firstrow = 4;
  9.     lastrow = 25;
  10.     primecmdcol = 28;
  11.     primemincol = 31;
  12.     primemaxcol = 52;
  13.     secndcmdcol = 54;
  14.     secndmincol = 57;
  15.     secndmaxcol = 79;
  16.     MaxDisplay = 206;
  17.  
  18.     EditPrompt : string[70] =
  19.     '-backspace  C-clear  R-restore  ┘-accept edit  <Scroll Lock> literal';
  20.  
  21.     BrowsePrompt : string[67] =
  22.     '--scroll  PgUp-PgDn-page  ┘-modify  R-restore defaults  ESC-exit';
  23.  
  24.     ordermap : array[1..MaxDisplay] of CommandType =
  25.     (
  26.  
  27.      CmdLeftChar,            {0. Left character}
  28.      CmdRightChar,           {1. Right character}
  29.      CmdLeftWord,            {2. Left lexeme}
  30.      CmdRightWord,           {3. Right lexeme}
  31.      CmdUpLine,              {4. Up line}
  32.      CmdDownLine,            {5. Down line}
  33.      CmdScrollUp,            {6. Scroll up}
  34.      CmdScrollDown,          {7. Scroll down}
  35.      CmdDownPage,            {8. Down page}
  36.      CmdUpPage,              {9. Up page}
  37.      CmdWindowTopFile,       {10. Top of window}
  38.      CmdWindowBottomFile,    {11. Bottom of window}
  39.      CmdLeftLine,            {12. Cursor to left side}
  40.      CmdRightLine,           {13. Cursor to right side}
  41.      CmdTopScreen,           {14. Top of screen}
  42.      CmdBottomScreen,        {15. Bottom of screen}
  43.  
  44.      CmdNull,                {==============================================}
  45.  
  46.      CmdCpgotoln,            {18. Goto line n}
  47.      CmdGotoColumn,          {19. Goto column n}
  48.      CmdGotoPage,            {129. Go to specified page}
  49.      CmdGotoWindow,          {20. Goto window n}
  50.      CmdJumpTopOfBlock,      {54. Top of block}
  51.      CmdJumpBottomBlock,     {55. Bottom of block}
  52.      CmdJumpMarker0,         {Jump marker}
  53.      CmdJumpMarker1,
  54.      CmdJumpMarker2,
  55.      CmdJumpMarker3,
  56.      CmdJumpMarker4,
  57.      CmdJumpMarker5,
  58.      CmdJumpMarker6,
  59.      CmdJumpMarker7,
  60.      CmdJumpMarker8,
  61.      CmdJumpMarker9,
  62.      CmdSetMarker0,          {62. Set marker}
  63.      CmdSetMarker1,
  64.      CmdSetMarker2,
  65.      CmdSetMarker3,
  66.      CmdSetMarker4,
  67.      CmdSetMarker5,
  68.      CmdSetMarker6,
  69.      CmdSetMarker7,
  70.      CmdSetMarker8,
  71.      CmdSetMarker9,
  72.      CmdJumpLastPosition,    {21. Previous cursor position}
  73.      CmdMoveToBegin,         {16. Move to previous BEGIN line}
  74.      CmdMoveToEnd,           {17. Move to previous END line}
  75.      CmdNextSentence,        {154. Next sentence}
  76.      CmdPrevSentence,        {155. Previous sentence}
  77.      CmdPromptSetMarker,     {143. Prompt for a marker number to set}
  78.      CmdPromptJumpMarker,    {144. Prompt for a marker to jump to}
  79.  
  80.      CmdNull,                {==============================================}
  81.  
  82.      CmdNewLine,             {26. New line in text buffer}
  83.      CmdInsertLine,          {27. Inserting line}
  84.      CmdInsertCtrlChar,      {25. Inserting control character into text}
  85.      CmdDeleteRightChar,     {28. Delete current character}
  86.      CmdDeleteLeftChar,      {29. Delete left character}
  87.      CmdDeleteRightWord,     {30. Delete right lexeme}
  88.      CmdDeleteLineRight,     {31. Delete line right of cursor}
  89.      CmdDeleteLine,          {32. Delete line}
  90.      CmdDelLineNoRecourse,   {33. Delete line, no undo}
  91.  
  92.      CmdNull,                {==============================================}
  93.  
  94.      CmdFind,                {34. Find pattern}
  95.      CmdFindReplace,         {35. Find and replace}
  96.      CmdFindAndMacro,        {36. Search and apply macro at position}
  97.      CmdFindNext,            {37. Find next}
  98.  
  99.      CmdNull,                {==============================================}
  100.  
  101.      CmdNewFile,             {40. Edit a new file in current window}
  102.      CmdAbandonFile,         {41. Abandon file}
  103.      CmdReadBlock,           {42. Read file into window}
  104.      CmdWriteBlock,          {44. Write block to file, not appending}
  105.      CmdSaveFile,            {43. Save file}
  106.      CmdDoneFile,            {48. Save current file, and get a new one}
  107.      CmdSaveQuit,            {45. Save file and exit}
  108.      CmdWriteNamedFile,      {151. Save current window to another file}
  109.  
  110.      CmdNull,                {==============================================}
  111.  
  112.      CmdAddWindow,           {46. Add second window with same or different file}
  113.      CmdCloseTillLast,       {142. Close window, on last one, enter menus}
  114.      CmdWindowDown,          {49. Switch windows}
  115.      CmdWindowUp,            {153. Move to previous window}
  116.      CmdSizeWindow,          {47. Resize current window}
  117.      CmdZoomWindow,          {51. Make the current window fill the screen}
  118.  
  119.      CmdNull,                {==============================================}
  120.  
  121.      CmdBlockBegin,          {52. Begin block}
  122.      CmdBlockEnd,            {53. End block}
  123.      CmdBlockCopy,           {56. Copy block}
  124.      CmdBlockMove,           {57. Move block}
  125.      CmdBlockDelete,         {58. Delete block}
  126.      CmdBlockHide,           {59. Hide/display toggle block}
  127.      CmdBlockWord,           {60. Mark current word as block}
  128.  
  129.      CmdNull,                {==============================================}
  130.  
  131.      CmdToggleMacroRecord,   {Toggle macro recording}
  132.      CmdInsertScrapPrompted, {Inserting scrap macro n times (prompted)}
  133.      CmdInsertScrap1,        {Inserting scrap macro 1..9 times}
  134.      CmdInsertScrap2,
  135.      CmdInsertScrap3,
  136.      CmdInsertScrap4,
  137.      CmdInsertScrap5,
  138.      CmdInsertScrap6,
  139.      CmdInsertScrap7,
  140.      CmdInsertScrap8,
  141.      CmdInsertScrap9,
  142.      CmdInsertMacro1,        {Inserting Macro 1 once}
  143.      CmdInsertMacro2,
  144.      CmdInsertMacro3,
  145.      CmdInsertMacro4,
  146.      CmdInsertMacro5,
  147.      CmdInsertMacro6,
  148.      CmdInsertMacro7,
  149.      CmdInsertMacro8,
  150.      CmdInsertMacro9,
  151.      CmdPromptInsertMacro,   {145. Prompt for a macro to insert}
  152.      CmdEditMacro,           {150. Edit a macro}
  153.      CmdReadMacroFile,       {Load a set of macros from disk}
  154.      CmdWriteMacroFile,      {Write current macros to disk}
  155.  
  156.      CmdNull,                {==============================================}
  157.  
  158.      CmdToggleInsert,        {106. Toggle insert mode}
  159.      CmdToggleAutoindent,    {107. Toggle autoindent mode}
  160.      CmdToggleWordWrap,      {113. Toggle word wrap on or off}
  161.      CmdToggleJustify,       {117. Toggle right justification}
  162.      CmdToggleCompressWrap,  {172. Toggle compression prior to wrap}
  163.      CmdSetLeftMargin,       {114. Set the left margin for word wrap}
  164.      CmdSetRightMargin,      {111. Set the right margin for word wrap and reformat}
  165.      CmdSetTempMargin,       {140. Set temporary margin for word wrap}
  166.      CmdSetTempAtCursor,     {147. Set temporary margin at current column}
  167.      CmdMarginRelease,       {168. Set margin release}
  168.      CmdCenterLine,          {120. Center the current line in margins}
  169.      CmdToggleCase,          {108. Toggle case of character(s)}
  170.      CmdLowerCase,           {109. Lower case character(s)}
  171.      CmdUpperCase,           {110. Upper case character or block}
  172.      CmdReformParagraph,     {112. Reformat the current paragraph}
  173.      CmdReformBlock,         {141. Reformat marked block}
  174.  
  175.      CmdNull,                {==============================================}
  176.  
  177.      CmdToggleTabLine,       {115. Toggle tab line display on or off}
  178.      CmdToggleTextMarker,    {61. Toggle text marker display}
  179.      CmdTogglePaginate,      {118. Toggle Pagination display}
  180.      CmdToggleAttribute,     {119. Toggle on-screen attribute display}
  181.      CmdToggleKeyHelp,       {152. Toggle display of keyboard help in menu system}
  182.  
  183.      CmdNull,                {==============================================}
  184.  
  185.      CmdInvokeDOS,           {38. Invoke a DOS shell}
  186.      CmdLogDrive,            {127. Log drive or path}
  187.      CmdSysInfo,             {104. Show system information}
  188.      CmdShowMem,             {105. Show available memory}
  189.      CmdDirectory,           {128. Show directory}
  190.  
  191.      CmdNull,                {==============================================}
  192.  
  193.      CmdSetUndoLimit,        {133. Set default undo limit}
  194.      CmdSetSupportPath,      {148. Set the path to all the support files}
  195.      CmdGetDefaultExtension, {135. Get a new default file extension}
  196.      CmdSetColors,           {121. Set editor colors}
  197.      CmdToggleRetraceMode,   {165. Toggle snow checking}
  198.      CmdToggleSolidCursor,   {166. Toggle block cursor mode}
  199.      CmdToggleEga43Line,     {167. Toggle EGA 43 line mode}
  200.      CmdToggleTabExpansion,  {134. Toggle tab expansion on read-in}
  201.      CmdToggleWriteTabs,     {171. Toggle tabs written to compress output}
  202.      CmdToggleStripMode,     {149. Toggle high bit stripping on read-in}
  203.      CmdToggleInitZoomState, {173. Toggle default zoom state}
  204.      CmdSaveDefaults,        {122. Save colors, toggles, etc for new time}
  205.  
  206.      CmdNull,                {==============================================}
  207.  
  208.      CmdTab,                 {24. Tab, either fixed or "smart"}
  209.      CmdBackTab,             {39. Backwards tab, fixed only}
  210.      CmdToggleTabMode,       {146. Toggle between fixed and "smart" tabs}
  211.      CmdEditTabLine,         {139. Interactively edit the tabs}
  212.      CmdSetTabLine,          {136. Set the tabs}
  213.      CmdSaveTabLine,         {138. Write current tab line into text}
  214.      CmdSetTabSize,          {137. Set default tab size}
  215.      CmdRestoreDefaultTabs,  {156. Restore to default (even) tabs}
  216.  
  217.      CmdNull,                {==============================================}
  218.  
  219.      CmdPrintFile,           {123. Print a file}
  220.      CmdSetTopMargin,        {130. Set default top margin}
  221.      CmdSetBotMargin,        {131. Set default bottom margin}
  222.      CmdSetPageLength,       {132. Set default page length}
  223.  
  224.      CmdNull,                {==============================================}
  225.  
  226.      CmdChooseBold,          {158. Insert Bold toggle}
  227.      CmdChooseDbl,           {159. Insert Doublestrike toggle}
  228.      CmdChooseUnd,           {160. Insert Underscore toggle}
  229.      CmdChooseSup,           {161. Insert Superscript toggle}
  230.      CmdChooseSub,           {162. Insert Subscript toggle}
  231.      CmdChooseAlt1,          {163. Insert Alt1 font toggle}
  232.      CmdChooseAlt2,          {164. Insert Alt2 font toggle}
  233.      CmdWhatFont,            {157. What font is cursor on}
  234.  
  235.      CmdNull,                {==============================================}
  236.  
  237.      CmdHelpMenu,            {174. Help summary menu}
  238.      CmdHelpSummary,         {50. Put up a help summary}
  239.      CmdHelpHelp,            {175.}
  240.      CmdCursorHelp,          {176.}
  241.      CmdQuickHelp,           {177.}
  242.      CmdDeleteHelp,          {178.}
  243.      CmdFindHelp,            {179.}
  244.      CmdFileHelp,            {180.}
  245.      CmdWindowHelp,          {181.}
  246.      CmdBlockHelp,           {182.}
  247.      CmdTextHelp,            {183.}
  248.      CmdTabHelp,             {184.}
  249.      CmdUtilityHelp,         {185.}
  250.      CmdSettingHelp,         {186.}
  251.      CmdSpellingHelp,        {187.}
  252.      CmdMacroHelp,           {188.}
  253.      CmdFormatHelp,          {189.}
  254.      CmdFunctionKeyHelp,     {190.}
  255.  
  256.      CmdNull,                {==============================================}
  257.  
  258.      CmdMenu,                {191. Activate the menu system}
  259.      CmdAbort,               {192. Abort current operation}
  260.      CmdUndo,                {22. Undo last deletion}
  261.      CmdRestoreCurrentLine,  {23. Restore line as on entry}
  262.      CmdInsertUndoBuffer,    {116. Insert undo buffer at cursor}
  263.      CmdFlushUndo,           {124. Flush undo buffer}
  264.      CmdSpellCheck           {169. Check spelling}
  265.      );
  266.  
  267.   var
  268.     Title : VarString;
  269.     Quitting : Boolean;
  270.     Wrote : Boolean;
  271.     CmdLen : Integer;
  272.     PackedCommands : PackedCommandList;
  273.     MinCmd : CommandType;
  274.     CH : Char;
  275.     KeyOfs : LongInt;
  276.     CmdsRead : Integer;
  277.  
  278.     procedure InitializeScreen;
  279.       {-Set up for full screen key editor}
  280.  
  281.     begin
  282.       ClrScr;
  283.       GoToXY(1, 1);
  284.       Title := CenterPad(' Installing: '+ProgName+' ', '═', 80);
  285.       Center(1, TiColor, Title);
  286.     end;
  287.  
  288.     function FindKeys(var PackedCommands : PackedCommandList;
  289.                       var KeyLen : Integer) : LongInt;
  290.       {-Read the command definitions into memory}
  291.     type
  292.       TempRec = record
  293.                   Len : Integer;
  294.                   PCList : PackedCommandList;
  295.                 end;
  296.     var
  297.       FO : LongInt;
  298.       TR : ^TempRec;
  299.     begin                    {FindKeys}
  300.       {allocate temporary workspace}
  301.       New(TR);
  302.       FillChar(TR^.PCList, SizeOf(PackedCommandList), 0);
  303.  
  304.       {search the work area}
  305.       FO := FindString(KIDstring, TR^, CmdListBytes+2);
  306.       if FO = 0 then
  307.         HaltError('Unable to locate keyboard installation area');
  308.  
  309.       {check the number of bytes in the command list}
  310.       if TR^.Len > CmdListBytes then
  311.         HaltError('Command list is too large. '+ProgName+' may be corrupted.');
  312.  
  313.       {get the command list}
  314.       KeyLen := TR^.Len;
  315.       PackedCommands := TR^.PCList;
  316.  
  317.       {release memory}
  318.       Dispose(TR);
  319.  
  320.       {return the offset of the command list}
  321.       FindKeys := FO+2;
  322.     end;                     {FindKeys}
  323.  
  324.     procedure InitializeCommands(var Commands : commandlist);
  325.       {-Initialize the titles of each command}
  326.     var
  327.       c : CommandType;
  328.  
  329.     begin                    {InitializeCommands}
  330.  
  331.       c := MinCmd;
  332.       while c <= CmdNull do begin
  333.         with Commands[c] do begin
  334.           with main do begin
  335.             keys := '';
  336.             modified := False;
  337.             conflict := False;
  338.             mincol := primemincol;
  339.             maxcol := primemaxcol;
  340.           end;
  341.           with alt do begin
  342.             keys := '';
  343.             modified := False;
  344.             conflict := False;
  345.             mincol := secndmincol;
  346.             maxcol := secndmaxcol;
  347.           end;
  348.           case c of
  349.             CmdLeftChar : name := 'Character left';
  350.             CmdRightChar : name := 'Character right';
  351.             CmdLeftWord : name := 'Word left';
  352.             CmdRightWord : name := 'Word right';
  353.             CmdUpLine : name := 'Line up';
  354.             CmdDownLine : name := 'Line down';
  355.             CmdScrollUp : name := 'Scroll up';
  356.             CmdScrollDown : name := 'Scroll down';
  357.             CmdDownPage : name := 'Page down';
  358.             CmdUpPage : name := 'Page up';
  359.             CmdWindowTopFile : name := 'Top of window';
  360.             CmdWindowBottomFile : name := 'Bottom of window';
  361.             CmdLeftLine : name := 'Cursor to left side';
  362.             CmdRightLine : name := 'Cursor to right side';
  363.             CmdTopScreen : name := 'Top of screen';
  364.             CmdBottomScreen : name := 'Bottom of screen';
  365.             CmdMoveToBegin : name := 'Up to equal indent';
  366.             CmdMoveToEnd : name := 'Down to equal indent';
  367.             CmdCpgotoln : name := 'Go to line';
  368.             CmdJumpLastPosition : name := 'Previous cursor position';
  369.             CmdUndo : name := 'Undo last deletion';
  370.             CmdRestoreCurrentLine : name := 'Restore line';
  371.             CmdTab : name := 'Tab';
  372.             CmdInsertCtrlChar : name := 'Insert control char';
  373.             CmdNewLine : name := 'New line';
  374.             CmdInsertLine : name := 'Insert line';
  375.             CmdDeleteRightChar : name := 'Delete current character';
  376.             CmdDeleteLeftChar : name := 'Delete left character';
  377.             CmdDeleteRightWord : name := 'Delete right word';
  378.             CmdDeleteLineRight : name := 'Delete line right';
  379.             CmdDeleteLine : name := 'Delete line';
  380.             CmdFind : name := 'Find pattern';
  381.             CmdFindReplace : name := 'Find and replace';
  382.             CmdFindAndMacro : name := 'Search and apply macro';
  383.             CmdFindNext : name := 'Find next';
  384.             CmdToggleCase : name := 'Toggle case';
  385.             CmdLowerCase : name := 'Lower case';
  386.             CmdUpperCase : name := 'Upper case';
  387.             CmdInvokeDOS : name := 'Invoke DOS shell';
  388.             CmdShowMem : name := 'Show available memory';
  389.             CmdToggleInsert : name := 'Toggle insert mode';
  390.             CmdToggleAutoindent : name := 'Toggle autoindent mode';
  391.             CmdToggleMacroRecord : name := 'Toggle macro record';
  392.             CmdAddWindow : name := 'Add window';
  393.             CmdSizeWindow : name := 'Resize current window';
  394.             CmdDoneFile : name := 'Save/switch files';
  395.             CmdWindowDown : name := 'Next window';
  396.             CmdHelpSummary : name := 'Show help summary';
  397.             CmdBackTab : name := 'Backward tab';
  398.             CmdNewFile : name := 'Edit another file';
  399.             CmdAbandonFile : name := 'Abandon file';
  400.             CmdReadBlock : name := 'Read file into window';
  401.             CmdSaveFile : name := 'Save and continue edit';
  402.             CmdWriteBlock : name := 'Write block to file';
  403.             CmdSaveQuit : name := 'Save and exit to DOS';
  404.             CmdReadMacroFile : name := 'Load macros from disk';
  405.             CmdWriteMacroFile : name := 'Write macros to disk';
  406.             CmdJumpTopOfBlock : name := 'Top of block';
  407.             CmdJumpBottomBlock : name := 'Bottom of block';
  408.             CmdBlockBegin : name := 'Begin block';
  409.             CmdBlockCopy : name := 'Copy block';
  410.             CmdBlockHide : name := 'Toggle block display';
  411.             CmdBlockEnd : name := 'End block';
  412.             CmdBlockWord : name := 'Mark current word';
  413.             CmdBlockMove : name := 'Move block';
  414.             CmdBlockDelete : name := 'Delete block';
  415.             CmdToggleTextMarker : name := 'Toggle marker display';
  416.             CmdSetMarker0 : name := 'Set marker 0';
  417.             CmdSetMarker1 : name := 'Set marker 1';
  418.             CmdSetMarker2 : name := 'Set marker 2';
  419.             CmdSetMarker3 : name := 'Set marker 3';
  420.             CmdSetMarker4 : name := 'Set marker 4';
  421.             CmdSetMarker5 : name := 'Set marker 5';
  422.             CmdSetMarker6 : name := 'Set marker 6';
  423.             CmdSetMarker7 : name := 'Set marker 7';
  424.             CmdSetMarker8 : name := 'Set marker 8';
  425.             CmdSetMarker9 : name := 'Set marker 9';
  426.             CmdJumpMarker0 : name := 'Jump marker 0';
  427.             CmdJumpMarker1 : name := 'Jump marker 1';
  428.             CmdJumpMarker2 : name := 'Jump marker 2';
  429.             CmdJumpMarker3 : name := 'Jump marker 3';
  430.             CmdJumpMarker4 : name := 'Jump marker 4';
  431.             CmdJumpMarker5 : name := 'Jump marker 5';
  432.             CmdJumpMarker6 : name := 'Jump marker 6';
  433.             CmdJumpMarker7 : name := 'Jump marker 7';
  434.             CmdJumpMarker8 : name := 'Jump marker 8';
  435.             CmdJumpMarker9 : name := 'Jump marker 9';
  436.             CmdInsertMacro1 : name := 'Playback macro 1';
  437.             CmdInsertMacro2 : name := 'Playback macro 2';
  438.             CmdInsertMacro3 : name := 'Playback macro 3';
  439.             CmdInsertMacro4 : name := 'Playback macro 4';
  440.             CmdInsertMacro5 : name := 'Playback macro 5';
  441.             CmdInsertMacro6 : name := 'Playback macro 6';
  442.             CmdInsertMacro7 : name := 'Playback macro 7';
  443.             CmdInsertMacro8 : name := 'Playback macro 8';
  444.             CmdInsertMacro9 : name := 'Playback macro 9';
  445.             CmdInsertScrapPrompted : name := 'Playback scrap';
  446.             CmdInsertScrap1 : name := 'Playback scrap 1 time';
  447.             CmdInsertScrap2 : name := 'Playback scrap 2 times';
  448.             CmdInsertScrap3 : name := 'Playback scrap 3 times';
  449.             CmdInsertScrap4 : name := 'Playback scrap 4 times';
  450.             CmdInsertScrap5 : name := 'Playback scrap 5 times';
  451.             CmdInsertScrap6 : name := 'Playback scrap 6 times';
  452.             CmdInsertScrap7 : name := 'Playback scrap 7 times';
  453.             CmdInsertScrap8 : name := 'Playback scrap 8 times';
  454.             CmdInsertScrap9 : name := 'Playback scrap 9 times';
  455.             CmdSetLeftMargin : name := 'Set left margin';
  456.             CmdSetRightMargin : name := 'Set right margin';
  457.             CmdReformParagraph : name := 'Reformat paragraph';
  458.             CmdToggleWordWrap : name := 'Toggle word wrap';
  459.             CmdGotoColumn : name := 'Go to column';
  460.             CmdGotoWindow : name := 'Go to window';
  461.             CmdSysInfo : name := 'Show system info';
  462.             CmdDelLineNoRecourse : name := 'Delete Line (no undo)';
  463.             CmdZoomWindow : name := 'Zoom current window';
  464.             CmdToggleTabLine : name := 'Toggle tab line';
  465.             CmdInsertUndoBuffer : name := 'Insert undo buffer';
  466.             CmdToggleJustify : name := 'Toggle right justify';
  467.             CmdPrintFile : name := 'Print file';
  468.             CmdFlushUndo : name := 'Flush undo buffer';
  469.             CmdUnused4 : name := 'For expansion';
  470.             CmdUnused5 : name := 'For expansion';
  471.             CmdLogDrive : name := 'Log drive/path';
  472.             CmdDirectory : name := 'File directory';
  473.             CmdTogglePaginate : name := 'Toggle pagination';
  474.             CmdToggleAttribute : name := 'Toggle attributes';
  475.             CmdCenterLine : name := 'Center line';
  476.             CmdSetColors : name := 'Set colors';
  477.             CmdSaveDefaults : name := 'Save defaults';
  478.             CmdGotoPage : name := 'Go to page';
  479.             CmdSetTopMargin : name := 'Set top margin';
  480.             CmdSetBotMargin : name := 'Set bottom margin';
  481.             CmdSetPageLength : name := 'Set page length';
  482.             CmdSetUndoLimit : name := 'Set undo limit';
  483.             CmdToggleTabExpansion : name := 'Toggle tab expansion';
  484.             CmdGetDefaultExtension : name := 'Set default extension';
  485.             CmdSaveTabLine : name := 'Save tab line';
  486.             CmdEditTabLine : name := 'Edit tab line';
  487.             CmdSetTempMargin : name := 'Set temp margin';
  488.             CmdSetTabLine : name := 'Set tab line';
  489.             CmdSetTabSize : name := 'Set tab size';
  490.             CmdPromptSetMarker : name := 'Set a marker via menu';
  491.             CmdPromptJumpMarker : name := 'Jump to marker by menu';
  492.             CmdPromptInsertMacro : name := 'Playback macro by menu';
  493.             CmdToggleTabMode : name := 'Toggle fixed tabs';
  494.             CmdSetTempAtCursor : name := 'Temp margin to cursor';
  495.             CmdReformBlock : name := 'Reformat block';
  496.             CmdCloseTillLast : name := 'Close window';
  497.             CmdSetSupportPath : name := 'Set support path';
  498.             CmdToggleStripMode : name := 'Toggle hi-bit strip';
  499.             CmdEditMacro : name := 'Edit macro';
  500.             CmdWriteNamedFile : name := 'Write to named file';
  501.             CmdToggleKeyHelp : name := 'Toggle key help';
  502.             CmdWindowUp : name := 'Previous window';
  503.             CmdNextSentence : name := 'Next sentence';
  504.             CmdPrevSentence : name := 'Previous sentence';
  505.             CmdRestoreDefaultTabs : name := 'Default tabs';
  506.             CmdWhatFont : name := 'Show font';
  507.             CmdChooseBold : name := 'Select bold';
  508.             CmdChooseDbl : name := 'Select double';
  509.             CmdChooseUnd : name := 'Select underscore';
  510.             CmdChooseSup : name := 'Select superscript';
  511.             CmdChooseSub : name := 'Select subscript';
  512.             CmdChooseAlt1 : name := 'Select compressed';
  513.             CmdChooseAlt2 : name := 'Select italic';
  514.             CmdToggleRetraceMode : name := 'Toggle snow check';
  515.             CmdToggleSolidCursor : name := 'Toggle block cursor';
  516.             CmdToggleEga43Line : name := 'Toggle 43 line mode';
  517.             CmdMarginRelease : name := 'Margin release';
  518.             CmdSpellCheck : name := 'Check spelling';
  519.             CmdToggleWriteTabs : name := 'Toggle tab writing';
  520.             CmdToggleCompressWrap : name := 'Toggle compress at wrap';
  521.             CmdToggleInitZoomState : name := 'Toggle initial zoom';
  522.  
  523.             CmdHelpMenu : name := 'Help menu';
  524.             CmdCursorHelp : name := 'Cursor help';
  525.             CmdQuickHelp : name := 'Quick movement help';
  526.             CmdDeleteHelp : name := 'Delete help';
  527.             CmdFindHelp : name := 'Find/Replace help';
  528.             CmdFileHelp : name := 'File help';
  529.             CmdWindowHelp : name := 'Window help';
  530.             CmdHelpHelp : name := 'Status help';
  531.             CmdBlockHelp : name := 'Block help';
  532.             CmdTextHelp : name := 'Text help';
  533.             CmdTabHelp : name := 'Tab help';
  534.             CmdUtilityHelp : name := 'Utility help';
  535.             CmdSettingHelp : name := 'Setting help';
  536.             CmdSpellingHelp : name := 'Spelling help';
  537.             CmdMacroHelp : name := 'Macro help';
  538.             CmdFormatHelp : name := 'Print Format help';
  539.             CmdFunctionKeyHelp : name := 'Function keys';
  540.  
  541.             CmdMenu : name := 'Activate menus';
  542.             CmdAbort : name := 'Abort command (1 char)';
  543.             CmdNull : name := 'No action';
  544.             CmdNullMain : name := 'No action (main)';
  545.           end;
  546.         end;
  547.         c := Succ(c);
  548.       end;
  549.     end;                     {InitializeCommands}
  550.  
  551.     procedure ParsePackedCommands(PackedCommands : PackedCommandList;
  552.                                   var Commands : commandlist);
  553.       {-fill in the structured command array from the packed buffer}
  554.     var
  555.       p, CmdLen : Integer;
  556.       c : CommandType;
  557.  
  558.     begin                    {ParsePackedCommands}
  559.       p := 0;
  560.       CmdLen := Ord(PackedCommands[p]);
  561.       while CmdLen <> 0 do begin
  562.         c := CommandType(Ord(PackedCommands[Succ(p+CmdLen)]));
  563.         with Commands[c] do begin
  564.           if main.keys = '' then
  565.             {load the main command selection}
  566.             Move(PackedCommands[p], main.keys[0], Succ(CmdLen))
  567.           else if alt.keys = '' then
  568.             {load the alternate command selection}
  569.             Move(PackedCommands[p], alt.keys[0], Succ(CmdLen))
  570.           else begin
  571.             {both are full}
  572.             ClrEol(1, 1, LoColor);
  573.             EdFastWrite('Warning: more than 2 definitions for command '+name, 1, 1, LoColor);
  574.           end;
  575.         end;
  576.         {move to next command set}
  577.         p := p+CmdLen+2;
  578.         CmdLen := Ord(PackedCommands[p]);
  579.       end;
  580.     end;                     {ParsePackedCommands}
  581.  
  582.     procedure DisplayKeys(thecolor, r : Byte; k : keyrec);
  583.       {-display the stored keystrokes}
  584.     var
  585.       txt, dis : VarString;
  586.       Len : Byte;
  587.       txtlen : Byte absolute txt;
  588.  
  589.     begin                    {DisplayKeys}
  590.       with k do begin
  591.         Len := Succ(maxcol-mincol);
  592.         txt := TextRepresentation(k);
  593.         dis := Pad(Copy(txt, 1, Len), Len);
  594.         EdFastWrite(dis, r, mincol, thecolor);
  595.         if txtlen > Len then
  596.           GoToXY(mincol+Len, r)
  597.         else
  598.           GoToXY(mincol+Ord(txt[0]), r);
  599.       end;
  600.     end;                     {DisplayKeys}
  601.  
  602.     procedure DisplayCommand(c : CommandType; r : Byte);
  603.       {-display a command and its keys}
  604.  
  605.     begin                    {DisplayCommand}
  606.       if c = CmdNull then
  607.         {Draw a separator bar}
  608.         Center(r, TiColor, '────────────────────────────────────────────────────────────────────────────────')
  609.       else
  610.         with Commands[c] do begin
  611.           ClrEol(1, r, TiColor);
  612.           EdFastWrite(name, r, 1, TiColor);
  613.           EdFastWrite('P:', r, primecmdcol, TiColor);
  614.           if main.conflict then
  615.             DisplayKeys(CfColor, r, main)
  616.           else if main.modified then
  617.             DisplayKeys(ChColor, r, main)
  618.           else
  619.             DisplayKeys(LoColor, r, main);
  620.           EdFastWrite('S:', r, secndcmdcol, TiColor);
  621.           if alt.conflict then
  622.             DisplayKeys(CfColor, r, alt)
  623.           else if alt.modified then
  624.             DisplayKeys(ChColor, r, alt)
  625.           else
  626.             DisplayKeys(LoColor, r, alt);
  627.         end;
  628.     end;                     {DisplayCommand}
  629.  
  630.     function GetKeys(r : Byte; var k : keyrec; var stopnow : Boolean) : Boolean;
  631.       {-edit a key sequence, default keys as input, keys also return result}
  632.       {-return true if keys were modified in the process}
  633.     const
  634.       ScrollMask = $10;
  635.     var
  636.       Quitting : Boolean;
  637.       CH : Char;
  638.       buf : KeyString;
  639.       scrolllock, lastscroll : Byte;
  640.       KbFlag : Byte absolute $0040 : $0017;
  641.  
  642.     begin                    {GetKeys}
  643.  
  644.       stopnow := False;
  645.       lastscroll := $FF;
  646.  
  647.       with k do begin
  648.         buf := keys;
  649.         Quitting := False;
  650.         repeat
  651.           DisplayKeys(EdColor, r, k);
  652.  
  653.           repeat
  654.             {Watch the scroll state while waiting for a keystroke}
  655.             scrolllock := KbFlag and ScrollMask;
  656.             if scrolllock <> lastscroll then begin
  657.               if scrolllock <> 0 then
  658.                 EdFastWrite('Literal', 1, 70, LoColor)
  659.               else
  660.                 EdFastWrite('Command', 1, 70, LoColor);
  661.               lastscroll := scrolllock;
  662.             end;
  663.           until KeyPressed;
  664.  
  665.           CH := ReadKey;
  666.  
  667.           if scrolllock <> 0 then begin
  668.             {literal mode}
  669.             if CH = #0 then begin
  670.               CH := ReadKey;
  671.               if Length(keys) < Pred(KeyLength) then
  672.                 keys := keys+#0+CH;
  673.             end else if Length(keys) < KeyLength then
  674.               keys := keys+CH;
  675.  
  676.           end else
  677.             {command mode}
  678.             case Upcase(CH) of
  679.               #0 :
  680.                 begin
  681.                   CH := ReadKey;
  682.                   if Length(keys) < Pred(KeyLength) then
  683.                     keys := keys+#0+CH;
  684.                 end;
  685.  
  686.               ^M :
  687.                 Quitting := True;
  688.  
  689.               ^H :           {backspace}
  690.                 if Length(keys) > 0 then begin
  691.                   Delete(keys, Length(keys), 1);
  692.                   if (Length(keys) > 0) and (keys[Length(keys)] = #0) then
  693.                     Delete(keys, Length(keys), 1);
  694.                 end;
  695.  
  696.               'C' :
  697.                 keys := '';  {erase}
  698.  
  699.               'R' :
  700.                 keys := buf; {restore original}
  701.  
  702.               #32..#47,
  703.               #58..#126,
  704.               #128..#255 : {ignore regular characters} ;
  705.  
  706.               Escape :
  707.                 begin
  708.                   stopnow := True;
  709.                   Quitting := True;
  710.                 end;
  711.  
  712.             else
  713.               if Length(keys) < KeyLength then
  714.                 keys := keys+CH;
  715.             end;
  716.  
  717.         until Quitting;
  718.  
  719.         GetKeys := (keys <> buf);
  720.         EdFastWrite('═══════', 1, 70, TiColor);
  721.  
  722.       end;
  723.     end;                     {getkeys}
  724.  
  725.     procedure EditKeys(r : Byte; var k : keyrec);
  726.       {-edit one key record}
  727.     var
  728.       stopnow : Boolean;
  729.  
  730.     begin                    {EditKeys}
  731.       Center(2, EdColor, EditPrompt);
  732.       with k do begin
  733.         modified := GetKeys(r, k, stopnow);
  734.         if modified then begin
  735.           DisplayKeys(ChColor, r, k);
  736.           conflict := False;
  737.         end else if conflict then
  738.           DisplayKeys(CfColor, r, k)
  739.         else
  740.           DisplayKeys(LoColor, r, k);
  741.       end;
  742.       Center(2, TiColor, BrowsePrompt);
  743.     end;                     {EditKeys}
  744.  
  745.     procedure DrawFullPage(cmdstart : Integer);
  746.       {-write a full page of commands, starting at cmdstart}
  747.     var
  748.       r : Byte;
  749.       c : Integer;
  750.  
  751.     begin                    {DrawFullPage}
  752.       r := firstrow;
  753.       c := cmdstart;
  754.       while (r <= lastrow) and (c <= MaxDisplay) do begin
  755.         DisplayCommand(ordermap[c], r);
  756.         r := Succ(r);
  757.         c := Succ(c);
  758.       end;
  759.     end;                     {DrawFullPage}
  760.  
  761.     procedure EditCommands;
  762.       {-Allow browsing and changing of command keys in range minc to maxc}
  763.     var
  764.       Quitting : Boolean;
  765.       oldtopc, topc, curc : Integer;
  766.       r, curr : Byte;
  767.       curcmd : CommandType;
  768.       k : keyrec;
  769.       onmain : Boolean;
  770.  
  771.     begin                    {EditCommands}
  772.       Center(2, TiColor, BrowsePrompt);
  773.       Center(3, TiColor, '════════════════════════════════════════════════════════════════════════════════');
  774.       topc := 1;
  775.       curc := 1;
  776.       curr := firstrow;
  777.       DrawFullPage(topc);
  778.       onmain := True;
  779.  
  780.       Quitting := False;
  781.       repeat
  782.  
  783.         {Handle display mapping}
  784.         curcmd := ordermap[curc];
  785.  
  786.         if onmain then
  787.           k := Commands[curcmd].main
  788.         else
  789.           k := Commands[curcmd].alt;
  790.  
  791.         GoToXY(k.mincol, curr);
  792.  
  793.         case GetCursorCommand of
  794.  
  795.           ^M :               {edit key}
  796.             if (curcmd <> CmdNull) then begin
  797.               EditKeys(curr, k);
  798.               if onmain then
  799.                 Commands[curcmd].main := k
  800.               else
  801.                 Commands[curcmd].alt := k;
  802.             end;
  803.  
  804.           ^E, ^W :           {scroll up}
  805.             if curc > 1 then begin
  806.               curc := Pred(curc);
  807.               if curr = firstrow then begin
  808.                 topc := curc;
  809.                 InsLine;
  810.                 DisplayCommand(ordermap[curc], firstrow);
  811.               end else
  812.                 curr := Pred(curr);
  813.             end;
  814.  
  815.           ^X, ^Z :           {scroll down}
  816.             if curc < MaxDisplay then begin
  817.               curc := Succ(curc);
  818.               if curr >= lastrow then begin
  819.                 GoToXY(1, firstrow);
  820.                 DelLine;
  821.                 DisplayCommand(ordermap[curc], lastrow);
  822.                 topc := Succ(topc);
  823.               end else
  824.                 curr := Succ(curr);
  825.             end;
  826.  
  827.           ^S :               {move to secondary}
  828.             onmain := True;
  829.  
  830.           ^D :               {move to primary}
  831.             onmain := False;
  832.  
  833.           ^r :               {page up}
  834.             if curc > 1 then begin
  835.               oldtopc := topc;
  836.               r := firstrow;
  837.               while (curc > 1) and (r < lastrow) do begin
  838.                 curc := Pred(curc);
  839.                 curr := Pred(curr);
  840.                 if curr < firstrow then begin
  841.                   topc := curc;
  842.                   curr := firstrow;
  843.                 end;
  844.                 r := Succ(r);
  845.               end;
  846.               if topc <> oldtopc then
  847.                 DrawFullPage(topc);
  848.             end;
  849.  
  850.           ^c :               {page down}
  851.             if curc < MaxDisplay then begin
  852.               r := firstrow;
  853.               oldtopc := topc;
  854.               while (curc < MaxDisplay) and (r < lastrow) do begin
  855.                 curr := Succ(curr);
  856.                 curc := Succ(curc);
  857.                 if curr > lastrow then begin
  858.                   topc := Succ(topc);
  859.                   curr := lastrow;
  860.                 end;
  861.                 r := Succ(r);
  862.               end;
  863.               if topc <> oldtopc then
  864.                 DrawFullPage(topc);
  865.             end;
  866.  
  867.           ^T :               {home}
  868.             if curc > 1 then begin
  869.               curc := 1;
  870.               topc := 1;
  871.               curr := firstrow;
  872.               onmain := True;
  873.               DrawFullPage(topc);
  874.             end;
  875.  
  876.           ^B :               {end}
  877.             if curc < MaxDisplay then begin
  878.               curr := firstrow;
  879.               curc := MaxDisplay;
  880.               while curr < lastrow do begin
  881.                 curr := Succ(curr);
  882.                 curc := Pred(curc);
  883.               end;
  884.               topc := curc;
  885.               DrawFullPage(topc);
  886.               curc := MaxDisplay;
  887.               onmain := False;
  888.             end;
  889.  
  890.           'R' : {restore all defaults} {***}
  891.             begin
  892.               Commands := OrigCommands;
  893.               DrawFullPage(topc);
  894.             end;
  895.  
  896.           Escape :           {done}
  897.             Quitting := True;
  898.  
  899.         end;
  900.       until Quitting;
  901.     end;                     {EditCommands}
  902.  
  903.     procedure FastInstallCommands;
  904.       {-Prompt for commands one by one}
  905.     var
  906.       curcmd : CommandType;
  907.       c : Integer;
  908.       stopnow : Boolean;
  909.       CH : Char;
  910.  
  911.       procedure PromptFor(var keyset : keyrec);
  912.         {-get the new keyrec for main or alt}
  913.       var
  914.         k : keyrec;
  915.  
  916.       begin                  {PromptFor}
  917.         k.keys := '';
  918.         k.mincol := WhereX;
  919.         k.maxcol := WhereX+20;
  920.         if GetKeys(WhereY, k, stopnow) then
  921.           {new keystring returned}
  922.           with keyset do begin
  923.             modified := True;
  924.             conflict := False;
  925.             keys := k.keys;
  926.             DisplayKeys(ChColor, WhereY, k);
  927.         end else
  928.           {accepted default}
  929.           DisplayKeys(LoColor, WhereY, k);
  930.         WriteLn;
  931.       end;                   {PromptFor}
  932.  
  933.     begin                    {FastInstallCommands}
  934.       WriteLn;
  935.       WriteLn('Press <Enter> to accept default');
  936.       WriteLn('Press keys followed by <Enter> for new key sequence');
  937.       WriteLn('Press <Bksp> to back up one keystroke, C to Clear, R to Restore');
  938.       WriteLn('Press <ScrollLock> to toggle literal mode');
  939.       WriteLn('Press <Escape> to quit entering commands');
  940.       WriteLn('Random access editing is available when you are finished');
  941.       WriteLn;
  942.       c := 1;
  943.       stopnow := False;
  944.       while not(stopnow) and (c <= MaxDisplay) do begin
  945.         with Commands[ordermap[c]] do begin
  946.           Write(Pad(name, 26), '( Primary ): ', Pad(TextRepresentation(main), 18), ' ');
  947.           PromptFor(main);
  948.           if not(stopnow) then begin
  949.             Write(Pad(name, 26), '(Secondary): ', Pad(TextRepresentation(alt), 18), ' ');
  950.             PromptFor(alt);
  951.           end;
  952.         end;
  953.         repeat
  954.           c := Succ(c);
  955.         until (c > MaxDisplay) or (ordermap[c] <> CmdNull);
  956.       end;
  957.       WriteLn;
  958.       Write('Press a key to invoke full screen key editor ');
  959.       CH := ReadKey;
  960.     end;                     {FastInstallCommands}
  961.  
  962.     function CheckCommands(var Commands : commandlist) : Boolean;
  963.       {-Return true if no duplicate commands are found, else complain}
  964.     var
  965.       fcmd, tcmd : CommandType;
  966.       ok : Boolean;
  967.       cnt : Integer;
  968.       cntstr : VarString;
  969.  
  970.       function Conflicting(fcmd, tcmd : CommandType) : Boolean;
  971.         {-return true, and set appropriate flags if any conflict}
  972.       var
  973.         fmain, falt, tmain, talt : KeyString;
  974.         ok : Boolean;
  975.  
  976.       begin                  {Conflicting}
  977.         ok := True;
  978.         with Commands[fcmd] do begin
  979.           fmain := main.keys;
  980.           falt := alt.keys;
  981.         end;
  982.         with Commands[tcmd] do begin
  983.           tmain := main.keys;
  984.           talt := alt.keys;
  985.         end;
  986.         if fmain <> '' then begin
  987.           if Pos(fmain, tmain) = 1 then begin
  988.             ok := False;
  989.             Commands[fcmd].main.conflict := True;
  990.             Commands[tcmd].main.conflict := True;
  991.           end;
  992.           if Pos(fmain, talt) = 1 then begin
  993.             ok := False;
  994.             Commands[fcmd].main.conflict := True;
  995.             Commands[tcmd].alt.conflict := True;
  996.           end;
  997.         end;
  998.         if tmain <> '' then begin
  999.           if Pos(tmain, fmain) = 1 then begin
  1000.             ok := False;
  1001.             Commands[tcmd].main.conflict := True;
  1002.             Commands[fcmd].main.conflict := True;
  1003.           end;
  1004.           if Pos(tmain, falt) = 1 then begin
  1005.             ok := False;
  1006.             Commands[tcmd].main.conflict := True;
  1007.             Commands[fcmd].alt.conflict := True;
  1008.           end;
  1009.         end;
  1010.         if talt <> '' then begin
  1011.           if Pos(talt, fmain) = 1 then begin
  1012.             ok := False;
  1013.             Commands[tcmd].alt.conflict := True;
  1014.             Commands[fcmd].main.conflict := True;
  1015.           end;
  1016.           if Pos(talt, falt) = 1 then begin
  1017.             ok := False;
  1018.             Commands[tcmd].alt.conflict := True;
  1019.             Commands[fcmd].alt.conflict := True;
  1020.           end;
  1021.         end;
  1022.         if falt <> '' then begin
  1023.           if Pos(falt, tmain) = 1 then begin
  1024.             ok := False;
  1025.             Commands[fcmd].alt.conflict := True;
  1026.             Commands[tcmd].main.conflict := True;
  1027.           end;
  1028.           if Pos(falt, talt) = 1 then begin
  1029.             ok := False;
  1030.             Commands[fcmd].alt.conflict := True;
  1031.             Commands[tcmd].alt.conflict := True;
  1032.           end;
  1033.         end;
  1034.         Conflicting := not(ok);
  1035.       end;                   {Conflicting}
  1036.  
  1037.     begin                    {CheckCommands}
  1038.       {Provide some reassurance}
  1039.       ClrEol(1, 1, LoColor);
  1040.       EdFastWrite('Checking for conflicts....', 1, 1, LoColor);
  1041.  
  1042.       {Reset previous conflicts}
  1043.       fcmd := MinCmd;
  1044.       while fcmd <= CmdAbort do begin
  1045.         with Commands[fcmd] do begin
  1046.           main.conflict := False;
  1047.           alt.conflict := False;
  1048.         end;
  1049.         fcmd := Succ(fcmd);
  1050.       end;
  1051.  
  1052.       fcmd := MinCmd;
  1053.       ok := True;
  1054.       cnt := 0;
  1055.  
  1056.       while fcmd <= CmdAbort do begin
  1057.  
  1058.         {Keep status going}
  1059.         cnt := Succ(cnt);
  1060.         Str(cnt:4, cntstr);
  1061.         EdFastWrite(cntstr, 1, 28, LoColor);
  1062.  
  1063.         {Don't waste space on duplicate commands}
  1064.         with Commands[fcmd] do
  1065.           if main.keys = alt.keys then begin
  1066.             alt.keys := '';
  1067.             alt.conflict := False;
  1068.             alt.modified := False;
  1069.           end;
  1070.  
  1071.         if Commands[fcmd].main.modified or Commands[fcmd].alt.modified then begin
  1072.           {Now compare for conflicts}
  1073.           tcmd := MinCmd;
  1074.           while tcmd <= CmdAbort do begin
  1075.             if (tcmd <> fcmd) then
  1076.               if Conflicting(fcmd, tcmd) then
  1077.                 ok := False;
  1078.             tcmd := Succ(tcmd);
  1079.           end;
  1080.         end;
  1081.  
  1082.         fcmd := Succ(fcmd);
  1083.  
  1084.       end;
  1085.       ClrEol(1, 1, LoColor);
  1086.       CheckCommands := ok;
  1087.     end;                     {CheckCommands}
  1088.  
  1089.     procedure PackCommands(Commands : commandlist;
  1090.                            var PackedCommands : PackedCommandList;
  1091.                            var CmdLen : Integer);
  1092.       {-Rebuild the packed command structure}
  1093.     var
  1094.       c : CommandType;
  1095.       Len : Byte;
  1096.  
  1097.     begin                    {PackCommands}
  1098.       CmdLen := 0;
  1099.       FillChar(PackedCommands, SizeOf(PackedCommands), 0);
  1100.       c := MinCmd;
  1101.       while c <= CmdAbort do begin
  1102.         with Commands[c] do begin
  1103.           if main.keys <> '' then begin
  1104.             Len := Ord(main.keys[0]);
  1105.             Move(main.keys, PackedCommands[CmdLen], Succ(Len));
  1106.             PackedCommands[Succ(CmdLen+Len)] := Chr(Ord(c));
  1107.             CmdLen := CmdLen+Len+2;
  1108.           end;
  1109.           if alt.keys <> '' then begin
  1110.             Len := Ord(alt.keys[0]);
  1111.             Move(alt.keys, PackedCommands[CmdLen], Succ(Len));
  1112.             PackedCommands[Succ(CmdLen+Len)] := Chr(Ord(c));
  1113.             CmdLen := CmdLen+Len+2;
  1114.           end;
  1115.         end;
  1116.         c := Succ(c);
  1117.       end;
  1118.       {Pad with zeros}
  1119.       CmdLen := CmdLen+4;
  1120.     end;                     {PackCommands}
  1121.  
  1122.   begin
  1123.  
  1124.     ClrScr;
  1125.  
  1126.     {command with the lowest ordinal}
  1127.     MinCmd := CmdLeftChar;
  1128.  
  1129.     InitializeScreen;
  1130.     GoToXY(1, 3);
  1131.  
  1132.     KeyOfs := FindKeys(PackedCommands, CmdsRead);
  1133.  
  1134.     InitializeCommands(Commands);
  1135.     ParsePackedCommands(PackedCommands, Commands);
  1136.     OrigCommands := Commands; {***}
  1137.  
  1138.     if YesNo('Perform fast entry of fully reconfigured keyboard?', 'N') then
  1139.       {Sequential installation}
  1140.       FastInstallCommands;
  1141.  
  1142.     InitializeScreen;
  1143.  
  1144.     Quitting := False;
  1145.     repeat
  1146.  
  1147.       {Random access editing}
  1148.       EditCommands;
  1149.       SetColor(LoColor);
  1150.       ClrEol(1, 1, LoColor);
  1151.       ClrEol(1, 2, LoColor);
  1152.       GoToXY(1, 1);
  1153.  
  1154.       CH := Getkey('W to update MS.EXE and MS.HLP files, Q to quit without writing: ', 'WQ');
  1155.       Write(CH);
  1156.       GoToXY(1, 1);
  1157.       case CH of
  1158.         'W' : begin
  1159.                 Wrote := True;
  1160.                 if CheckCommands(Commands) then
  1161.                   Quitting := True
  1162.                 else begin
  1163.                   ClrEol(1, 1, EdColor);
  1164.                   EdFastWrite('Command conflicts found and marked. Press a key to correct...', 1, 1, EdColor);
  1165.                   CH := ReadKey;
  1166.                   Center(1, TiColor, Title);
  1167.                 end;
  1168.               end;
  1169.         'Q' : begin
  1170.                 Wrote := False;
  1171.                 Quitting := True;
  1172.               end;
  1173.       end;
  1174.     until Quitting;
  1175.  
  1176.     if Wrote then begin
  1177.       ClrEol(1, 1, LoColor);
  1178.       EdFastWrite('Updating '+ProgName+'...', 1, 1, LoColor);
  1179.       PackCommands(Commands, PackedCommands, CmdLen);
  1180.       if not ModifyDefaults(KeyOfs, PackedCommands, CmdsRead) then
  1181.         HaltError('Error writing to keyboard installation area');
  1182.     end;
  1183.     KeyInstall := Wrote;
  1184.  
  1185.   end;                       {KeyInstall}
  1186.  
  1187.