Add multiple levels of undo/redo.

Allows undo/redo using --undo and --redo commands. Currently preallocates
large surfaces to save entire drawing state, wastes memory.