Exercises
November 10, 2006
-
Implement a text editor. Your editor will display a string of characters and a cursor. Your program will allow the user to move the cursor and modify the text using the following five operations:
- right - move the cursor to the right one character or do nothing if at the end of the line
- left - move the cursor to the left one character or do nothing if at the end of the line
- rdelete n - delete n characters to the right of the cursor
- ldelete n - delete n characters to the left of the cursor
- insert c - insert the character c just before the cursor
Use 2 stacks to store the characters - one to store the chars to the left of the cursor and one to store the chars to the right of the cursor.
Sami Rollins