Undo Stack Spell

You're building a text editor that supports undo/redo. Each user action (insert text, delete text, change formatting) needs to be recorded and reversible. Which behavioral pattern directly models this?

A

State: model the editor as a state machine that transitions between editing modes

B

Strategy: encapsulate each editing algorithm and swap them interchangeably

C

Command: encapsulate each action as an object with execute() and undo() methods, storing them in a history stack

D

Memento: capture the editor's entire state before each action and restore it to undo