Build a tiny text editor with full undo and redo.
Implement a class Editor with:
text: the current text (starts empty)insert(pos, s): insert s at index posdelete(pos, n): delete n characters starting at pos (clipped to the end of the text)undo() and redo(): return False if there's nothing to undo or redo, True otherwise. Any new edit clears the redo stack.begin_group() / end_group(): edits between them undo and redo as a single step (for example, a find-and-replace across the document)Store each edit as a command object that knows how to reverse itself. Don't store copies of the whole text.