client_manager.hh (1985B)
1 #ifndef client_manager_hh_INCLUDED 2 #define client_manager_hh_INCLUDED 3 4 #include "client.hh" 5 #include "completion.hh" 6 7 namespace Kakoune 8 { 9 10 struct WindowAndSelections 11 { 12 UniquePtr<Window> window; 13 SelectionList selections; 14 }; 15 16 class ClientManager : public Singleton<ClientManager> 17 { 18 public: 19 ClientManager(); 20 ~ClientManager(); 21 22 Client* create_client(UniquePtr<UserInterface>&& ui, int pid, 23 String name, EnvVarMap env_vars, StringView init_cmds, 24 StringView init_buffer, Optional<BufferCoord> init_coord, 25 Client::OnExitCallback on_exit); 26 27 bool empty() const { return m_clients.empty(); } 28 size_t count() const { return m_clients.size(); } 29 30 void clear(bool exit); 31 32 void ensure_no_client_uses_buffer(Buffer& buffer); 33 34 WindowAndSelections get_free_window(Buffer& buffer); 35 void add_free_window(UniquePtr<Window>&& window, SelectionList selections); 36 37 void redraw_clients() const; 38 bool process_pending_inputs(); 39 bool has_pending_inputs() const; 40 41 Client* get_client_ifp(StringView name); 42 Client& get_client(StringView name); 43 bool client_name_exists(StringView name) const; 44 void remove_client(Client& client, bool graceful, int status); 45 46 using ClientList = Vector<UniquePtr<Client>, MemoryDomain::Client>; 47 using iterator = ClientList::const_iterator; 48 49 iterator begin() const { return m_clients.begin(); } 50 iterator end() const { return m_clients.end(); } 51 52 CandidateList complete_client_name(StringView name, 53 ByteCount cursor_pos = -1) const; 54 55 void clear_window_trash(); 56 void clear_client_trash(); 57 private: 58 String generate_name() const; 59 60 ClientList m_clients; 61 ClientList m_client_trash; 62 Vector<WindowAndSelections, MemoryDomain::Client> m_free_windows; 63 Vector<UniquePtr<Window>, MemoryDomain::Client> m_window_trash; 64 }; 65 66 } 67 68 #endif // client_manager_hh_INCLUDED