FTXUI/examples/dom/window.cpp

35 lines
1.0 KiB
C++
Raw Normal View History

2022-03-31 08:17:43 +08:00
#include <stdlib.h> // for EXIT_SUCCESS
#include <ftxui/dom/elements.hpp> // for operator|=, Element, bgcolor, color, graph, border
#include <ftxui/screen/screen.hpp> // for Fixed, Screen
#include <vector> // for vector
2021-05-02 02:40:35 +08:00
2022-03-31 08:17:43 +08:00
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, Color::DarkBlue, Color::Red, ftxui
2020-05-25 07:34:13 +08:00
2022-03-31 08:17:43 +08:00
int main() {
2020-05-25 07:34:13 +08:00
using namespace ftxui;
2020-10-17 04:31:24 +08:00
Element document = graph([](int x, int y) {
2022-03-31 08:17:43 +08:00
std::vector<int> result(x, 0);
for (int i{0}; i < x; ++i) {
result[i] = ((3 * i) / 2) % y;
}
return result;
});
2020-10-17 04:31:24 +08:00
2022-03-31 08:17:43 +08:00
document |= color(Color::Red);
document |= bgcolor(Color::DarkBlue);
document |= border;
const int width = 80;
const int height = 10;
auto screen =
Screen::Create(Dimension::Fixed(width), Dimension::Fixed(height));
2020-05-25 07:34:13 +08:00
Render(screen, document);
2021-03-22 05:54:39 +08:00
screen.Print();
2022-03-31 08:17:43 +08:00
return EXIT_SUCCESS;
2020-05-25 07:34:13 +08:00
}
2020-09-06 19:46:56 +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.