From 8e555cb992a77a540bc211a6c5bbe510e7bcb23d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 29 Apr 2018 20:38:47 +1000 Subject: JsonUI: add support for set_ui_options RPC call As discussed on #2019 --- src/json_ui.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/json_ui.cc b/src/json_ui.cc index 322085ac..55b21e81 100644 --- a/src/json_ui.cc +++ b/src/json_ui.cc @@ -20,19 +20,19 @@ namespace Kakoune template String to_json(ArrayView array) { - String res; - for (auto& elem : array) - { - if (not res.empty()) - res += ", "; - res += to_json(elem); - } - return "[" + res + "]"; + return "[" + join(array | transform([](auto&& elem) { return to_json(elem); }), ',', false) + "]"; } template String to_json(const Vector& vec) { return to_json(ArrayView{vec}); } +template +String to_json(const HashMap& map) +{ + return "{" + join(map | transform([](auto&& i) { return format("{}: {}", to_json(i.key), to_json(i.value)); }), + ',', false) + "}"; +} + String to_json(int i) { return to_string(i); } String to_json(bool b) { return b ? "true" : "false"; } String to_json(StringView str) @@ -232,7 +232,7 @@ void JsonUI::refresh(bool force) void JsonUI::set_ui_options(const Options& options) { - // rpc_call("set_ui_options", options); + rpc_call("set_ui_options", options); } DisplayCoord JsonUI::dimensions() -- cgit v1.2.3