diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 8e489e862b..0f626b57cd 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -174,6 +174,7 @@ Application Debugger : # user_interface/cli CliCommand.cpp + CliContext.cpp CommandLineUserInterface.cpp # user_interface/gui diff --git a/src/apps/debugger/user_interface/cli/CliContext.cpp b/src/apps/debugger/user_interface/cli/CliContext.cpp new file mode 100644 index 0000000000..cb099bf4ae --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliContext.cpp @@ -0,0 +1,32 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include "CliContext.h" + +#include "UserInterface.h" + + +CliContext::CliContext() + : + fTeam(NULL), + fListener(NULL) +{ +} + + +void +CliContext::Init(Team* team, UserInterfaceListener* listener) +{ + fTeam = team; + fListener = listener; +} + + +void +CliContext::QuitSession() +{ + fListener->UserInterfaceQuitRequested(); +} diff --git a/src/apps/debugger/user_interface/cli/CliContext.h b/src/apps/debugger/user_interface/cli/CliContext.h index df318160a9..93d06af3fa 100644 --- a/src/apps/debugger/user_interface/cli/CliContext.h +++ b/src/apps/debugger/user_interface/cli/CliContext.h @@ -6,7 +6,25 @@ #define CLI_CONTEXT_H +class Team; +class UserInterfaceListener; + + class CliContext { +public: + CliContext(); + + void Init(Team* team, + UserInterfaceListener* listener); + + Team* GetTeam() const { return fTeam; } + + void QuitSession(); + + +private: + Team* fTeam; + UserInterfaceListener* fListener; }; diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index 614a227544..0be51f9d0f 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -100,8 +100,6 @@ private: CommandLineUserInterface::CommandLineUserInterface() : - fTeam(NULL), - fListener(NULL), fCommands(20, true), fShowSemaphore(-1), fShown(false), @@ -127,8 +125,7 @@ CommandLineUserInterface::ID() const status_t CommandLineUserInterface::Init(Team* team, UserInterfaceListener* listener) { - fTeam = team; - fListener = listener; + fContext.Init(team, listener); status_t error = _RegisterCommands(); if (error != B_OK) @@ -318,8 +315,7 @@ CommandLineUserInterface::_ExecuteCommand(int argc, const char* const* argv) return; } - CliContext context; - firstEntry->Command()->Execute(argc, argv, context); + firstEntry->Command()->Execute(argc, argv, fContext); } diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h index 9d0c0714b5..35899c0871 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h @@ -10,6 +10,7 @@ #include #include +#include "CliContext.h" #include "UserInterface.h" @@ -68,8 +69,7 @@ private: void _PrintHelp(); private: - Team* fTeam; - UserInterfaceListener* fListener; + CliContext fContext; CommandList fCommands; sem_id fShowSemaphore; bool fShown;