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{};
|
|
|
|
|
|
|
|
class ClientManager : public Singleton<ClientManager>
|
|
|
|
{
|
|
|
|
public:
|
2012-10-31 14:23:44 +01:00
|
|
|
void create_client(std::unique_ptr<UserInterface>&& ui,
|
|
|
|
Buffer& buffer, int event_fd);
|
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-10-30 14:00:44 +01:00
|
|
|
private:
|
2012-11-20 18:54:35 +01:00
|
|
|
void remove_client_by_context(Context& context);
|
|
|
|
|
2012-10-31 14:23:44 +01:00
|
|
|
struct Client
|
|
|
|
{
|
|
|
|
Client(std::unique_ptr<UserInterface>&& ui, Window& window)
|
2012-11-22 14:17:46 +01:00
|
|
|
: user_interface(std::move(ui)),
|
|
|
|
context(input_handler, window, *user_interface) {}
|
|
|
|
Client(Client&&) = delete;
|
|
|
|
Client& operator=(Client&& other) = delete;
|
2012-10-31 14:23:44 +01:00
|
|
|
|
|
|
|
std::unique_ptr<UserInterface> user_interface;
|
2012-11-22 14:17:46 +01:00
|
|
|
InputHandler input_handler;
|
|
|
|
Context context;
|
2012-10-31 14:23:44 +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
|
|
|
|
|