File procps-3.2.7-toosmall.dif of Package procps

--- top.c
+++ top.c	2008-10-22 13:00:06.976330812 +0200
@@ -2514,7 +2514,7 @@ static void do_key (unsigned c)
 
    switch (c) {
       case '1':
-         if (Cpu_tot+7 > Screen_rows && !CHKw(Curwin, View_CPUSUM)) {
+         if (Cpu_tot+7 > Screen_rows && CHKw(Curwin, View_CPUSUM)) {
             show_msg(err_num_cpus);
          } else {
 #ifdef WARN_NOT_SMP
@@ -2984,7 +2984,7 @@ static proc_t **summary_show (void)
    p_table = procs_refresh(p_table, Frames_libflags);
 
    // Display Uptime and Loadavg
-   if (CHKw(Curwin, View_LOADAV)) {
+   if (CHKw(Curwin, View_LOADAV) && (Screen_rows > Msg_row+2)) {
       if (!Rc.mode_altscr) {
          show_special(0, fmtmk(LOADAV_line, Myname, sprint_uptime()));
       } else {
@@ -3001,7 +3001,7 @@ static proc_t **summary_show (void)
    }
 
    // Display Task and Cpu(s) States
-   if (CHKw(Curwin, View_STATES)) {
+   if (CHKw(Curwin, View_STATES) && (Screen_rows > Msg_row+2)) {
       show_special(
          0,
          fmtmk(
@@ -3013,6 +3013,14 @@ static proc_t **summary_show (void)
 
       smpcpu = cpus_refresh(smpcpu);
 
+      if (Screen_rows <= Msg_row+Cpu_tot+1) {
+         if (!CHKw(Curwin, View_CPUSUM)) {
+            show_msg("\aSorry, terminal is not big enough\n");
+            TOGw(Curwin, View_CPUSUM);
+         }
+         goto skip;
+      }
+
       if (CHKw(Curwin, View_CPUSUM)) {
          // display just the 1st /proc/stat line
          summaryhlp(&smpcpu[Cpu_tot], "Cpu(s):");
@@ -3026,10 +3034,11 @@ static proc_t **summary_show (void)
          }
       }
    }
+skip:
 
    // Display Memory and Swap stats
    meminfo();
-   if (CHKw(Curwin, View_MEMORY)) {
+   if (CHKw(Curwin, View_MEMORY) && (Screen_rows > Msg_row+3)) {
       show_special(0, fmtmk(MEMORY_line1
          , kb_main_total, kb_main_used, kb_main_free, kb_main_buffers));
       show_special(0, fmtmk(MEMORY_line2
openSUSE Build Service is sponsored by