Add CodeCursor class to manage cursor position, including error animation and completion detection