39 auto my_graph = [&shift](
int width,
int height) {
40 std::vector<int> output(width);
41 for (
int i = 0; i < width; ++i) {
43 v += 0.1f * sin((i + shift) * 0.1f);
44 v += 0.2f * sin((i + shift + 10) * 0.15f);
45 v += 0.1f * sin((i + shift) * 0.03f);
53 auto frequency =
vbox({
67 auto utilization =
vbox({
111 const std::vector<std::string> compiler_entries = {
117 "ALGOL 60 compilers",
118 "ALGOL 68 compilers",
119 "Assemblers (Intel *86)",
120 "Assemblers (Motorola 68*)",
121 "Assemblers (Zilog Z80)",
122 "Assemblers (other)",
124 "BASIC interpreters",
127 "Source-to-source compilers",
131 "Common Lisp compilers",
133 "DIBOL/DBL compilers",
134 "ECMAScript interpreters",
145 "Scheme compilers and interpreters",
146 "Smalltalk compilers",
153 int compiler_selected = 0;
156 std::array<std::string, 8> options_label = {
162 "-Wno-class-conversion",
164 "-Wno-conversion-null",
166 std::array<bool, 8> options_state = {
167 false,
false,
false,
false,
false,
false,
false,
false,
170 std::vector<std::string> input_entries;
171 int input_selected = 0;
175 std::string input_add_content;
176 input_option.on_enter = [&] {
177 input_entries.push_back(input_add_content);
178 input_add_content =
"";
180 Component input_add =
Input(&input_add_content,
"input files", input_option);
182 std::string executable_content_ =
"";
183 Component executable_ =
Input(&executable_content_,
"executable");
186 Checkbox(&options_label[0], &options_state[0]),
187 Checkbox(&options_label[1], &options_state[1]),
188 Checkbox(&options_label[2], &options_state[2]),
189 Checkbox(&options_label[3], &options_state[3]),
190 Checkbox(&options_label[4], &options_state[4]),
191 Checkbox(&options_label[5], &options_state[5]),
192 Checkbox(&options_label[6], &options_state[6]),
193 Checkbox(&options_label[7], &options_state[7]),
196 auto compiler_component = Container::Horizontal({
199 Container::Vertical({
201 Container::Horizontal({
208 auto render_command = [&] {
211 line.push_back(
text(compiler_entries[compiler_selected]) | bold);
213 for (
int i = 0; i < 8; ++i) {
214 if (options_state[i]) {
215 line.push_back(
text(
" "));
216 line.push_back(
text(options_label[i]) | dim);
220 if (!executable_content_.empty()) {
221 line.push_back(
text(
" -o ") | bold);
226 for (
auto& it : input_entries) {
232 auto compiler_renderer =
Renderer(compiler_component, [&] {
234 compiler->
Render() | vscroll_indicator | frame);
249 input->
Render() | vscroll_indicator | frame |
270 auto spinner_tab_renderer =
Renderer([&] {
272 for (
int i = 0; i < 22; ++i) {
273 entries.push_back(
spinner(i, shift / 5) | bold |
276 return hflow(std::move(entries));
282 auto color_tab_renderer =
Renderer([] {
283 auto basic_color_display =
285 text(
"16 color palette:"),
330 auto palette_256_color_display =
text(
"256 colors palette:");
334 for (
auto& column : info_columns) {
336 for (
auto& it : column) {
337 column_elements.push_back(
340 columns.push_back(
hbox(std::move(column_elements)));
342 palette_256_color_display =
vbox({
343 palette_256_color_display,
351 auto true_color_display =
text(
"TrueColors: 24bits:");
353 int saturation = 255;
355 for (
int value = 0; value < 255; value += 16) {
357 for (
int hue = 0; hue < 255; hue += 6) {
358 line.push_back(
text(
"â–€")
362 array.push_back(
hbox(std::move(line)));
364 true_color_display =
vbox({
367 vbox(std::move(array)),
375 palette_256_color_display,
384 auto render_gauge = [&shift](
int delta) {
385 float progress = (shift + delta) % 500 / 500.f;
387 text(std::to_string(
int(progress * 100)) +
"% ") |
393 auto gauge_component =
Renderer([render_gauge] {
418 auto make_box = [](
size_t dimx,
size_t dimy) {
419 std::string title = std::to_string(dimx) +
"x" + std::to_string(dimy);
421 text(
"content") | hcenter | dim) |
425 auto paragraph_renderer_left =
Renderer([&] {
427 "Lorem Ipsum is simply dummy text of the printing and typesetting "
428 "industry.\nLorem Ipsum has been the industry's standard dummy text "
429 "ever since the 1500s, when an unknown printer took a galley of type "
430 "and scrambled it to make a type specimen book.";
457 vscroll_indicator | yframe | flex;
460 auto paragraph_renderer_right =
Renderer([] {
461 return paragraph(
"<--- This vertical bar is resizable using the mouse") |
465 int paragraph_renderer_split_position = Terminal::Size().dimx / 2;
466 auto paragraph_renderer_group =
468 ¶graph_renderer_split_position);
469 auto paragraph_renderer_group_renderer =
471 [&] {
return paragraph_renderer_group->Render(); });
478 std::vector<std::string> tab_entries = {
479 "htop",
"color",
"spinner",
"gauge",
"compiler",
"paragraph",
483 auto tab_content = Container::Tab(
487 spinner_tab_renderer,
490 paragraph_renderer_group_renderer,
497 auto main_container = Container::Vertical({
498 Container::Horizontal({
505 auto main_renderer =
Renderer(main_container, [&] {
509 tab_selection->Render() |
flex,
510 exit_button->Render(),
516 Loop loop(&screen, main_renderer);
517 while (!loop.HasQuitted()) {
522 screen.RequestAnimationFrame();
528 std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 60));