| 1956 | } |
| 1957 | |
| 1958 | void TextEditor::Paste() |
| 1959 | { |
| 1960 | if (IsReadOnly()) |
| 1961 | return; |
| 1962 | |
| 1963 | auto clipText = ImGui::GetClipboardText(); |
| 1964 | if (clipText != nullptr && strlen(clipText) > 0) |
| 1965 | { |
| 1966 | UndoRecord u; |
| 1967 | u.mBefore = mState; |
| 1968 | |
| 1969 | if (HasSelection()) |
| 1970 | { |
| 1971 | u.mRemoved = GetSelectedText(); |
| 1972 | u.mRemovedStart = mState.mSelectionStart; |
| 1973 | u.mRemovedEnd = mState.mSelectionEnd; |
| 1974 | DeleteSelection(); |
| 1975 | } |
| 1976 | |
| 1977 | u.mAdded = clipText; |
| 1978 | u.mAddedStart = GetActualCursorCoordinates(); |
| 1979 | |
| 1980 | InsertText(clipText); |
| 1981 | |
| 1982 | u.mAddedEnd = GetActualCursorCoordinates(); |
| 1983 | u.mAfter = mState; |
| 1984 | AddUndo(u); |
| 1985 | } |
| 1986 | } |
| 1987 | |
| 1988 | bool TextEditor::CanUndo() const |
| 1989 | { |