Our goal in this project is to write a command-based text editor in cpp using linked lists and stack.
This text editor will print the contents of a file to the screen, page by page.
Each page consists of 10 lines. An example image is given below.
I have implemented a stack to keep track of all actions carried out, so you can undo actions if needed.
Sample txt files are included to the "Resource Files" folder of the project
-
open filename: The program should open the file whose name is provided in the field
filename
and loads its contents. For example, if the user enters "open test.txt", your program should open test.txt and load each line in the file to the linked list. -
save filename: The program should write the contents of the linked list to the file whose name is provided in the
filename
field. -
insert n text: The program should insert a new line with the "text" area user entered to the n_th_ line. For example, if the user enters "insert 5 hello my friend", your program should insert a new line at line position 5 and put "hello my friend" in that line.
If the .txt file already contains more than n lines, it should insert thin new line between lines n-1 and n, putting the newly inserted text at line n. If the file contains
less than n lines, it should fill the gap with blank lines until the newly inserted line becomes at position n. -
delete n: The program should delete the line at position n.
-
move n m: The program should move the line at position n to new position m.
-
replace n text: The program should replace the text at line n with the string provided within
text
area. -
next: Previous contents of the file should not change, but the program should display the next page.
-
prev: Previous contents of the file should not change, but the program should display the previous page.
-
undo: Reverts the last action taken. User should be able to call as many undo commands as s/he likes, and should be able to revert back to the initial state of the file after calling undo action enough times