Today I implemented a simple TUI (text-based user interface) using termios.
During development, I needed to avoid blocking the main loop, so I couldn’t directly use functions like getchar() for input. Instead, I used read() along with fcntl to enable non-blocking input handling.
I also refactored the CPU usage calculation function. Previously, I had sleep(1) inside the function, which caused the UI to feel unresponsive. I moved the sleep call into the main loop to improve responsiveness and overall control of the update cycle.
Now the program supports switching between different views using keys 1, 2, 3, and 4.
In the future, I plan to integrate ncurses to build a more advanced and user-friendly interface.