| 18 | } |
| 19 | |
| 20 | int main() { |
| 21 | std::thread tUserInput(waitingForWorkEnterKey); |
| 22 | while (keep_running) { |
| 23 | Table process_table; |
| 24 | std::random_device rd; |
| 25 | std::mt19937 gen(rd()); |
| 26 | std::uniform_real_distribution<> dis(0, 1); |
| 27 | process_table.add_row(Row_t{"PID", "%CPU", "%MEM", "User", "NI"}); |
| 28 | process_table.add_row(Row_t{"4297", std::to_string((int)round(dis(gen) * 100)), |
| 29 | std::to_string((int)round(dis(gen) * 100)), "ubuntu", "20"}); |
| 30 | process_table.add_row(Row_t{"12671", std::to_string((int)round(dis(gen) * 100)), |
| 31 | std::to_string((int)round(dis(gen) * 100)), "root", "0"}); |
| 32 | process_table.add_row({"810", std::to_string((int)round(dis(gen) * 100)), |
| 33 | std::to_string((int)round(dis(gen) * 100)), "root", "-20"}); |
| 34 | |
| 35 | process_table.column(2).format().font_align(FontAlign::center); |
| 36 | process_table.column(3).format().font_align(FontAlign::right); |
| 37 | process_table.column(4).format().font_align(FontAlign::right); |
| 38 | |
| 39 | for (size_t i = 0; i < 5; ++i) { |
| 40 | process_table[0][i] |
| 41 | .format() |
| 42 | .font_color(Color::yellow) |
| 43 | .font_align(FontAlign::center) |
| 44 | .font_style({FontStyle::bold}); |
| 45 | } |
| 46 | |
| 47 | std::cout << process_table << std::endl; |
| 48 | std::cout << "Press ENTER to exit..." << std::endl; |
| 49 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); |
| 50 | std::cout << "\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F\033[F"; |
| 51 | } |
| 52 | std::cout << "\033[B\033[B\033[B\033[B\033[B\033[B\033[B\033[B\033[B\033[B"; |
| 53 | tUserInput.join(); |
| 54 | |
| 55 | return 0; |
| 56 | } |