diff options
author | Kostas Nakos | 2007-06-02 19:56:18 +0000 |
---|---|---|
committer | Kostas Nakos | 2007-06-02 19:56:18 +0000 |
commit | 299cbcb059879c71947825cd0a094938b435ebdb (patch) | |
tree | e5a56db82e1fd5bebbd72d2443b9ff18ee120602 /engines | |
parent | 8d97729ee85070c001bbdfa69d475c3e4496e304 (diff) | |
download | scummvm-rg350-299cbcb059879c71947825cd0a094938b435ebdb.tar.gz scummvm-rg350-299cbcb059879c71947825cd0a094938b435ebdb.tar.bz2 scummvm-rg350-299cbcb059879c71947825cd0a094938b435ebdb.zip |
better handle mode changes and command line length
svn-id: r27057
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agi/predictive.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp index a43c14a1f2..9f06f9b1ff 100644 --- a/engines/agi/predictive.cpp +++ b/engines/agi/predictive.cpp @@ -273,6 +273,7 @@ processkey: prefix += temp; prefix += " "; _currentCode.clear(); + _currentWord.clear(); memset(repeatcount, 0, MAXWORDLEN); break; } if (active < 9 || active == 11 || active == 15) { // number or backspace @@ -284,10 +285,12 @@ processkey: if (prefix.size()) prefix.deleteLastChar(); } - } else if (active == 15) { // zero - _currentCode += buttonStr[9]; - } else { - _currentCode += buttonStr[active]; + } else if (prefix.size() + _currentCode.size() < MAXWORDLEN - 1) { // don't overflow the dialog line + if (active == 15) { // zero + _currentCode += buttonStr[9]; + } else { + _currentCode += buttonStr[active]; + } } switch (mode) { @@ -334,6 +337,14 @@ processkey: mode++; if (mode > kModeAbc) mode = kModePre; + + // truncate current input at mode change + strncpy(temp, _currentWord.c_str(), _currentCode.size()); + temp[_currentCode.size()] = 0; + prefix += temp; + _currentCode.clear(); + _currentWord.clear(); + memset(repeatcount, 0, MAXWORDLEN); } else { goto press; } |