// 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. #include // for operator""s, chrono_literals #include // for Full, Screen #include // for cout, ostream #include // for allocator, shared_ptr #include // for string, operator<< #include // for sleep_for #include // for hflow, paragraph, separator, hbox, vbox, filler, operator|, border, Element #include // for Render #include // for ftxui #include using namespace std::chrono_literals; std::array tiles = { "##########", "# #", "# #", "# |", "# #", "##########", }; int main() { using namespace ftxui; std::string reset_position; auto c = Canvas(100, 100); // A triangle following the mouse, using braille characters. auto map = Renderer([&] { for(size_t i = 0; i < tiles.size(); ++i) { c.DrawText(50, 50+i*4, tiles[i]); } for(size_t i = 0; i < tiles[0].size() - 2; i++) { for(size_t j = 0; j < tiles.size() - 2; j++) { c.DrawText(52+i*2, 54+j*4, ".", Color::Yellow); } } c.DrawText(50+3*4, 50+3*4, "@", Color::Blue); return canvas(c); }); while (true) { auto document = hbox({ hflow( vbox( gauge(0.5) | border, text("STATUS") | border ) | xflex_grow ), separator(), hflow(map->Render()), }) | border; auto screen = Screen::Create(Dimension::Full()); Render(screen, document); std::cout << reset_position; screen.Print(); reset_position = screen.ResetPosition(); std::this_thread::sleep_for(0.01s); } return 0; }