19 using namespace ftxui;
20 auto screen = App::FitComponent();
22 auto quirks = Terminal::GetQuirks();
24 bool block_characters = quirks.BlockCharacters();
25 bool cursor_hiding = quirks.CursorHiding();
26 bool component_ascii = quirks.ComponentAscii();
27 int color_support = (int)quirks.ColorSupport();
30 Checkbox(
"Support 8 Unicode block characters", &block_characters);
31 auto cb_cursor = Checkbox(
"Support cursor hiding", &cursor_hiding);
32 auto cb_ascii = Checkbox(
"Use ASCII for components", &component_ascii);
34 std::vector<std::string> color_names = {
40 auto rb_color = Radiobox(&color_names, &color_support);
43 Button(
"Quit", screen.ExitLoopClosure(), ButtonOption::Animated());
45 bool dummy_checked =
true;
46 int dummy_selected = 0;
47 std::vector<std::string> dummy_options = {
"Option"};
48 auto dummy_checkbox = Checkbox(
"Tested", &dummy_checked);
49 auto dummy_radiobox = Radiobox(&dummy_options, &dummy_selected);
51 auto layout = Container::Vertical({
61 auto start_time = std::chrono::steady_clock::now();
63 auto renderer = Renderer(layout, [&] {
64 auto capabilities = screen.TerminalCapabilityNames();
66 for (
const auto& cap : capabilities) {
67 capability_elements.push_back(text(
" - " + cap));
70 auto info_pane = vbox({
71 text(
"Terminal Name: " + screen.TerminalName()),
72 text(
"Terminal Version: " + std::to_string(screen.TerminalVersion())),
73 text(
"Emulator Name: " + screen.TerminalEmulatorName()),
74 text(
"Emulator Version: " + screen.TerminalEmulatorVersion()),
75 text(
"Detected Capabilities:"),
76 vbox(std::move(capability_elements)),
83 quirks.SetBlockCharacters(block_characters);
84 quirks.SetCursorHiding(cursor_hiding);
85 quirks.SetComponentAscii(component_ascii);
87 Terminal::SetQuirks(quirks);
89 auto current_time = std::chrono::steady_clock::now();
90 std::chrono::duration<float> elapsed = current_time - start_time;
93 float gauge_value = 0.5f + 0.3f * std::sin(elapsed.count() * 0.5f);
94 screen.RequestAnimationFrame();
97 const int saturation = 255;
98 for (
int value = 0; value < 255; value += 20) {
100 for (
int hue = 0; hue < 255; hue += 6) {
101 line.push_back(text(
"▀")
102 | color(Color::HSV(hue, saturation, value))
103 | bgcolor(Color::HSV(hue, saturation, value + 10)));
105 hsv_rows.push_back(hbox(std::move(line)));
108 auto overrides_pane = vbox({
110 hbox(text(
"Verification: "), gauge(gauge_value) | flex),
113 text(
"(Hides terminal cursor if supported/enabled)") | dim,
117 text(
"Verification: "),
118 dummy_checkbox->Render(),
120 dummy_radiobox->Render(),
123 text(
"Color Support:"),
125 text(
"Verification (HSV Square):"),
126 vbox(std::move(hsv_rows)),
131 window(text(
" Terminal Info "), info_pane),
132 window(text(
" Exit "),
134 text(
"Press 'q' or click the button to exit."),
137 }) | size(WIDTH, EQUAL, 40),
138 window(text(
" Runtime Quirk Overrides & Visual Verification "),
144 auto component = CatchEvent(renderer, [&](Event event) {
145 if (event == Event::Character(
'q')) {
152 screen.Loop(component);