aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2002-12-14 22:10:37 +0000
committerMax Horn2002-12-14 22:10:37 +0000
commitbb210766ce5dc6c160a9acf106c9270a4cb56d94 (patch)
tree0fcd6d193683bd8ed3fdeb54f3aa1291b7874829
parent5c80aeaed6d233f43c9b711c4bc7082b468d4b49 (diff)
downloadscummvm-rg350-bb210766ce5dc6c160a9acf106c9270a4cb56d94.tar.gz
scummvm-rg350-bb210766ce5dc6c160a9acf106c9270a4cb56d94.tar.bz2
scummvm-rg350-bb210766ce5dc6c160a9acf106c9270a4cb56d94.zip
scroll to caret if user types
svn-id: r5968
-rw-r--r--gui/console.cpp15
-rw-r--r--gui/console.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/gui/console.cpp b/gui/console.cpp
index 3c14ecc9a2..1d2f5f2100 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -149,6 +149,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers)
_buffer[_promptEndPos % kBufferSize] = ' ';
_promptEndPos--;
}
+ scrollToCurrent();
draw(); // FIXME - not nice to redraw the full console just for one char!
break;
/*
@@ -194,6 +195,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers)
_buffer[(i+1) % kBufferSize] = _buffer[i % kBufferSize];
_promptEndPos++;
putchar((char)ascii);
+ scrollToCurrent();
}
}
}
@@ -352,3 +354,16 @@ void ConsoleDialog::drawCaret(bool erase)
_caretVisible = !erase;
}
+
+void ConsoleDialog::scrollToCurrent()
+{
+ int line = _currentPos / _lineWidth;
+ int displayLine = line - _scrollLine + _linesPerPage - 1;
+
+ if (displayLine < 0) {
+ // TODO - this should only occur for loong edit lines, though
+ } else if (displayLine >= _linesPerPage) {
+ _scrollLine = _currentPos / _lineWidth;
+ updateScrollBar();
+ }
+}
diff --git a/gui/console.h b/gui/console.h
index 52b6e0ab12..ad764aff5d 100644
--- a/gui/console.h
+++ b/gui/console.h
@@ -77,6 +77,7 @@ protected:
void print(const char *str);
void nextLine();
void updateScrollBar();
+ void scrollToCurrent();
inline int getBufferPos() const { return _currentPos % kBufferSize; }
// Line editing