HISTORY Rainbow Version 5.0 Description HISTORY is a program for Rainbow MS-DOS 2.0 and later (there is also an IBM PC version) which allows the user to recall, edit, and reissue previously-typed DOS commands. If a mistake is made on the command currently being entered but is not noticed until after several more characters have been typed, the mistake may be fixed without deleting the intervening characters. Commands are saved in a 512-byte FIFO buffer. The number of commands that can be saved in the buffer depends on their length. When the buffer becomes full, one or more of the oldest commands are evicted to make room for a new command. If a new command is identical to the immediately preceding command, it is not duplicated in the history buffer. The user steps back and forth through old commands using the up- and down-arrow keys. Up-arrow recalls the most recent command, another up-arrow the second most recent, and so forth. Down-arrow moves forward in the buffer. Both movements are circular -- when up-arrow reaches the oldest command another up- arrow will return to the current command (the DOS prompt). An initial down-arrow will move to the oldest command. The left- and right-arrow keys may be used to move within a line. Shift-up-arrow moves to the beginning of the line, while shift-down-arrow moves back to the end. The Delete key deletes the character to the left of the cursor and the Remove key deletes the character under the cursor. Normal characters are inserted into the line. Other editing commands are summarized below. When the user types Return the command is executed regard- less of the position of the cursor. After each DOS command is executed the buffer pointer is returned to the location at the end of the buffer. A line may be recalled by content by typing the Select key; the user is then prompted for an anchored search string. The history list is searched backwards for the line beginning with the specified string. To search for the next-most recent occurrence of the string, the user merely hits the Find key. The command may then be edited as above and sent to DOS with a Return. As a shorthand for Select, the Do key prompts for a single-character search string without a carriage return; the selected command is automatically executed. The string seleted by Select or Do is remembered between HISTORY invocations. Subsequent uses of the Find key use this string until another is chosen. All searches wrap circularly. Multiple DOS commands may be entered on one line by separating them with a semi-colon. The commands will be sent one at a time to DOS. A semicolon as the last character on the line will be sent along (hello, MicroSoft). To enter a semicolon mid- command, type two (one will be sent). Other function key actions are described under "Function Key Summary" below. Immortal Commands Up to 256 bytes of "immortal" commands may be loaded from a file by specifying the file name as an argument when HISTORY is loaded or by loading the file interactively with the Shift-Do key. The commands are immortal in that they are not deleted to make room for new commands. The immortal commands remain at the top (oldest) part of the buffer and thus are immediately accessible via the down-arrow key. They may be searched for and otherwise treated as any other commands. The buffer is cleared before the file is loaded. Aliases Commands may be given an alias via the syntax :alias replacement Whenever the alias is typed at the start of the line, its replacement is inserted in its place and the resulting command executed. For example given the aliases :dw dir /w :t type in the command buffer, typing dw is equivalent to typing dir /w and t fred is equivalent to type fred Alias substitution is only done on the first word of a command; multiple commands separated by semicolons will, however, have alias substitution applied to each command. Substitution is tried only once per command, thus :dir dir /w will not loop recursively but will give the desired result. Aliases are usually loaded from a file of immortal commands but may also be established interactively. Non-immortal aliases eventually age and die, however. If multiple definitions of the same alias exist, the first one encountered searching from most recent to oldest is used. If an alias is defined with no replacement string, e.g. :dir then this cancels the effect of older definitions of the same alias; in this case dir is no longer an alias for something else. Hot Keys A special case of an alias is the Hot Key. A command may be aliased as a function key. If the function key is then pressed at the beginning of the line, the command is executed without waiting for a carriage return. The alias must be a 3-character hex code from the following table: Fkey Code Fkey Code F3 (Print Screen) X03 F18 X15 F4 X05 F19 X17 F5 (Break) X65 F20 X19 F7 (Resume) X09 PF1 X59 F8 (Cancel) X0B PF2 X5C F9 (Main Screen) X0D PF3 X5F F14 (Addl Options) X11 PF4 X62 F17 X13 where the first character X is one of 1 Unshifted 3 Shift-Fkey 5 Control-Fkey 7 Control-Shift-Fkey These codes are cryptic, but a more user-friendly scheme would consume precious dedicated memory. You may put a comment at the end of the alias definition by preceding the comment by zero or more spaces followed by two pound signs (##). As an example, the following alias in the command buffer :113 dir ## F17 would cause the dir command to be executed when F17 was pressed. Screen Saver Timeout HISTORY enables the Rainbow's screen-saver feature after about eight minutes of keyboard inactivity (instead of the Rainbow default of thirty) at the command level. The screen is blanked and a blinking square appears in the upper-lefthand corner of the screen. Pressing any key (including Shift alone) will restore the screen. Installation HISTORY is enabled by executing HISTORY.EXE once per boot, typically from AUTOEXEC.BAT. It requires about 9K of dedicated memory. If an argument is present it is assumed to be the name of a file containing immortal commands to read into the buffer. Only the first 256 bytes will be read; it may, of course, be shorter than that. HISTORY works by trapping DOS function 0AH. Since programs other than COMMAND.COM also use function 0AH, HISTORY must distinguish COMMAND.COM from the crowd. It does this by remembering the address of the very first program to call it after it's been loaded; to insure that COMMAND.COM is the first caller, make HISTORY the last command in AUTOEXEC.BAT or invoke it manually. IMPORTANT NOTE TO USERS OF HISTORY 2.0 THROUGH 2.2: It is no longer necessary to patch COMMAND.COM with the HISPAT program; in fact, the patched COMMAND.COM will cause your system to hang with the new HISTORY. Replace your COMMAND.COM with the original supplied with DOS. Function Key Summary Up-arrow or Move back through commands. Prev Screen Down-arrow or Move forward through commands. Next Screen Left-arrow Move the cursor left one character. Right-arrow Move the cursor right one character. Shift-up-arrow Move the cursor to the beginning of line. Shift-down Move the cursor to the end of the line. Shift-left Move the cursor left one word. Shift-right Move the cursor right one word. Delete Delete the character before the cursor. Remove Delete the character under the cursor. Shift-Delete Delete from the beginning of the line to the cursor. Shift-Remove Delete from the cursor to the end of the line. ^Shift-left Delete from start of previous word to cursor. ^Shift-right Delete from cursor to start of next word. Insert Toggle insert/overstrike mode (starts each time in insert mode). When in overstrike mode, the cursor style is changed (if you use a block cursor, underscore will be used for overstrike mode; if you use an underscore cursor, a block will be used for overstrike mode). Return Execute the command (regardless of the cursor position). Select Select and find search string. Shift-Select Select and find search string and execute. Find Find next occurrence of string (remembered between commands). Shift-Find Find search string and execute. Do Select and find one-character search string and execute. Shift-Do Promts for the name of a file of immortal commands and loads that file. Help List the contents of the history buffer, oldest to most recent. Shift-Help List the contents of the history buffer, most recent to oldest. Exit Same as typing "EXIT"; useful for leaving secondary COMMAND.COM's. Interrupt Turns HISTORY off; commands are parsed via normal DOS code until Control-Z followed by Return is typed. HISTORY remains resident in memory and the command buffer remains intact. ; If not the last character on the line, splits DOS commands. They are handed one at a time to COMMAND.COM. If last on the line, it is sent along as part of the command. To send a semicolon mid-command, type two semicolons. ^C or ^X Delete the line being typed/edited. Printer Considerations When printing a file using the standard DOS print spooler PRINT.COM, lines are sent to the printer only when awaiting DOS input; since HISTORY bypasses DOS input when awaiting command input, the printer will stop until a command is run. Similarly, Control-P (printer toggle) will not be recognized in HISTORY. The solution to both problems is to use the Interrupt key to turn HISTORY off long enough for the file to print or to type Control-P (once toggled on you may turn HISTORY back on; printing will take place in this case). To turn HISTORY back on, type Control-Z followed by Return. Modification History Version 2.0 Version 1 worked by trapping each keyboard character and watching for the Help key which threw it into history-recall mode. The disadvantage of this (aside from having to type Help) was that HISTORY remembered everything, not just DOS commands, filling the buffer with unwanted text. The new version doesn't require the use of the Help key and allows the current command being typed to be edited as well. HISTORY may no longer be turned on and off (there is no longer any need to as it only operates with COMMAND.COM). You should remove any HISTORY ON and HISTORY OFF commands from your BAT files. To be consistent with other systems, Up-arrow and Down-arrow are now used to step back and forth between commands (they used to move to the beginning and end of the line). They now must be shifted to move to the beginning and end of the line respectively. Insert/overstrike mode is no longer remembered between commands (I got tired of forgetting). Each new DOS prompt begins in insert mode. The semicolon feature is new with version 2. Version 2.3 A few minor bugs were fixed. Input/overstrike mode is now reflected in the cursor style. Version 2.4 The ill-conceived scheme of patching COMMAND.COM has been eliminated. HISTORY 2.4 now works with the vanilla COMMAND.COM (see the important note under "Installation" above). The Help, Exit, and Interrupt key functions were added. Pyrotechnics caused by showing every command while searching have been eliminated. Version 2.6 A bug which caused the system to hang was fixed. HISTORY properly handles long lines which wrap around two rows. Searches are now caseless. The amount of dedicated memory required has been reduced. Version 2.7 A bug associated with ^X was fixed. Version 2.8 Unshifted HISTORY function keys may now be typed-ahead while a program is running (before, they were mapped to VT220 escape sequences). Shifted function keys will be mapped to their unshifted counterparts (alas!). Version 2.9 Screen-saver feature added. Version 3.0 Immortal commands added. Labeled commands added. If a command is identical to the immediately preceding command, the second is not saved in the history buffer. Version 3.1 Fixed a bug which made immortal commands mortal. Version 3.2 Fixed a bug which occurred when backspacing over the response to a prompt. Version 3.3 Added delete-word commands. Version 3.4 Made ^C behave like ^X. Version 3.5 Added Shift-Select and Shift-Find. Version 4.0 Labeled commands replaced with aliasing. Version 4.1 Alias substitution applied to semicolon-separated commands. Version 5.0 Added Hot Keys. Load function changed from Shift-Help to Shift-Do. Shift-Help added (lists command buffer in reverse order). Added alias cancel capability. ^C cancels command buffer list. Version 5.1 Translations of hot keys shown when executed. Author, author Copyright (c) 1985,86,87 by Bryan Higgins. All rights reserved, except the right to copy for non-commercial use. The author may be reached/rewarded at 1802 Channing Way Berkeley, CA 94703 One of the Kramden Utilities.