diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-01-21 12:14:44 +0000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-01-21 12:17:49 +0000 |
| commit | e8ee8c23d837d64b1df1d39a97acb88c7cb207de (patch) | |
| tree | 55af498c0cda9a11484dd891f17edb1380c21ae8 /src/remote.cc | |
| parent | c6a7924b80f25227212d493d367a8c3bec16e4ee (diff) | |
Support the +line syntax for clients as well.
Fix a crash on daemon quit as well.
Diffstat (limited to 'src/remote.cc')
| -rw-r--r-- | src/remote.cc | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/remote.cc b/src/remote.cc index 016ba23c..6a436d5c 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -8,6 +8,7 @@ #include "event_manager.hh" #include "file.hh" #include "id_map.hh" +#include "optional.hh" #include "user_interface.hh" #include <sys/types.h> @@ -102,6 +103,14 @@ public: } } + template<typename T> + void write(const Optional<T>& val) + { + write((bool)val); + if (val) + write(*val); + } + void write(Color color) { write(color.color); @@ -219,6 +228,14 @@ public: return res; } + template<typename T> + Optional<T> read_optional() + { + if (not read<bool>()) + return {}; + return read<T>(); + } + void reset() { m_stream.resize(0); @@ -511,7 +528,8 @@ bool check_session(StringView session) } RemoteClient::RemoteClient(StringView session, std::unique_ptr<UserInterface>&& ui, - const EnvVarMap& env_vars, StringView init_command) + const EnvVarMap& env_vars, StringView init_command, + Optional<BufferCoord> init_coord) : m_ui(std::move(ui)) { int sock = connect_to(session); @@ -519,6 +537,7 @@ RemoteClient::RemoteClient(StringView session, std::unique_ptr<UserInterface>&& { MsgWriter msg{m_send_buffer, MessageType::Connect}; msg.write(init_command); + msg.write(init_coord); msg.write(m_ui->dimensions()); msg.write(env_vars); } @@ -652,12 +671,13 @@ private: case MessageType::Connect: { auto init_cmds = m_reader.read<String>(); + auto init_coord = m_reader.read_optional<BufferCoord>(); auto dimensions = m_reader.read<DisplayCoord>(); auto env_vars = m_reader.read_idmap<String, MemoryDomain::EnvVars>(); auto* ui = new RemoteUI{sock, dimensions}; if (auto* client = ClientManager::instance().create_client( std::unique_ptr<UserInterface>(ui), - std::move(env_vars), init_cmds, {})) + std::move(env_vars), init_cmds, init_coord)) ui->set_client(client); Server::instance().remove_accepter(this); |
