| 1041 | } |
| 1042 | |
| 1043 | bool EditBox::commandRedo() |
| 1044 | { |
| 1045 | if (mVectorRedoChangeInfo.empty()) |
| 1046 | return false; |
| 1047 | |
| 1048 | // сбрасываем выделение |
| 1049 | resetSelect(); |
| 1050 | |
| 1051 | // save last undo info |
| 1052 | VectorChangeInfo info = mVectorRedoChangeInfo.back(); |
| 1053 | // move redo info to undo |
| 1054 | mVectorRedoChangeInfo.pop_back(); |
| 1055 | mVectorUndoChangeInfo.push_back(info); |
| 1056 | |
| 1057 | UString::utf32string text = getRealString().asUTF32(); |
| 1058 | |
| 1059 | // apply redo |
| 1060 | for (const auto& change : info) |
| 1061 | { |
| 1062 | switch (change.type) |
| 1063 | { |
| 1064 | case TextCommandInfo::COMMAND_INSERT: text.insert(change.start, change.text); break; |
| 1065 | case TextCommandInfo::COMMAND_ERASE: text.erase(change.start, change.text.size()); break; |
| 1066 | case TextCommandInfo::COMMAND_POSITION: |
| 1067 | mCursorPosition = change.redo; |
| 1068 | mTextLength = change.length; |
| 1069 | break; |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | setRealString(UString(text)); |
| 1074 | |
| 1075 | // restore cursor position |
| 1076 | if (mClientText != nullptr) |
| 1077 | mClientText->setCursorPosition(mCursorPosition); |
| 1078 | updateSelectText(); |
| 1079 | |
| 1080 | eventEditTextChange(this); |
| 1081 | |
| 1082 | return true; |
| 1083 | } |
| 1084 | |
| 1085 | void EditBox::saveInHistory(VectorChangeInfo* _info) |
| 1086 | { |