From 203a7732f5fafb5f9b7e8564bd3bd4587e168134 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 7 Apr 2014 21:25:44 +0100 Subject: Add support for querying client environement variables At connection, a remote client sends all its environement to the server, which then provides access to client env through kak_client_env_VAR_NAME variables in the shell. --- src/client.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/client.cc') diff --git a/src/client.cc b/src/client.cc index 4f8dfbdf..cda0ef5c 100644 --- a/src/client.cc +++ b/src/client.cc @@ -14,10 +14,13 @@ namespace Kakoune Client::Client(std::unique_ptr&& ui, std::unique_ptr&& window, - SelectionList selections, String name) + SelectionList selections, + EnvVarMap env_vars, + String name) : m_ui{std::move(ui)}, m_window{std::move(window)}, m_input_handler{m_window->buffer(), std::move(selections), - std::move(name)} + std::move(name)}, + m_env_vars(env_vars) { context().set_client(*this); context().set_window(*m_window); @@ -151,4 +154,13 @@ void Client::check_buffer_fs_timestamp() reload_buffer(context(), filename); } +const String& Client::get_env_var(const String& name) const +{ + auto it = m_env_vars.find(name); + static String empty{}; + if (it == m_env_vars.end()) + return empty; + return it->second; +} + } -- cgit v1.2.3