A line editor with undo

The problem

Build a small text editor that keeps the lines of a document in a doubly linked list, and can undo every change.

Requirements

Technologies

Step by step

  1. Define the line node, and write functions that insert after the cursor and delete the current line.
  2. Write the print command, and test inserting and deleting at the first, a middle and the last line.
  3. Define an undo record that says what was done and holds what is needed to reverse it.
  4. Push a record on every insert and every delete.
  5. Write undo: pop a record and apply the opposite change, putting the cursor back where it was.
  6. Free the list and the undo stack at the end.
  7. Test a long run of changes followed by the same number of undos, which must give back the empty document.

Expected result

A working line editor in which any sequence of edits can be undone step by step, with no memory errors.

How it is evaluated

Ways to improve it