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"
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
namespace ftxui {
|
2019-01-03 05:33:59 +08:00
|
|
|
|
|
|
|
Element nothing(Element element) {
|
2019-02-02 08:59:48 +08:00
|
|
|
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) {
|
2019-01-05 09:03:49 +08:00
|
|
|
return b(a(std::move(element)));
|
2019-01-03 07:35:59 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-01-05 09:03:49 +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;
|
|
|
|
}
|
|
|
|
|
2019-01-05 09:03:49 +08:00
|
|
|
Element operator|(Element e, Decorator d) {
|
|
|
|
return d(std::move(e));
|
|
|
|
}
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
} // namespace ftxui
|