ClientManager: move the Client inner class detail in the cpp file

This commit is contained in:
Maxime Coste 2013-02-07 19:25:42 +01:00
parent 32e6184210
commit cb26948ad3
2 changed files with 28 additions and 20 deletions

View File

@ -7,6 +7,30 @@
namespace Kakoune
{
struct ClientManager::Client
{
Client(std::unique_ptr<UserInterface>&& ui, Window& window,
String name)
: user_interface(std::move(ui)),
input_handler(*user_interface),
name(std::move(name))
{
assert(not this->name.empty());
context().change_editor(window);
}
Client(Client&&) = delete;
Client& operator=(Client&& other) = delete;
Context& context() { return input_handler.context(); }
std::unique_ptr<UserInterface> user_interface;
InputHandler input_handler;
String name;
};
ClientManager::ClientManager() = default;
ClientManager::~ClientManager() = default;
String ClientManager::generate_name() const
{
for (int i = 0; true; ++i)
@ -32,10 +56,7 @@ void ClientManager::create_client(std::unique_ptr<UserInterface>&& ui,
Buffer& buffer = **BufferManager::instance().begin();
m_clients.emplace_back(new Client{std::move(ui), get_unused_window_for_buffer(buffer),
generate_name()});
InputHandler* input_handler = &m_clients.back()->input_handler;
Context* context = &m_clients.back()->context();
try
{
CommandManager::instance().execute(init_commands, *context);

View File

@ -12,6 +12,9 @@ struct client_removed{};
class ClientManager : public Singleton<ClientManager>
{
public:
ClientManager();
~ClientManager();
void create_client(std::unique_ptr<UserInterface>&& ui,
const String& init_cmd);
@ -30,23 +33,7 @@ private:
void remove_client_by_context(Context& context);
String generate_name() const;
struct Client
{
Client(std::unique_ptr<UserInterface>&& ui, Window& window,
String name)
: user_interface(std::move(ui)),
input_handler(*user_interface),
name(std::move(name)) { context().change_editor(window); }
Client(Client&&) = delete;
Client& operator=(Client&& other) = delete;
Context& context() { return input_handler.context(); }
std::unique_ptr<UserInterface> user_interface;
InputHandler input_handler;
String name;
};
struct Client;
std::vector<std::unique_ptr<Client>> m_clients;
std::vector<std::unique_ptr<Window>> m_windows;
};