You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.0 KiB
60 lines
2.0 KiB
3 weeks ago
|
#include <catch2/catch_test_macros.hpp>
|
||
|
#include <fmt/core.h>
|
||
|
#include <string>
|
||
|
#include "ansi_parser.hpp"
|
||
|
|
||
|
|
||
|
#include "ftxui/dom/elements.hpp" // for text, bgcolor, color, vbox, hbox, separator, operator|, Elements, Element, Fit, border
|
||
|
#include "ftxui/dom/node.hpp" // for Render
|
||
|
#include "ftxui/screen/color.hpp" // for Color, Color::Black, Color::Blue, Color::BlueLight, Color::Cyan, Color::CyanLight, Color::Default, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::RedLight, Color::White, Color::Yellow, Color::YellowLight, Color::Palette256, ftxui
|
||
|
#include <ftxui/screen/color_info.hpp> // for ColorInfo
|
||
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||
|
#include <ftxui/screen/terminal.hpp> // for ColorSupport, Color, Palette16, Palette256, TrueColor
|
||
|
|
||
|
|
||
|
using namespace fmt;
|
||
|
using namespace ftxui;
|
||
|
|
||
|
std::string generate_colors() {
|
||
|
const int max_value = 255;
|
||
|
const int value_increment = 8;
|
||
|
const int hue_increment = 6;
|
||
|
int saturation = max_value;
|
||
|
Elements array;
|
||
|
int count = 0;
|
||
|
|
||
|
for (int value = 0; value < max_value; value += 2 * value_increment) {
|
||
|
Elements line;
|
||
|
for (int hue = 0; hue < max_value; hue += hue_increment) {
|
||
|
line.push_back(
|
||
|
text("#") //
|
||
|
| color(Color::HSV(hue, saturation, value)) //
|
||
|
| bgcolor(Color::HSV(hue, saturation, value + value_increment)));
|
||
|
count++;
|
||
|
}
|
||
|
array.push_back(hbox(std::move(line)));
|
||
|
break; /// UNDO ME
|
||
|
}
|
||
|
|
||
|
println("MADE {} CHARS", count);
|
||
|
|
||
|
auto true_color_display = vbox({
|
||
|
vbox(std::move(array)),
|
||
|
});
|
||
|
|
||
|
auto document = vbox({hbox({
|
||
|
true_color_display,
|
||
|
})});
|
||
|
|
||
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
||
|
Render(screen, document);
|
||
|
return screen.ToString();
|
||
|
}
|
||
|
|
||
|
TEST_CASE("test out ragel parser", "[gui]") {
|
||
|
std::string colors = generate_colors();
|
||
|
|
||
|
println("--- PARSING");
|
||
|
REQUIRE(parse_ansi(colors));
|
||
|
}
|