2012-10-30 14:00:44 +01:00
|
|
|
#ifndef client_manager_hh_INCLUDED
|
|
|
|
#define client_manager_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "context.hh"
|
|
|
|
#include "input_handler.hh"
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
struct client_removed{};
|
|
|
|
|
2013-04-15 14:28:21 +02:00
|
|
|
class Client
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Context& context() { return m_input_handler.context(); }
|
|
|
|
const String& name() const { return m_name; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class ClientManager;
|
|
|
|
|
|
|
|
Client(std::unique_ptr<UserInterface>&& ui,
|
|
|
|
Window& window, String name);
|
|
|
|
Client(Client&&) = delete;
|
|
|
|
Client& operator=(Client&& other) = delete;
|
|
|
|
|
|
|
|
const std::unique_ptr<UserInterface> m_user_interface;
|
|
|
|
InputHandler m_input_handler;
|
|
|
|
String m_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-10-30 14:00:44 +01:00
|
|
|
class ClientManager : public Singleton<ClientManager>
|
|
|
|
{
|
|
|
|
public:
|
2013-02-07 19:25:42 +01:00
|
|
|
ClientManager();
|
|
|
|
~ClientManager();
|
|
|
|
|
2013-04-15 14:28:21 +02:00
|
|
|
Client* create_client(std::unique_ptr<UserInterface>&& ui,
|
|
|
|
const String& init_cmd);
|
2012-10-30 14:00:44 +01:00
|
|
|
|
|
|
|
bool empty() const { return m_clients.empty(); }
|
|
|
|
size_t count() const { return m_clients.size(); }
|
2012-10-31 14:23:44 +01:00
|
|
|
|
2012-11-22 14:08:55 +01:00
|
|
|
Window& get_unused_window_for_buffer(Buffer& buffer);
|
2012-11-07 14:02:23 +01:00
|
|
|
void ensure_no_client_uses_buffer(Buffer& buffer);
|
2012-11-05 19:15:42 +01:00
|
|
|
|
2012-11-05 19:58:04 +01:00
|
|
|
void redraw_clients() const;
|
2012-12-03 18:56:53 +01:00
|
|
|
|
2013-04-15 14:28:21 +02:00
|
|
|
Client& get_client(const Context& context);
|
|
|
|
Client& get_client(const String& name);
|
|
|
|
void set_client_name(Client& client, String name);
|
2013-04-15 18:50:45 +02:00
|
|
|
void remove_client(Client& client);
|
2013-04-15 14:28:21 +02:00
|
|
|
|
2012-10-30 14:00:44 +01:00
|
|
|
private:
|
2013-01-07 13:59:09 +01:00
|
|
|
String generate_name() const;
|
2012-11-20 18:54:35 +01:00
|
|
|
|
2012-11-22 14:17:46 +01:00
|
|
|
std::vector<std::unique_ptr<Client>> m_clients;
|
2012-11-22 14:08:55 +01:00
|
|
|
std::vector<std::unique_ptr<Window>> m_windows;
|
2012-10-30 14:00:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // client_manager_hh_INCLUDED
|
|
|
|
|