2012-10-30 17:00:44 +04:00
|
|
|
#ifndef client_manager_hh_INCLUDED
|
|
|
|
#define client_manager_hh_INCLUDED
|
|
|
|
|
2013-09-13 01:47:23 +04:00
|
|
|
#include "client.hh"
|
2014-04-08 00:43:55 +04:00
|
|
|
#include "completion.hh"
|
2012-10-30 17:00:44 +04:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2014-01-28 00:28:38 +04:00
|
|
|
struct WindowAndSelections
|
|
|
|
{
|
|
|
|
std::unique_ptr<Window> window;
|
2014-05-13 02:25:15 +04:00
|
|
|
SelectionList selections;
|
2014-01-28 00:28:38 +04:00
|
|
|
};
|
2013-12-21 00:10:08 +04:00
|
|
|
|
2012-10-30 17:00:44 +04:00
|
|
|
class ClientManager : public Singleton<ClientManager>
|
|
|
|
{
|
|
|
|
public:
|
2013-02-07 22:25:42 +04:00
|
|
|
ClientManager();
|
|
|
|
~ClientManager();
|
|
|
|
|
2017-08-28 09:12:15 +03:00
|
|
|
Client* create_client(std::unique_ptr<UserInterface>&& ui, int pid,
|
2016-12-01 23:40:50 +03:00
|
|
|
EnvVarMap env_vars, StringView init_cmds,
|
2017-08-23 09:22:23 +03:00
|
|
|
Optional<BufferCoord> init_coord,
|
|
|
|
Client::OnExitCallback on_exit);
|
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
|
|
|
|
2016-03-03 16:55:35 +03:00
|
|
|
void clear();
|
|
|
|
|
2016-05-13 22:32:53 +03:00
|
|
|
void ensure_no_client_uses_buffer(Buffer& buffer);
|
2012-11-05 22:15:42 +04:00
|
|
|
|
2013-12-21 00:10:08 +04:00
|
|
|
WindowAndSelections get_free_window(Buffer& buffer);
|
|
|
|
void add_free_window(std::unique_ptr<Window>&& window, SelectionList selections);
|
|
|
|
|
2012-11-05 22:58:04 +04:00
|
|
|
void redraw_clients() const;
|
2016-11-30 00:35:53 +03:00
|
|
|
void process_pending_inputs() const;
|
2012-12-03 21:56:53 +04:00
|
|
|
|
2014-10-20 22:18:38 +04:00
|
|
|
Client* get_client_ifp(StringView name);
|
|
|
|
Client& get_client(StringView name);
|
|
|
|
bool validate_client_name(StringView name) const;
|
2017-08-23 09:22:23 +03:00
|
|
|
void remove_client(Client& client, bool graceful, int status);
|
2013-04-15 16:28:21 +04:00
|
|
|
|
2015-02-12 17:55:02 +03: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 17:02:14 +04:00
|
|
|
CandidateList complete_client_name(StringView name,
|
2014-04-08 00:43:55 +04:00
|
|
|
ByteCount cursor_pos = -1) const;
|
|
|
|
|
2016-05-13 22:32:53 +03:00
|
|
|
void clear_window_trash();
|
2016-09-04 19:54:07 +03:00
|
|
|
void clear_client_trash();
|
2012-10-30 17:00:44 +04:00
|
|
|
private:
|
2013-01-07 16:59:09 +04:00
|
|
|
String generate_name() const;
|
2012-11-20 21:54:35 +04:00
|
|
|
|
2015-02-12 17:55:02 +03:00
|
|
|
ClientList m_clients;
|
2016-09-04 19:54:07 +03:00
|
|
|
ClientList m_client_trash;
|
2015-01-14 22:16:32 +03:00
|
|
|
Vector<WindowAndSelections, MemoryDomain::Client> m_free_windows;
|
2016-11-28 16:59:55 +03:00
|
|
|
Vector<std::unique_ptr<Window>, MemoryDomain::Client> m_window_trash;
|
2012-10-30 17:00:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // client_manager_hh_INCLUDED
|