Develop a basic command-line text editor with Undo/Redo features.
In this project, you are going to develop a basic command-line text editor where the user enters commands to edit the text. An example of real-life text editor of this type is vi.
The text editor will read the input text from a file. Your program will then ask the user for commands to edit the text. Our text editor supports the following commands:
d n delete the next n characters.
r n new_text replace the next n characters with new_text
s key search for the first occurrence of key in the text. This commands moves the cursor to the first character of key, or to the end of the text if key is not found in the text.
i text insert text.
undo undo the effect of the last command.
redo redo the last undone command.
Your program should support undoing/redoing an arbitrary number of commands. Please refer to the test suit to find out the exact behavior of these commands.
You are provided with a test suite in folder src/test/java. Your implementation must pass all tests provided in this test suit. The test suite is broken into a number of sets for grading purposes as well as to help you with incremental development.
Individual tests can be run as follows:
gradle test_editor_state_construction
gradle test_editor_state_cursor_move
gradle test_editor_state_clone
gradle test_editor_print
gradle test_editor_cursor_move_commands
gradle test_editor_insert_commands
gradle test_editor_delete_commands
gradle test_editor_search_commands
gradle test_editor_replace_commands
gradle test_editor_undo_redo_commands
Running all of these tests must be possible by running gradle test.
The file file.txt contains the text that our editor will be editing.
To be successful, you have to use each day as an opportunity to improve, to be better, to get a little bit closer to your goals.
It might sound like a lot of work—and with a busy schedule, next to impossible. But the best part is, the more you accomplish, the more you’ll want to do, the higher you’ll want to reach.
So as long as you have the hunger for success, you will always have the power within you to achieve it.
Obviously, these are not my words!