summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-01-04 23:19:18 +0000
committerMaxime Coste <mawww@kakoune.org>2017-01-04 23:19:18 +0000
commitd9914201407c64185ffaa90c42f2013e7a264eb2 (patch)
tree32cf79b05be4b8ae80f8a155460acc6723764247 /src
parent60d08137044c5fa52213fe89863bdf0018a36df7 (diff)
Higher level implementation of attributes to json formatting
Diffstat (limited to 'src')
-rw-r--r--src/json_ui.cc17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/json_ui.cc b/src/json_ui.cc
index d35471dd..f49807cc 100644
--- a/src/json_ui.cc
+++ b/src/json_ui.cc
@@ -73,7 +73,7 @@ String to_json(Color color)
String to_json(Attribute attributes)
{
- struct { Attribute attr; StringView name; }
+ struct Attr { Attribute attr; StringView name; }
attrs[] {
{ Attribute::Exclusive, "exclusive" },
{ Attribute::Underline, "underline" },
@@ -84,17 +84,10 @@ String to_json(Attribute attributes)
{ Attribute::Italic, "italic" },
};
- String res;
- for (auto& attr : attrs)
- {
- if (not (attributes & attr.attr))
- continue;
-
- if (not res.empty())
- res += ", ";
- res += to_json(attr.name);
- }
- return "[" + res + "]";
+ return "[" + join(attrs |
+ filter([=](const Attr& a) { return attributes & a.attr; }) |
+ transform([](const Attr& a) { return to_json(a.name); }),
+ ',', false) + "]";
}
String to_json(Face face)