Add support for auto-scrolling.

- If the console output is currently at the bottom, any new output will automatically be scrolled into view. Otherwise,
its current position will be maintained.
This commit is contained in:
Rene Gollent 2013-06-28 18:29:26 -04:00
parent b8b4219f26
commit 277945a648

View File

@ -74,8 +74,19 @@ ConsoleOutputView::ConsoleOutputReceived(int32 fd, const BString& output)
run.runs[0].color.blue = 0;
run.runs[0].color.alpha = 255;
bool autoScroll = false;
BScrollBar* scroller = fConsoleOutput->ScrollBar(B_VERTICAL);
float min, max;
scroller->GetRange(&min, &max);
if (min == max || scroller->Value() == max)
autoScroll = true;
fConsoleOutput->Insert(fConsoleOutput->TextLength(), output.String(),
output.Length(), &run);
if (autoScroll) {
scroller->GetRange(&min, &max);
fConsoleOutput->ScrollTo(0.0, max);
}
}