diff options
author | Max Horn | 2003-05-03 21:49:19 +0000 |
---|---|---|
committer | Max Horn | 2003-05-03 21:49:19 +0000 |
commit | 975d325a924a5a55d87d1ed4c3fd1cfb1de9e876 (patch) | |
tree | 3132bc563701cbcc636718bca65d9da9e6e1fc46 /gui/console.cpp | |
parent | fc9100c8415e03e98e8111ecc54713fb94691f6b (diff) | |
download | scummvm-rg350-975d325a924a5a55d87d1ed4c3fd1cfb1de9e876.tar.gz scummvm-rg350-975d325a924a5a55d87d1ed4c3fd1cfb1de9e876.tar.bz2 scummvm-rg350-975d325a924a5a55d87d1ed4c3fd1cfb1de9e876.zip |
Patch #731613: debugger tab-completion (thanks, Willem!)
svn-id: r7293
Diffstat (limited to 'gui/console.cpp')
-rw-r--r-- | gui/console.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/gui/console.cpp b/gui/console.cpp index f531629d7d..c52c54a823 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -159,7 +159,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { // comply to the C++ standard, so we can't use a dynamic sized stack array. char *str = new char[len + 1]; - // Copy the user intput to str + // Copy the user input to str for (i = 0; i < len; i++) str[i] = _buffer[(_promptStartPos + i) % kBufferSize]; str[len] = '\0'; @@ -197,6 +197,33 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { scrollToCurrent(); draw(); // FIXME - not nice to redraw the full console just for one char! break; + case 9: // tab + { + if (_completionCallbackProc) { + int len = _currentPos - _promptStartPos; + assert(len >= 0); + char *str = new char[len + 1]; + + // Copy the user input to str + for (i = 0; i < len; i++) + str[i] = _buffer[(_promptStartPos + i) % kBufferSize]; + str[len] = '\0'; + + char *completion = 0; + if ((*_completionCallbackProc)(this, str, completion, + _callbackRefCon)) + { + if (_caretVisible) + drawCaret(true); + insertIntoPrompt(completion); + scrollToCurrent(); + draw(); + delete[] completion; + } + delete[] str; + } + break; + } case 127: killChar(); draw(); @@ -255,6 +282,18 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { } } +void ConsoleDialog::insertIntoPrompt(const char* str) +{ + unsigned int l = strlen(str); + for (int i = _promptEndPos-1; i >= _currentPos; i--) + _buffer[(i + l) % kBufferSize] = + _buffer[i % kBufferSize]; + for (unsigned int j = 0; j < l; ++j) { + _promptEndPos++; + putcharIntern(str[j]); + } +} + void ConsoleDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case kSetPositionCmd: |