aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2017-08-05 00:06:22 +0200
committerEugene Sandulenko2017-08-05 00:06:22 +0200
commit2feeefaed3a231128b07feac445f5b7b4c5088e9 (patch)
treeb9cb6d9c18d8e4ac8a8c8eb679e583a1cb7d994f
parent4fea533dfdf222574e78dc835c2977a4e3f4bed9 (diff)
downloadscummvm-rg350-2feeefaed3a231128b07feac445f5b7b4c5088e9.tar.gz
scummvm-rg350-2feeefaed3a231128b07feac445f5b7b4c5088e9.tar.bz2
scummvm-rg350-2feeefaed3a231128b07feac445f5b7b4c5088e9.zip
WAGE: Implemented Cut and Clear actions over MacTextWindow
-rw-r--r--engines/wage/gui-console.cpp52
1 files changed, 33 insertions, 19 deletions
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index 7987f5a4ba..c8b5782108 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -394,46 +394,60 @@ void Gui::actionUndo() {
}
void Gui::actionClear() {
- int startPos = _selectionStartX;
- int endPos = _selectionEndX;
+ const Graphics::SelectedText *s = _consoleWindow->getSelectedText();
+
+ if (s->endY == -1)
+ return;
+
+ int startPos = s->startCol;
+ int endPos = s->endCol;
if (startPos > endPos)
SWAP(startPos, endPos);
- Common::String beg(_lines[_selectionStartY].c_str(), &_lines[_selectionStartY].c_str()[startPos]);
- Common::String end(&_lines[_selectionStartY].c_str()[endPos]);
+ Common::String input = _consoleWindow->getInput();
- _undobuffer = _engine->_inputText;
- _engine->_inputText = beg + end;
- drawInput();
+ Common::String beg(input.c_str(), &input.c_str()[startPos]);
+ Common::String end(&input.c_str()[endPos]);
+
+ _undobuffer = input;
+
+ _consoleWindow->clearInput();
+ _consoleWindow->appendInput(beg + end);
_menu->enableCommand(kMenuEdit, kMenuActionUndo, true);
- _selectionStartY = -1;
- _selectionEndY = -1;
+ _consoleWindow->clearSelection();
}
void Gui::actionCut() {
- int startPos = _selectionStartX;
- int endPos = _selectionEndX;
+ const Graphics::SelectedText *s = _consoleWindow->getSelectedText();
+
+ if (s->endY == -1)
+ return;
+
+ int startPos = s->startCol;
+ int endPos = s->endCol;
if (startPos > endPos)
SWAP(startPos, endPos);
- Common::String beg(_lines[_selectionStartY].c_str(), &_lines[_selectionStartY].c_str()[startPos]);
- Common::String mid(&_lines[_selectionStartY].c_str()[startPos], &_lines[_selectionStartY].c_str()[endPos]);
- Common::String end(&_lines[_selectionStartY].c_str()[endPos]);
+ Common::String input = _consoleWindow->getInput();
- _undobuffer = _engine->_inputText;
- _engine->_inputText = beg + end;
+ Common::String beg(input.c_str(), &input.c_str()[startPos]);
+ Common::String mid(&input.c_str()[startPos], &input.c_str()[endPos]);
+ Common::String end(&input.c_str()[endPos]);
+
+ _undobuffer = input;
+
+ _consoleWindow->clearInput();
+ _consoleWindow->appendInput(beg + end);
_clipboard = mid;
- drawInput();
_menu->enableCommand(kMenuEdit, kMenuActionUndo, true);
_menu->enableCommand(kMenuEdit, kMenuActionPaste, true);
- _selectionStartY = -1;
- _selectionEndY = -1;
+ _consoleWindow->clearSelection();
}
void Gui::disableUndo() {