diff --git a/src/ncurses_display.cpp b/src/ncurses_display.cpp index 3f59c3e8..b44729bc 100644 --- a/src/ncurses_display.cpp +++ b/src/ncurses_display.cpp @@ -72,7 +72,9 @@ void NCursesDisplay::DisplayProcesses(std::vector& 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()); @@ -82,7 +84,7 @@ void NCursesDisplay::DisplayProcesses(std::vector& 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()); } } @@ -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);