diff options
author | Eugene Sandulenko | 2016-02-12 19:36:08 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-02-14 17:13:06 +0100 |
commit | 5cea5a4d3aa712c21fbdfd9283c8ce9981086a67 (patch) | |
tree | 8c07317398e7bb0f6d3c42b04eecbca8d6631574 /engines/wage | |
parent | 1b27abafdc17ca4f5855b63cb53712fabd9693cb (diff) | |
download | scummvm-rg350-5cea5a4d3aa712c21fbdfd9283c8ce9981086a67.tar.gz scummvm-rg350-5cea5a4d3aa712c21fbdfd9283c8ce9981086a67.tar.bz2 scummvm-rg350-5cea5a4d3aa712c21fbdfd9283c8ce9981086a67.zip |
WAGE: Implement Cut and Clear actions
Diffstat (limited to 'engines/wage')
-rw-r--r-- | engines/wage/gui-console.cpp | 43 | ||||
-rw-r--r-- | engines/wage/gui.cpp | 8 | ||||
-rw-r--r-- | engines/wage/gui.h | 2 | ||||
-rw-r--r-- | engines/wage/menu.cpp | 4 |
4 files changed, 55 insertions, 2 deletions
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp index 9b02608989..92e61f9617 100644 --- a/engines/wage/gui-console.cpp +++ b/engines/wage/gui-console.cpp @@ -348,6 +348,49 @@ void Gui::actionUndo() { _menu->enableCommand(kMenuEdit, kMenuActionUndo, false); } +void Gui::actionClear() { + int startPos = _selectionStartX; + int endPos = _selectionEndX; + + 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]); + + _undobuffer = _engine->_inputText; + _engine->_inputText = beg + end; + drawInput(); + + _menu->enableCommand(kMenuEdit, kMenuActionUndo, true); + + _selectionStartY = -1; + _selectionEndY = -1; +} + +void Gui::actionCut() { + int startPos = _selectionStartX; + int endPos = _selectionEndX; + + 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]); + + _undobuffer = _engine->_inputText; + _engine->_inputText = beg + end; + _clipboard = mid; + drawInput(); + + _menu->enableCommand(kMenuEdit, kMenuActionUndo, true); + _menu->enableCommand(kMenuEdit, kMenuActionPaste, true); + + _selectionStartY = -1; + _selectionEndY = -1; +} + void Gui::disableUndo() { _menu->enableCommand(kMenuEdit, kMenuActionUndo, false); } diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 309617e8ff..819f5881c4 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -485,6 +485,14 @@ Designed *Gui::mouseUp(int x, int y) { _menu->enableCommand(kMenuEdit, kMenuActionCopy, false); } else { _menu->enableCommand(kMenuEdit, kMenuActionCopy, true); + + bool cutAllowed = false; + + if (_selectionStartY == _selectionEndY && _selectionStartY == _lines.size() - 1) + cutAllowed = true; + + _menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed); + _menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed); } } diff --git a/engines/wage/gui.h b/engines/wage/gui.h index 652e0ff1e4..f679faa5cd 100644 --- a/engines/wage/gui.h +++ b/engines/wage/gui.h @@ -107,6 +107,8 @@ public: void actionCopy(); void actionPaste(); void actionUndo(); + void actionClear(); + void actionCut(); void disableUndo(); private: diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp index aeb5792b44..a65d4dd36a 100644 --- a/engines/wage/menu.cpp +++ b/engines/wage/menu.cpp @@ -519,7 +519,7 @@ void Menu::executeCommand(MenuSubItem *subitem) { _gui->actionUndo(); break; case kMenuActionCut: - warning("STUB: Unhandled shortcut"); + _gui->actionCut(); break; case kMenuActionCopy: _gui->actionCopy(); @@ -528,7 +528,7 @@ void Menu::executeCommand(MenuSubItem *subitem) { _gui->actionPaste(); break; case kMenuActionClear: - warning("STUB: Unhandled shortcut"); + _gui->actionClear(); break; case kMenuActionCommand: |