Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/ncurses_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ void NCursesDisplay::DisplayProcesses(std::vector<Process>& processes,
for (int i = 0; i < n; ++i) {
//You need to take care of the fact that the cpu utilization has already been multiplied by 100.
// Clear the line
mvwprintw(window, ++row, pid_column, (string(window->_maxx-2, ' ').c_str()));
int w = getmaxx(window);
mvwprintw(window, ++row, pid_column, "%s",
std::string(std::max(0, w - 2), ' ').c_str());

mvwprintw(window, row, pid_column, "%s", to_string(processes[i].Pid()).c_str());
mvwprintw(window, row, user_column, "%s", processes[i].User().c_str());
Expand All @@ -82,7 +84,7 @@ void NCursesDisplay::DisplayProcesses(std::vector<Process>& processes,
mvwprintw(window, row, time_column, "%s",
Format::ElapsedTime(processes[i].UpTime()).c_str());
mvwprintw(window, row, command_column, "%s",
processes[i].Command().substr(0, window->_maxx - 46).c_str());
processes[i].Command().substr(0, std::max(0, w - 46)).c_str());
}
}

Expand All @@ -94,8 +96,9 @@ void NCursesDisplay::Display(System& system, int n) {

int x_max{getmaxx(stdscr)};
WINDOW* system_window = newwin(9, x_max - 1, 0, 0);
WINDOW* process_window =
newwin(3 + n, x_max - 1, system_window->_maxy + 1, 0);
int sy = getbegy(system_window);
int sh = getmaxy(system_window);
WINDOW* process_window = newwin(3 + n, x_max -1, sy + sh, 0);

while (1) {
init_pair(1, COLOR_BLUE, COLOR_BLACK);
Expand Down