diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-04-29 20:38:47 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-04-29 20:45:53 +1000 |
| commit | 8e555cb992a77a540bc211a6c5bbe510e7bcb23d (patch) | |
| tree | 653405ef75e3d1b6538687983bab1967974442c8 /src | |
| parent | 2fa553e728d5600426886e6301d80807f02db533 (diff) | |
JsonUI: add support for set_ui_options RPC call
As discussed on #2019
Diffstat (limited to 'src')
| -rw-r--r-- | src/json_ui.cc | 18 |
1 files changed, 9 insertions, 9 deletions
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<typename T> String to_json(ArrayView<const T> 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<typename T, MemoryDomain D> String to_json(const Vector<T, D>& vec) { return to_json(ArrayView<const T>{vec}); } +template<typename K, typename V, MemoryDomain D> +String to_json(const HashMap<K, V, D>& 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() |
