| 99 | } |
| 100 | |
| 101 | void RichTextUserInput::add_textbox_undo(const RichText::TextBox::Cursor& prevCursor, const RichText::TextData& prevRichText) { |
| 102 | textboxUndo.push({[&, prevCursor = prevCursor, prevRichText = prevRichText]() { |
| 103 | textBox->set_rich_text_data_for_undo_redo(prevRichText); |
| 104 | cursor->selectionBeginPos = cursor->selectionEndPos = cursor->pos = std::max(prevCursor.selectionEndPos, prevCursor.selectionBeginPos); |
| 105 | cursor->previousX = std::nullopt; |
| 106 | return true; |
| 107 | }, |
| 108 | [&, currentCursor = *cursor, currentRichText = textBox->get_rich_text_data()]() { |
| 109 | textBox->set_rich_text_data_for_undo_redo(currentRichText); |
| 110 | cursor->selectionBeginPos = cursor->selectionEndPos = cursor->pos = std::max(currentCursor.selectionEndPos, currentCursor.selectionBeginPos); |
| 111 | cursor->previousX = std::nullopt; |
| 112 | return true; |
| 113 | }}); |
| 114 | } |
| 115 | |
| 116 | void RichTextUserInput::do_textbox_operation_with_undo(const std::function<void()>& func) { |
| 117 | auto prevRichText = textBox->get_rich_text_data(); |
no test coverage detected