2012-10-30 14:00:44 +01:00
|
|
|
#ifndef client_manager_hh_INCLUDED
|
|
|
|
#define client_manager_hh_INCLUDED
|
|
|
|
|
2013-09-12 23:47:23 +02:00
|
|
|
#include "client.hh"
|
2014-04-07 22:43:55 +02:00
|
|
|
#include "completion.hh"
|
2012-10-30 14:00:44 +01:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2015-10-08 14:43:39 +02:00
|
|
|
struct client_removed
|
|
|
|
{
|
|
|
|
client_removed(bool graceful) : graceful{graceful} {}
|
|
|
|
|
|
|
|
const bool graceful;
|
|
|
|
};
|
2012-10-30 14:00:44 +01:00
|
|
|
|
2014-01-27 21:28:38 +01:00
|
|
|
struct WindowAndSelections
|
|
|
|
{
|
|
|
|
std::unique_ptr<Window> window;
|
2014-05-13 00:25:15 +02:00
|
|
|
SelectionList selections;
|
|
|
|
size_t timestamp;
|
2014-01-27 21:28:38 +01:00
|
|
|
};
|
2013-12-20 21:10:08 +01:00
|
|
|
|
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-09-12 23:47:23 +02:00
|
|
|
Client* create_client(std::unique_ptr<UserInterface>&& ui,
|
2014-10-20 20:18:38 +02:00
|
|
|
EnvVarMap env_vars, StringView 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
|
|
|
|
2015-08-26 20:33:52 +02:00
|
|
|
void ensure_no_client_uses_buffer(Buffer& buffer);
|
2012-11-05 19:15:42 +01:00
|
|
|
|
2013-12-20 21:10:08 +01:00
|
|
|
WindowAndSelections get_free_window(Buffer& buffer);
|
|
|
|
void add_free_window(std::unique_ptr<Window>&& window, SelectionList selections);
|
|
|
|
|
2012-11-05 19:58:04 +01:00
|
|
|
void redraw_clients() const;
|
2014-11-29 21:14:52 +01:00
|
|
|
void handle_pending_inputs() const;
|
2012-12-03 18:56:53 +01:00
|
|
|
|
2014-10-20 20:18:38 +02:00
|
|
|
Client* get_client_ifp(StringView name);
|
|
|
|
Client& get_client(StringView name);
|
|
|
|
bool validate_client_name(StringView name) const;
|
2015-10-08 14:43:39 +02:00
|
|
|
void remove_client(Client& client, bool graceful);
|
2013-04-15 14:28:21 +02:00
|
|
|
|
2015-02-12 15:55:02 +01:00
|
|
|
using ClientList = Vector<std::unique_ptr<Client>, MemoryDomain::Client>;
|
|
|
|
using iterator = ClientList::const_iterator;
|
|
|
|
|
|
|
|
iterator begin() const { return m_clients.begin(); }
|
|
|
|
iterator end() const { return m_clients.end(); }
|
|
|
|
|
2014-04-18 15:02:14 +02:00
|
|
|
CandidateList complete_client_name(StringView name,
|
2014-04-07 22:43:55 +02:00
|
|
|
ByteCount cursor_pos = -1) const;
|
|
|
|
|
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
|
|
|
|
2015-02-12 15:55:02 +01:00
|
|
|
ClientList m_clients;
|
2015-01-14 20:16:32 +01:00
|
|
|
Vector<WindowAndSelections, MemoryDomain::Client> m_free_windows;
|
2012-10-30 14:00:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // client_manager_hh_INCLUDED
|