2012-10-30 17:00:44 +04: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 17:23:44 +04:00
|
|
|
void create_client(std::unique_ptr<UserInterface>&& ui,
|
2012-12-28 16:51:14 +04:00
|
|
|
int event_fd, const String& init_cmd);
|
2012-10-30 17:00:44 +04:00
|
|
|
|
|
|
|
bool empty() const { return m_clients.empty(); }
|
|
|
|
size_t count() const { return m_clients.size(); }
|
2012-10-31 17:23:44 +04:00
|
|
|
|
2012-11-22 17:08:55 +04:00
|
|
|
Window& get_unused_window_for_buffer(Buffer& buffer);
|
2012-11-07 17:02:23 +04:00
|
|
|
void ensure_no_client_uses_buffer(Buffer& buffer);
|
2012-11-05 22:15:42 +04:00
|
|
|
|
2012-11-05 22:58:04 +04:00
|
|
|
void redraw_clients() const;
|
2012-12-03 21:56:53 +04:00
|
|
|
|
|
|
|
void set_client_name(Context& context, String name);
|
2013-01-07 16:59:09 +04:00
|
|
|
String get_client_name(const Context& context);
|
2012-12-03 21:56:53 +04:00
|
|
|
Context& get_client_context(const String& name);
|
2012-10-30 17:00:44 +04:00
|
|
|
private:
|
2012-11-20 21:54:35 +04:00
|
|
|
void remove_client_by_context(Context& context);
|
2013-01-07 16:59:09 +04:00
|
|
|
String generate_name() const;
|
2012-11-20 21:54:35 +04:00
|
|
|
|
2012-10-31 17:23:44 +04:00
|
|
|
struct Client
|
|
|
|
{
|
2013-01-07 16:59:09 +04:00
|
|
|
Client(std::unique_ptr<UserInterface>&& ui, Window& window,
|
|
|
|
String name)
|
2012-11-22 17:17:46 +04:00
|
|
|
: user_interface(std::move(ui)),
|
2013-01-07 16:59:09 +04:00
|
|
|
context(input_handler, window, *user_interface),
|
|
|
|
name(std::move(name)) {}
|
2012-11-22 17:17:46 +04:00
|
|
|
Client(Client&&) = delete;
|
|
|
|
Client& operator=(Client&& other) = delete;
|
2012-10-31 17:23:44 +04:00
|
|
|
|
|
|
|
std::unique_ptr<UserInterface> user_interface;
|
2012-11-22 17:17:46 +04:00
|
|
|
InputHandler input_handler;
|
|
|
|
Context context;
|
2012-12-03 21:56:53 +04:00
|
|
|
String name;
|
2012-10-31 17:23:44 +04:00
|
|
|
};
|
|
|
|
|
2012-11-22 17:17:46 +04:00
|
|
|
std::vector<std::unique_ptr<Client>> m_clients;
|
2012-11-22 17:08:55 +04:00
|
|
|
std::vector<std::unique_ptr<Window>> m_windows;
|
2012-10-30 17:00:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // client_manager_hh_INCLUDED
|
|
|
|
|