diff options
author | Max Horn | 2002-12-14 22:18:00 +0000 |
---|---|---|
committer | Max Horn | 2002-12-14 22:18:00 +0000 |
commit | 2f30b76ceb4859de37efad2eb9cc2413bd4cde84 (patch) | |
tree | 8ed7b69bb56372a7686ed8e909425c0011c092fc /gui | |
parent | bb210766ce5dc6c160a9acf106c9270a4cb56d94 (diff) | |
download | scummvm-rg350-2f30b76ceb4859de37efad2eb9cc2413bd4cde84.tar.gz scummvm-rg350-2f30b76ceb4859de37efad2eb9cc2413bd4cde84.tar.bz2 scummvm-rg350-2f30b76ceb4859de37efad2eb9cc2413bd4cde84.zip |
retrieve the input and (for now) print it back to the console
svn-id: r5969
Diffstat (limited to 'gui')
-rw-r--r-- | gui/console.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/gui/console.cpp b/gui/console.cpp index 1d2f5f2100..5e9316bd21 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -123,18 +123,29 @@ void ConsoleDialog::handleMouseWheel(int x, int y, int direction) void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { + int i; + switch (keycode) { case '\n': // enter/return - case '\r': + case '\r': { if (_caretVisible) drawCaret(true); - + nextLine(); + + int len = _promptEndPos - _promptStartPos; + char str[len + 1]; + for (i = 0; i < len; i++) + str[i] = _buffer[(_promptStartPos + i) % kBufferSize]; + str[len] = 0; + printf("You entered '%s'\n", str); + print(PROMPT); _promptStartPos = _promptEndPos = _currentPos; draw(); break; + } case 27: // escape close(); break; @@ -144,7 +155,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) if (_currentPos > _promptStartPos) { _currentPos--; - for (int i = _currentPos; i < _promptEndPos; i++) + for (i = _currentPos; i < _promptEndPos; i++) _buffer[i % kBufferSize] = _buffer[(i+1) % kBufferSize]; _buffer[_promptEndPos % kBufferSize] = ' '; _promptEndPos--; @@ -191,7 +202,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) } else if (modifiers == OSystem::KBD_CTRL) { specialKeys(keycode); } else if (isprint((char)ascii)) { - for (int i = _promptEndPos-1; i >= _currentPos; i--) + for (i = _promptEndPos-1; i >= _currentPos; i--) _buffer[(i+1) % kBufferSize] = _buffer[i % kBufferSize]; _promptEndPos++; putchar((char)ascii); |