From 9b0d6d08986415923ecf0cb56760edc4d45035c1 Mon Sep 17 00:00:00 2001 From: Kostas Nakos Date: Sat, 2 Jun 2007 20:39:04 +0000 Subject: implement most-recently-used scheme for dictionary words svn-id: r27058 --- engines/agi/predictive.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp index 9f06f9b1ff..f6319630d3 100644 --- a/engines/agi/predictive.cpp +++ b/engines/agi/predictive.cpp @@ -250,8 +250,8 @@ bool AgiEngine::predictiveDialog(void) { key = doPollKeyboard(); switch (key) { case KEY_ENTER: - rc = true; - goto press; + active = 13; + goto processkey; case KEY_ESCAPE: rc = false; goto getout; @@ -266,10 +266,14 @@ processkey: needRefresh = true; lastactive = active; if (active == 15 && mode != kModeNum) { // Space - strncpy(temp, _currentWord.c_str(), _currentCode.size()); + // bring MRU word at the top of the list when changing words + if (mode == kModePre && _activeTreeNode && _activeTreeNode->words.size() > 1 && _wordNumber != 0) { + String tmpstr = _activeTreeNode->words.remove_at(_wordNumber); + _activeTreeNode->words.insert_at(0, tmpstr); + } + strncpy(temp, _currentWord.c_str(), _currentCode.size()); temp[_currentCode.size()] = 0; - prefix += temp; prefix += " "; _currentCode.clear(); @@ -331,6 +335,12 @@ processkey: } else if (active == 10) { // add debug(0, "add"); } else if (active == 13) { // Ok + // bring MRU word at the top of the list when ok'ed out of the dialog + if (mode == kModePre && _activeTreeNode && _activeTreeNode->words.size() > 1 && _wordNumber != 0) { + String tmpstr = _activeTreeNode->words.remove_at(_wordNumber); + _activeTreeNode->words.insert_at(0, tmpstr); + } + rc = true; goto press; } else if (active == 14) { // Mode -- cgit v1.2.3