MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / add_textbox_undo

Method add_textbox_undo

src/RichTextUserInput.cpp:101–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void 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
116void RichTextUserInput::do_textbox_operation_with_undo(const std::function<void()>& func) {
117 auto prevRichText = textBox->get_rich_text_data();

Callers 1

release_undo_dataMethod · 0.80

Calls 3

get_rich_text_dataMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected