From 277945a648f560f98910198d96a7ef34e8f86a51 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 28 Jun 2013 18:29:26 -0400 Subject: [PATCH] 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. --- .../gui/team_window/ConsoleOutputView.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/apps/debugger/user_interface/gui/team_window/ConsoleOutputView.cpp b/src/apps/debugger/user_interface/gui/team_window/ConsoleOutputView.cpp index 618f25af29..cc5876fa24 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ConsoleOutputView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ConsoleOutputView.cpp @@ -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); + } }