You are to write a small version of a wordprocessor which can use escape sequences to gain special effects in the text. Set up a buffer capable of holding 1760 characters, clear the screen and put the cursor in the upperleft corner. Then, as the person at the keyboard enters each character do three things:
1. Check the character to determine if it is ordinary text or a special character. Ordinary text characters are to be echoed to the screen. For special characters, perform an appropriate action as follows:
Character Action
Ctrl B Toggle between bold on and off. At first Ctrl B, turn bold on; at second Ctrl B, turn bold off, etc.
Ctrl F Toggle between flashing (blinking) on and off. Use the same approach as for Ctrl B.
Ctrl H Erase the last character entered (assume it is to the immediate left of the cursor) and leave the cursor where the character was.
Backquote Clear the screen again, redisplay the contents of the buffer, and exit. This redisplay should look exactly like the screen already
looks, except the counter is missing and there is a system prompt. The backquote (`) is on the same key with the tilde (~).
2. Put an ordinary text character in the buffer and increase the count of characters stored there. Or, put the characters you output for the special action in the buffer and increase the count accordingly.
3. Display the number of characters that are in the buffer on line 24, near the right side of the screen and put the cursor back where it was in the text area.
In addition to the special actions listed above, implement one or the other of the following special character actions.
Ctrl G
Change subsequent text color. Actually, two characters are needed to change color, Ctrl G and a digit that represents the color to change to. These digits are taken directly from the escape sequences (1 red, 2 green, 3 yellow, ... 6 cyan). Thus, Ctrl G followed by 4 would change subsequent text to blue. To turn the color off, only a Ctrl G needs to be entered. All output the program does to handle color must be recorded in the buffer and counted, as with other special characters.
Esc
Respond as though this is the first character of a 3-character escape sequence (like esc [ A). Read in the next two characters, put it all in the buffer, output the escape sequence, and adjust the count. Responding to this special character will make it possible for the person at the keyboard to use the arrow keys and the mouse.
For extra credit, implement both Ctrl G and Esc.
Notes for testing: Enter is a Ctrl M (carriage return), Ctrl J is a linefeed. Some control characters should NOT be tried at all - for example, Ctrl C and Ctrl Y terminate the program, Ctrl O, Ctrl Q, and Ctrl S are used for Kermit's buffering. Backspace will NOT work at all. The function keys and named keys generate escape sequences that are more than three characters and will mess up your implementation of Esc, if you choose to try that.
Hand in an assembler generated listing of your program (a .LIS file printout). Also, copy the executable version of your program to the HANDIN directory and name the program after yourself. For example, if I were handing in the program I would give this command: COPY P3.EXE HANDIN:WOLFE.EXE
Do NOT name your program WOLFE.EXE; last time I checked, your name was not 'Wolfe'.