scroll to caret if user types

svn-id: r5968
This commit is contained in:
Max Horn 2002-12-14 22:10:37 +00:00
parent 5c80aeaed6
commit bb210766ce
2 changed files with 16 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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