*** empty log message ***
authorroot <root>
Thu, 22 Dec 2005 15:28:15 +0000 (15:28 +0000)
committerroot <root>
Thu, 22 Dec 2005 15:28:15 +0000 (15:28 +0000)
src/netdisp.C
src/screen.C

index ddb009c0fcae6171c6e30469771d9671171baef3..042127cf110e8fc588347fa7fbb53db691a64e15 100644 (file)
@@ -58,25 +58,28 @@ rxvt_network_display (const char *display)
       perror ("socket");
       return NULL;
     }
+
   if (ioctl (skfd, SIOCGIFCONF, &ifc) < 0)
     {
       perror ("SIOCGIFCONF");
       close (skfd);
       return NULL;
     }
+
   for (i = 0, ifr = ifc.ifc_req;
        i < (ifc.ifc_len / sizeof (struct ifreq));
        i++, ifr++)
     {
-      struct ifreq    ifr2;
+      struct ifreq ifr2;
 
       strcpy (ifr2.ifr_name, ifr->ifr_name);
+
       if (ioctl (skfd, SIOCGIFADDR, &ifr2) >= 0)
         {
-          unsigned long   addr;
+          unsigned long addr;
           struct sockaddr_in *p_addr;
 
-          p_addr = (struct sockaddr_in *)& (ifr2.ifr_addr);
+          p_addr = (struct sockaddr_in *) &ifr2.ifr_addr;
           addr = htonl ((unsigned long)p_addr->sin_addr.s_addr);
 
           /*
@@ -84,7 +87,7 @@ rxvt_network_display (const char *display)
            */
           if (addr && addr != 0x7F000001)
             {
-              char           *colon = strchr (display, ':');
+              char *colon = strchr (display, ':');
 
               if (colon == NULL)
                 colon = ":0.0";
@@ -101,6 +104,7 @@ rxvt_network_display (const char *display)
     }
 
   close (skfd);
+
   return rval;
 }
 #endif                         /* DISPLAY_IS_IP */
index 47b3a45c8b82d4748ee4223c5555c7902f7bd1cf..8889cc057c62c1f83c5eb38935ae2947f99e80cf 100644 (file)
@@ -273,91 +273,118 @@ rxvt_term::scr_reset ()
 
       line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t));
         
-      // re-wrap lines, this is rather ugly, possibly because I am too dumb
-      // to come up with a lean and mean algorithm.
-
       int p    = MOD (term_start + prev_nrow, prev_total_rows);  // previous row
       int pend = MOD (term_start - nsaved   , prev_total_rows);
       int q    = total_rows; // rewrapped row
 
-      while (p != pend && q > 0)
+      if (nsaved)
         {
-          p = MOD (p - 1, prev_total_rows);
-#ifdef DEBUG_STRICT
-          assert (old_buf [MOD (p, prev_total_rows)].t);
-#endif
-
-          int llen = old_buf [MOD (p, prev_total_rows)].l;
+          // re-wrap lines, this is rather ugly, possibly because I am too dumb
+          // to come up with a lean and mean algorithm.
 
-          while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
+          while (p != pend && q > 0)
             {
               p = MOD (p - 1, prev_total_rows);
+#ifdef DEBUG_STRICT
+              assert (old_buf [MOD (p, prev_total_rows)].t);
+#endif
 
-              llen += prev_ncol;
-            }
+              int llen = old_buf [MOD (p, prev_total_rows)].l;
 
-          int qlines = max (0, (llen - 1) / ncol) + 1;
+              while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
+                {
+                  p = MOD (p - 1, prev_total_rows);
 
-          // drop partial lines completely
-          if (q < qlines)
-            break;
+                  llen += prev_ncol;
+                }
 
-          q -= qlines;
+              int qlines = max (0, (llen - 1) / ncol) + 1;
 
-          int lofs = 0;
-          line_t *qline;
+              // drop partial lines completely
+              if (q < qlines)
+                break;
 
-          // re-assemble the full line by destination lines
-          for (int qrow = q; qlines--; qrow++)
-            {
-              qline = row_buf + qrow;
-              lalloc (*qline);
-              qline->set_is_longer ();
+              q -= qlines;
 
-              int qcol = 0;
+              int lofs = 0;
+              line_t *qline;
 
-              // fill a single destination line
-              while (lofs < llen && qcol < ncol)
+              // re-assemble the full line by destination lines
+              for (int qrow = q; qlines--; qrow++)
                 {
-                  int prow = lofs / prev_ncol;
-                  int pcol = lofs % prev_ncol;
+                  qline = row_buf + qrow;
+                  lalloc (*qline);
+                  qline->set_is_longer ();
+
+                  int qcol = 0;
+
+                  // fill a single destination line
+                  while (lofs < llen && qcol < ncol)
+                    {
+                      int prow = lofs / prev_ncol;
+                      int pcol = lofs % prev_ncol;
 
-                  line_t &pline = old_buf [MOD (p + prow, prev_total_rows)];
+                      line_t &pline = old_buf [MOD (p + prow, prev_total_rows)];
 
-                  int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
+                      int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
 
-                  assert (len);
-                  assert (pline.t);
+                      assert (len);
+                      assert (pline.t);
 
-                  memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
-                  memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
+                      memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
+                      memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
 
-                  lofs += len;
-                  qcol += len;
+                      lofs += len;
+                      qcol += len;
+                    }
                 }
+
+              qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1;
+              scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
             }
 
-          qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1;
-          scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
+          term_start = total_rows - nrow;
+          view_start = 0;
+          nsaved = term_start - q;
+          // make sure all terminal lines exist
+          while (nsaved < 0)
+            scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
+
         }
+      else
+        {
+          // if no scrollback exists (yet), wing, instead of wrap
+          
+          for (int row = min (nrow, prev_nrow); row--; )
+            {
+              line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)];
+              line_t &qline = row_buf [row];
 
-      term_start = total_rows - nrow;
-      view_start = 0;
-      nsaved = term_start - q;
+              qline = pline;
+              lresize (qline);
+            }
 
-      // make sure all terminal lines exist
-      while (nsaved < 0)
-        scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
+          for (int row = prev_nrow; row < nrow; row++)
+            {
+              row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
+            }
 
+          term_start = 0;
+          view_start = 0;
+        }
+
+#ifdef DEBUG_STRICT
       for (int i = -nsaved; i < nrow; i++)
-        assert (ROW (i).t);//D
+        assert (ROW (i).t);
+#endif
 
       free (old_buf);
       delete old_ta;
       delete old_ra;
 
-      min_it (screen.cur.row, nrow - 1);
-      min_it (screen.cur.col, ncol - 1);
+      clamp_it (screen.cur.row, 0, nrow - 1);
+      clamp_it (screen.cur.col, 0, ncol - 1);
 
       if (tabs)
         free (tabs);