hrev48103 adds 2 changesets to branch 'master' old head: 1714eaf29e7b63fec1728d5c03cbec366c0eba20 new head: 4501776089faeb8601254383c838f0b24e250c13 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=4501776+%5E1714eaf ---------------------------------------------------------------------------- cda38af: Debugger: Initial GUI for expression evaluation. - Add a simple interface window for expression evaluation. Not yet accessible from the team window. 4501776: Debugger: Style fixes. [ Rene Gollent <rene@xxxxxxxxxxx> ] ---------------------------------------------------------------------------- 4 files changed, 184 insertions(+) src/apps/debugger/Jamfile | 1 + .../team_window/ExpressionEvaluationWindow.cpp | 128 +++++++++++++++++++ .../gui/team_window/ExpressionEvaluationWindow.h | 52 ++++++++ .../gui/team_window/WatchPromptWindow.cpp | 3 + ############################################################################ Commit: cda38afb68290ad9158ee270158b8c03f69b7b08 URL: http://cgit.haiku-os.org/haiku/commit/?id=cda38af Author: Rene Gollent <rene@xxxxxxxxxxx> Date: Sun Oct 26 18:07:28 2014 UTC Debugger: Initial GUI for expression evaluation. - Add a simple interface window for expression evaluation. Not yet accessible from the team window. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 300b372..ca763a8 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -264,6 +264,7 @@ Application Debugger : BreakpointListView.cpp BreakpointsView.cpp ConsoleOutputView.cpp + ExpressionEvaluationWindow.cpp ImageFunctionsView.cpp ImageListView.cpp RegistersView.cpp diff --git a/src/apps/debugger/user_interface/gui/team_window/ExpressionEvaluationWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/ExpressionEvaluationWindow.cpp new file mode 100644 index 0000000..fa66aa1 --- /dev/null +++ b/src/apps/debugger/user_interface/gui/team_window/ExpressionEvaluationWindow.cpp @@ -0,0 +1,128 @@ +/* + * Copyright 2014, Rene Gollent, rene@xxxxxxxxxxx. + * Distributed under the terms of the MIT License. + */ +#include "ExpressionEvaluationWindow.h" + +#include <Alert.h> +#include <Button.h> +#include <LayoutBuilder.h> +#include <String.h> +#include <StringView.h> +#include <TextControl.h> + +#include "MessageCodes.h" +#include "SourceLanguage.h" +#include "UserInterface.h" +#include "Value.h" + + +enum { + MSG_EVALUATE_EXPRESSION = 'evex' +}; + + +ExpressionEvaluationWindow::ExpressionEvaluationWindow( + SourceLanguage* language, UserInterfaceListener* listener) + : + BWindow(BRect(), "Evaluate Expression", B_FLOATING_WINDOW, + B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), + fLanguage(language), + fListener(listener) +{ + fLanguage->AcquireReference(); +} + + +ExpressionEvaluationWindow::~ExpressionEvaluationWindow() +{ + fLanguage->ReleaseReference(); +} + + +ExpressionEvaluationWindow* +ExpressionEvaluationWindow::Create(SourceLanguage* language, + UserInterfaceListener* listener) +{ + ExpressionEvaluationWindow* self = new ExpressionEvaluationWindow( + language, listener); + + try { + self->_Init(); + } catch (...) { + delete self; + throw; + } + + return self; + +} + + +void +ExpressionEvaluationWindow::_Init() +{ + fExpressionInput = new BTextControl("Expression:", NULL, NULL); + BLayoutItem* labelItem = fExpressionInput->CreateLabelLayoutItem(); + labelItem->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + BLayoutBuilder::Group<>(this, B_VERTICAL) + .SetInsets(B_USE_DEFAULT_SPACING) + .AddGroup(B_HORIZONTAL, 4.0f) + .Add(labelItem) + .Add(fExpressionInput->CreateTextViewLayoutItem()) + .End() + .AddGroup(B_HORIZONTAL, 4.0f) + .Add(new BStringView("OutputLabelView", "Result:")) + .Add((fExpressionOutput = new BStringView("ExpressionOutputView", + NULL))) + .End() + .AddGroup(B_HORIZONTAL, 4.0f) + .AddGlue() + .Add((fEvaluateButton = new BButton("Evaluate", + new BMessage(MSG_EVALUATE_EXPRESSION)))) + .End(); + + fEvaluateButton->SetTarget(this); + +} + + +void +ExpressionEvaluationWindow::Show() +{ + CenterOnScreen(); + BWindow::Show(); +} + + +void +ExpressionEvaluationWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case MSG_EVALUATE_EXPRESSION: + { + Value* value = NULL; + status_t error = fLanguage->EvaluateExpression( + fExpressionInput->TextView()->Text(), value); + if (error != B_OK) { + BString errorText; + errorText.SetToFormat("Failed to evaluate expression: %s", + strerror(error)); + BAlert* alert = new(std::nothrow) BAlert("Evaluate Expression", + errorText.String(), "Close"); + if (alert != NULL) + alert->Go(); + break; + } + + BString valueText; + value->ToString(valueText); + fExpressionOutput->SetText(valueText); + break; + } + default: + BWindow::MessageReceived(message); + break; + } + +} diff --git a/src/apps/debugger/user_interface/gui/team_window/ExpressionEvaluationWindow.h b/src/apps/debugger/user_interface/gui/team_window/ExpressionEvaluationWindow.h new file mode 100644 index 0000000..ba28df4 --- /dev/null +++ b/src/apps/debugger/user_interface/gui/team_window/ExpressionEvaluationWindow.h @@ -0,0 +1,52 @@ +/* + * Copyright 2014, Rene Gollent, rene@xxxxxxxxxxx. + * Distributed under the terms of the MIT License. + */ +#ifndef EXPRESSION_EVALUATION_WINDOW_H +#define EXPRESSION_EVALUATION_WINDOW_H + + +#include <Window.h> + +#include "types/Types.h" + + +class BButton; +class BStringView; +class BTextControl; +class SourceLanguage; +class UserInterfaceListener; + + +class ExpressionEvaluationWindow : public BWindow +{ +public: + ExpressionEvaluationWindow( + SourceLanguage* language, + UserInterfaceListener* listener); + + ~ExpressionEvaluationWindow(); + + static ExpressionEvaluationWindow* Create( + SourceLanguage* language, + UserInterfaceListener* listener); + // throws + + + virtual void MessageReceived(BMessage* message); + + virtual void Show(); + +private: + void _Init(); + + +private: + SourceLanguage* fLanguage; + BTextControl* fExpressionInput; + BStringView* fExpressionOutput; + BButton* fEvaluateButton; + UserInterfaceListener* fListener; +}; + +#endif // EXPRESSION_EVALUATION_WINDOW_H ############################################################################ Revision: hrev48103 Commit: 4501776089faeb8601254383c838f0b24e250c13 URL: http://cgit.haiku-os.org/haiku/commit/?id=4501776 Author: Rene Gollent <rene@xxxxxxxxxxx> Date: Sun Oct 26 18:08:50 2014 UTC Debugger: Style fixes. ---------------------------------------------------------------------------- diff --git a/src/apps/debugger/user_interface/gui/team_window/WatchPromptWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/WatchPromptWindow.cpp index 2363e28..4bef8b2 100644 --- a/src/apps/debugger/user_interface/gui/team_window/WatchPromptWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/WatchPromptWindow.cpp @@ -64,6 +64,7 @@ WatchPromptWindow::Create(Architecture* architecture, target_addr_t address, } + void WatchPromptWindow::_Init() { @@ -125,6 +126,7 @@ WatchPromptWindow::_Init() fTypeField->Menu()->ItemAt(fInitialType)->SetMarked(true); } + void WatchPromptWindow::Show() { @@ -132,6 +134,7 @@ WatchPromptWindow::Show() BWindow::Show(); } + void WatchPromptWindow::MessageReceived(BMessage* message) {