From 9648ea6f441a44c9c1bf08f013f4066b3408b0ff Mon Sep 17 00:00:00 2001 From: Oliver Kiehl Date: Sun, 15 Dec 2002 12:56:13 +0000 Subject: console now "remembers" the text which the user had typed before using the history svn-id: r5977 --- gui/console.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'gui') diff --git a/gui/console.cpp b/gui/console.cpp index e97fecef9f..c2abf26438 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -331,6 +331,13 @@ void ConsoleDialog::historyScroll(int direction) { if (_historySize == 0) return; + + if (_historyLine == 0 && direction > 0) { + int i; + for (i = 0; i < _promptEndPos - _promptStartPos; i++) + _history[_historyIndex][i] = _buffer[_promptStartPos + i]; + _history[_historyIndex][i] = '\0'; + } // Advance to the next line in the history int line = _historyLine + direction; @@ -350,17 +357,17 @@ void ConsoleDialog::historyScroll(int direction) scrollToCurrent(); // Print the text from the history - if (_historyLine > 0) { - int idx = (_historyIndex - _historyLine + _historySize) % _historySize; - for (int i = 0; i < kLineBufferSize && _history[idx][i] != '\0'; i++) - putcharIntern(_history[idx][i]); - _promptEndPos = _currentPos; + int idx; + if (_historyLine > 0) + idx = (_historyIndex - _historyLine + _historySize) % _historySize; + else + idx = _historyIndex; + for (int i = 0; i < kLineBufferSize && _history[idx][i] != '\0'; i++) + putcharIntern(_history[idx][i]); + _promptEndPos = _currentPos; - // Ensure once more the caret is visible (in case of very long history entries) - scrollToCurrent(); - } else { - // TODO print the text which the user had typed before using the history - } + // Ensure once more the caret is visible (in case of very long history entries) + scrollToCurrent(); draw(); } -- cgit v1.2.3