Implement #9758.
- Add ConsoleOutputView for showing the debugged team's console output. The view presents checkboxes for controlling whether or not stdout and/or stderr output is captured and shown, as well as the ability to clear the current output.
This commit is contained in:
@@ -244,6 +244,7 @@ Application Debugger :
|
||||
# user_interface/gui/team_window
|
||||
BreakpointListView.cpp
|
||||
BreakpointsView.cpp
|
||||
ConsoleOutputView.cpp
|
||||
ExceptionConfigWindow.cpp
|
||||
ImageFunctionsView.cpp
|
||||
ImageListView.cpp
|
||||
|
||||
@@ -28,6 +28,7 @@ enum {
|
||||
MSG_THREAD_STACK_TRACE_CHANGED = 'tstc',
|
||||
MSG_STACK_FRAME_VALUE_RETRIEVED = 'sfvr',
|
||||
MSG_IMAGE_DEBUG_INFO_CHANGED = 'idic',
|
||||
MSG_CONSOLE_OUTPUT_RECEIVED = 'core',
|
||||
MSG_IMAGE_FILE_CHANGED = 'ifch',
|
||||
MSG_FUNCTION_SOURCE_CODE_CHANGED = 'fnsc',
|
||||
MSG_USER_BREAKPOINT_CHANGED = 'ubrc',
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright 2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "ConsoleOutputView.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <Button.h>
|
||||
#include <CheckBox.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <ScrollView.h>
|
||||
#include <String.h>
|
||||
#include <TextView.h>
|
||||
|
||||
|
||||
enum {
|
||||
MSG_CLEAR_OUTPUT = 'clou'
|
||||
};
|
||||
|
||||
|
||||
// #pragma mark - ConsoleOutputView
|
||||
|
||||
|
||||
ConsoleOutputView::ConsoleOutputView()
|
||||
:
|
||||
BGroupView(B_VERTICAL, 0.0f),
|
||||
fStdoutEnabled(NULL),
|
||||
fStderrEnabled(NULL),
|
||||
fConsoleOutput(NULL),
|
||||
fClearButton(NULL)
|
||||
{
|
||||
SetName("ConsoleOutput");
|
||||
}
|
||||
|
||||
|
||||
ConsoleOutputView::~ConsoleOutputView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*static*/ ConsoleOutputView*
|
||||
ConsoleOutputView::Create()
|
||||
{
|
||||
ConsoleOutputView* self = new ConsoleOutputView();
|
||||
|
||||
try {
|
||||
self->_Init();
|
||||
} catch (...) {
|
||||
delete self;
|
||||
throw;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConsoleOutputView::ConsoleOutputReceived(int32 fd, const BString& output)
|
||||
{
|
||||
if (fd == 1 && fStdoutEnabled->Value() != B_CONTROL_ON)
|
||||
return;
|
||||
else if (fd == 2 && fStderrEnabled->Value() != B_CONTROL_ON)
|
||||
return;
|
||||
|
||||
text_run_array run;
|
||||
run.count = 1;
|
||||
run.runs[0].font = be_fixed_font;
|
||||
run.runs[0].offset = 0;
|
||||
run.runs[0].color.red = fd == 1 ? 0 : 192;
|
||||
run.runs[0].color.green = 0;
|
||||
run.runs[0].color.blue = 0;
|
||||
run.runs[0].color.alpha = 255;
|
||||
|
||||
fConsoleOutput->Insert(fConsoleOutput->TextLength(), output.String(),
|
||||
output.Length(), &run);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConsoleOutputView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case MSG_CLEAR_OUTPUT:
|
||||
{
|
||||
fConsoleOutput->SetText("");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BGroupView::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConsoleOutputView::AttachedToWindow()
|
||||
{
|
||||
BGroupView::AttachedToWindow();
|
||||
|
||||
fStdoutEnabled->SetValue(B_CONTROL_ON);
|
||||
fStderrEnabled->SetValue(B_CONTROL_ON);
|
||||
fClearButton->SetTarget(this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConsoleOutputView::LoadSettings(const BMessage& settings)
|
||||
{
|
||||
fStdoutEnabled->SetValue(settings.GetBool("showStdout", true)
|
||||
? B_CONTROL_ON : B_CONTROL_OFF);
|
||||
fStderrEnabled->SetValue(settings.GetBool("showStderr", true)
|
||||
? B_CONTROL_ON : B_CONTROL_OFF);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
ConsoleOutputView::SaveSettings(BMessage& settings)
|
||||
{
|
||||
bool value = fStdoutEnabled->Value() == B_CONTROL_ON;
|
||||
if (settings.AddBool("showStdout", value) != B_OK)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
value = fStderrEnabled->Value() == B_CONTROL_ON;
|
||||
if (settings.AddBool("showStderr", value) != B_OK)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConsoleOutputView::_Init()
|
||||
{
|
||||
BScrollView* consoleScrollView;
|
||||
|
||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0.0f)
|
||||
.Add(consoleScrollView = new BScrollView("console scroll", NULL, 0,
|
||||
true, true), 3.0f)
|
||||
.AddGroup(B_VERTICAL, 0.0f)
|
||||
.SetInsets(B_USE_SMALL_SPACING)
|
||||
.Add(fStdoutEnabled = new BCheckBox("Stdout"))
|
||||
.Add(fStderrEnabled = new BCheckBox("Stderr"))
|
||||
.Add(fClearButton = new BButton("Clear"))
|
||||
.AddGlue()
|
||||
.End()
|
||||
.End();
|
||||
|
||||
consoleScrollView->SetTarget(fConsoleOutput = new BTextView("Console"));
|
||||
|
||||
fClearButton->SetMessage(new BMessage(MSG_CLEAR_OUTPUT));
|
||||
fConsoleOutput->MakeEditable(false);
|
||||
fConsoleOutput->SetStylable(true);
|
||||
fConsoleOutput->SetDoesUndo(false);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef CONSOLE_OUTPUT_VIEW_H_
|
||||
#define CONSOLE_OUTPUT_VIEW_H_
|
||||
|
||||
|
||||
#include <GroupView.h>
|
||||
|
||||
|
||||
class BButton;
|
||||
class BCheckBox;
|
||||
class BTextView;
|
||||
|
||||
|
||||
class ConsoleOutputView : public BGroupView {
|
||||
public:
|
||||
ConsoleOutputView();
|
||||
~ConsoleOutputView();
|
||||
|
||||
static ConsoleOutputView* Create();
|
||||
// throws
|
||||
|
||||
void ConsoleOutputReceived(
|
||||
int32 fd, const BString& output);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void AttachedToWindow();
|
||||
|
||||
void LoadSettings(const BMessage& settings);
|
||||
status_t SaveSettings(BMessage& settings);
|
||||
|
||||
private:
|
||||
void _Init();
|
||||
|
||||
private:
|
||||
BCheckBox* fStdoutEnabled;
|
||||
BCheckBox* fStderrEnabled;
|
||||
BTextView* fConsoleOutput;
|
||||
BButton* fClearButton;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CONSOLE_OUTPUT_VIEW_H
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <AutoLocker.h>
|
||||
|
||||
#include "Breakpoint.h"
|
||||
#include "ConsoleOutputView.h"
|
||||
#include "CpuState.h"
|
||||
#include "DisassembledCode.h"
|
||||
#include "ExceptionConfigWindow.h"
|
||||
@@ -116,6 +117,14 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener)
|
||||
fStepOverButton(NULL),
|
||||
fStepIntoButton(NULL),
|
||||
fStepOutButton(NULL),
|
||||
fMenuBar(NULL),
|
||||
fSourcePathView(NULL),
|
||||
fConsoleOutputView(NULL),
|
||||
fFunctionSplitView(NULL),
|
||||
fSourceSplitView(NULL),
|
||||
fImageSplitView(NULL),
|
||||
fThreadSplitView(NULL),
|
||||
fConsoleSplitView(NULL),
|
||||
fExceptionConfigWindow(NULL),
|
||||
fInspectorWindow(NULL),
|
||||
fFilePanel(NULL)
|
||||
@@ -429,6 +438,18 @@ TeamWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_CONSOLE_OUTPUT_RECEIVED:
|
||||
{
|
||||
int32 fd;
|
||||
BString output;
|
||||
if (message->FindInt32("fd", &fd) != B_OK
|
||||
|| message->FindString("output", &output) != B_OK) {
|
||||
break;
|
||||
}
|
||||
fConsoleOutputView->ConsoleOutputReceived(fd, output);
|
||||
break;
|
||||
}
|
||||
|
||||
case MSG_USER_BREAKPOINT_CHANGED:
|
||||
{
|
||||
UserBreakpoint* breakpoint;
|
||||
@@ -505,6 +526,9 @@ TeamWindow::LoadSettings(const GuiTeamUiSettings* settings)
|
||||
if (teamWindowSettings.FindMessage("threadSplit", &archive) == B_OK)
|
||||
GuiSettingsUtils::UnarchiveSplitView(archive, fThreadSplitView);
|
||||
|
||||
if (teamWindowSettings.FindMessage("consoleSplit", &archive) == B_OK)
|
||||
GuiSettingsUtils::UnarchiveSplitView(archive, fConsoleSplitView);
|
||||
|
||||
if (teamWindowSettings.FindMessage("imageListView", &archive) == B_OK)
|
||||
fImageListView->LoadSettings(archive);
|
||||
|
||||
@@ -526,6 +550,9 @@ TeamWindow::LoadSettings(const GuiTeamUiSettings* settings)
|
||||
if (teamWindowSettings.FindMessage("breakpointsView", &archive) == B_OK)
|
||||
fBreakpointsView->LoadSettings(archive);
|
||||
|
||||
if (teamWindowSettings.FindMessage("consoleOutputView", &archive) == B_OK)
|
||||
fConsoleOutputView->LoadSettings(archive);
|
||||
|
||||
fUiSettings = *settings;
|
||||
|
||||
return B_OK;
|
||||
@@ -570,6 +597,11 @@ TeamWindow::SaveSettings(GuiTeamUiSettings* settings)
|
||||
if (teamWindowSettings.AddMessage("threadSplit", &archive))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
if (GuiSettingsUtils::ArchiveSplitView(archive, fConsoleSplitView) != B_OK)
|
||||
return B_NO_MEMORY;
|
||||
if (teamWindowSettings.AddMessage("consoleSplit", &archive))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
if (fImageListView->SaveSettings(archive) != B_OK)
|
||||
return B_NO_MEMORY;
|
||||
if (teamWindowSettings.AddMessage("imageListView", &archive))
|
||||
@@ -605,6 +637,11 @@ TeamWindow::SaveSettings(GuiTeamUiSettings* settings)
|
||||
if (teamWindowSettings.AddMessage("breakpointsView", &archive))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
if (fConsoleOutputView->SaveSettings(archive) != B_OK)
|
||||
return B_NO_MEMORY;
|
||||
if (teamWindowSettings.AddMessage("consoleOutputView", &archive))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
if (!settings->AddSettings("teamWindow", teamWindowSettings))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@@ -763,6 +800,16 @@ TeamWindow::ImageDebugInfoChanged(const Team::ImageEvent& event)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamWindow::ConsoleOutputReceived(const Team::ConsoleOutputEvent& event)
|
||||
{
|
||||
BMessage message(MSG_CONSOLE_OUTPUT_RECEIVED);
|
||||
message.AddInt32("fd", event.Descriptor());
|
||||
message.AddString("output", event.Output());
|
||||
PostMessage(&message);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamWindow::UserBreakpointChanged(const Team::UserBreakpointEvent& event)
|
||||
{
|
||||
@@ -838,6 +885,11 @@ TeamWindow::_Init()
|
||||
.End()
|
||||
.Add(fLocalsTabView = new BTabView("locals view"))
|
||||
.End()
|
||||
.AddSplit(B_VERTICAL, splitSpacing)
|
||||
.GetSplitView(&fConsoleSplitView)
|
||||
.SetInsets(0.0)
|
||||
.Add(fConsoleOutputView = ConsoleOutputView::Create())
|
||||
.End()
|
||||
.End();
|
||||
|
||||
// add source view
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2010-2011, Rene Gollent, [email protected].
|
||||
* Copyright 2010-2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef TEAM_WINDOW_H
|
||||
@@ -29,6 +29,7 @@ class BMenuBar;
|
||||
class BSplitView;
|
||||
class BStringView;
|
||||
class BTabView;
|
||||
class ConsoleOutputView;
|
||||
class ExceptionConfigWindow;
|
||||
class Image;
|
||||
class InspectorWindow;
|
||||
@@ -129,6 +130,8 @@ private:
|
||||
const Team::ThreadEvent& event);
|
||||
virtual void ImageDebugInfoChanged(
|
||||
const Team::ImageEvent& event);
|
||||
virtual void ConsoleOutputReceived(
|
||||
const Team::ConsoleOutputEvent& event);
|
||||
virtual void UserBreakpointChanged(
|
||||
const Team::UserBreakpointEvent& event);
|
||||
virtual void WatchpointChanged(
|
||||
@@ -195,10 +198,12 @@ private:
|
||||
BButton* fStepOutButton;
|
||||
BMenuBar* fMenuBar;
|
||||
BStringView* fSourcePathView;
|
||||
ConsoleOutputView* fConsoleOutputView;
|
||||
BSplitView* fFunctionSplitView;
|
||||
BSplitView* fSourceSplitView;
|
||||
BSplitView* fImageSplitView;
|
||||
BSplitView* fThreadSplitView;
|
||||
BSplitView* fConsoleSplitView;
|
||||
ExceptionConfigWindow* fExceptionConfigWindow;
|
||||
InspectorWindow* fInspectorWindow;
|
||||
GuiTeamUiSettings fUiSettings;
|
||||
|
||||
Reference in New Issue
Block a user