aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorOliver Kiehl2002-12-15 12:56:13 +0000
committerOliver Kiehl2002-12-15 12:56:13 +0000
commit9648ea6f441a44c9c1bf08f013f4066b3408b0ff (patch)
treecf817235549ebb655f490f87d774745ac17ad4da /gui
parent1d40232efbba9ec61c4e3c023e679d594380b062 (diff)
downloadscummvm-rg350-9648ea6f441a44c9c1bf08f013f4066b3408b0ff.tar.gz
scummvm-rg350-9648ea6f441a44c9c1bf08f013f4066b3408b0ff.tar.bz2
scummvm-rg350-9648ea6f441a44c9c1bf08f013f4066b3408b0ff.zip
console now "remembers" the text which the user had typed before using the history
svn-id: r5977
Diffstat (limited to 'gui')
-rw-r--r--gui/console.cpp27
1 files changed, 17 insertions, 10 deletions
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();
}