diff options
author | Marisa-Chan | 2014-06-13 21:43:04 +0700 |
---|---|---|
committer | Marisa-Chan | 2014-06-13 21:43:04 +0700 |
commit | 45589950c0fb1a449351e6a00ef10d42290d8bae (patch) | |
tree | 44e4eedcb7e69d5fc386155b000ed038af07251d /gui/console.cpp | |
parent | 48360645dcd5f8fddb135b6e31ae5cae4be8d77f (diff) | |
parent | 5c005ad3a3f1df0bc968c85c1cf0fc48e36ab0b2 (diff) | |
download | scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.tar.gz scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.tar.bz2 scummvm-rg350-45589950c0fb1a449351e6a00ef10d42290d8bae.zip |
Merge remote-tracking branch 'upstream/master' into zvision
Conflicts:
engines/zvision/animation/rlf_animation.cpp
engines/zvision/animation_control.h
engines/zvision/core/console.cpp
engines/zvision/core/events.cpp
engines/zvision/cursors/cursor.cpp
engines/zvision/cursors/cursor_manager.cpp
engines/zvision/cursors/cursor_manager.h
engines/zvision/fonts/truetype_font.cpp
engines/zvision/graphics/render_manager.cpp
engines/zvision/graphics/render_manager.h
engines/zvision/inventory/inventory_manager.h
engines/zvision/inventory_manager.h
engines/zvision/meta_animation.h
engines/zvision/module.mk
engines/zvision/scripting/actions.cpp
engines/zvision/scripting/control.h
engines/zvision/scripting/controls/animation_control.cpp
engines/zvision/scripting/controls/animation_control.h
engines/zvision/scripting/controls/input_control.cpp
engines/zvision/scripting/controls/lever_control.cpp
engines/zvision/scripting/controls/timer_node.cpp
engines/zvision/scripting/controls/timer_node.h
engines/zvision/scripting/puzzle.h
engines/zvision/scripting/scr_file_handling.cpp
engines/zvision/scripting/script_manager.cpp
engines/zvision/scripting/script_manager.h
engines/zvision/sidefx.cpp
engines/zvision/sound/zork_raw.cpp
engines/zvision/sound/zork_raw.h
engines/zvision/video/video.cpp
engines/zvision/video/zork_avi_decoder.h
engines/zvision/zvision.cpp
engines/zvision/zvision.h
Diffstat (limited to 'gui/console.cpp')
-rw-r--r-- | gui/console.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/gui/console.cpp b/gui/console.cpp index 49e2fccd98..4cdad41f5f 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #include "gui/console.h" @@ -82,8 +83,6 @@ ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) _historyIndex = 0; _historyLine = 0; _historySize = 0; - for (int i = 0; i < kHistorySize; i++) - _history[i][0] = '\0'; // Display greetings & prompt print(gScummVMFullVersion); @@ -274,24 +273,19 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) { if (len > 0) { - // We have to allocate the string buffer with new, since VC++ sadly does not - // comply to the C++ standard, so we can't use a dynamic sized stack array. - char *str = new char[len + 1]; + Common::String str; // Copy the user input to str for (i = 0; i < len; i++) - str[i] = buffer(_promptStartPos + i); - str[len] = '\0'; + str.insertChar(buffer(_promptStartPos + i), i); // Add the input to the history addToHistory(str); // Pass it to the input callback, if any if (_callbackProc) - keepRunning = (*_callbackProc)(this, str, _callbackRefCon); + keepRunning = (*_callbackProc)(this, str.c_str(), _callbackRefCon); - // Get rid of the string buffer - delete[] str; } print(PROMPT); @@ -575,8 +569,8 @@ void ConsoleDialog::killLastWord() { } } -void ConsoleDialog::addToHistory(const char *str) { - strcpy(_history[_historyIndex], str); +void ConsoleDialog::addToHistory(const Common::String &str) { + _history[_historyIndex] = str; _historyIndex = (_historyIndex + 1) % kHistorySize; _historyLine = 0; if (_historySize < kHistorySize) @@ -590,8 +584,7 @@ void ConsoleDialog::historyScroll(int direction) { if (_historyLine == 0 && direction > 0) { int i; for (i = 0; i < _promptEndPos - _promptStartPos; i++) - _history[_historyIndex][i] = buffer(_promptStartPos + i); - _history[_historyIndex][i] = '\0'; + _history[_historyIndex].insertChar(buffer(_promptStartPos + i), i); } // Advance to the next line in the history @@ -617,7 +610,8 @@ void ConsoleDialog::historyScroll(int direction) { idx = (_historyIndex - _historyLine + _historySize) % _historySize; else idx = _historyIndex; - for (int i = 0; i < kLineBufferSize && _history[idx][i] != '\0'; i++) + int length = _history[idx].size(); + for (int i = 0; i < length; i++) printCharIntern(_history[idx][i]); _promptEndPos = _currentPos; |