FTXUI/src/ftxui/dom/util.cpp

35 lines
742 B
C++
Raw Normal View History

2020-04-20 03:00:37 +08:00
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
2019-01-03 05:33:59 +08:00
#include "ftxui/dom/elements.hpp"
namespace ftxui {
2019-01-03 05:33:59 +08:00
Element nothing(Element element) {
return element;
2019-01-03 05:33:59 +08:00
}
2019-01-03 07:35:59 +08:00
Decorator compose(Decorator a, Decorator b) {
2020-03-23 05:32:44 +08:00
return [a = std::move(a), b = std::move(b)](Element element) {
return b(a(std::move(element)));
2019-01-03 07:35:59 +08:00
};
}
Decorator operator|(Decorator a, Decorator b) {
return compose(a, b);
}
2019-01-27 04:52:55 +08:00
Elements operator|(Elements es, Decorator d) {
Elements output;
for (auto& it : es)
output.push_back(std::move(it) | d);
return output;
}
Element operator|(Element e, Decorator d) {
return d(std::move(e));
}
} // namespace ftxui